Music printer
Introduction
A music printer is a solution that will allow its users to generate 3D models from music and subsequently print them using 3D printer. This idea was created with two primary use cases in mind. Non-academic users will use it to generate interesting 3D models for eanjoyment and aesthetical value. Academic users can use it to compare different audio sequences and their respective attributes.
The image below illustrates the usage of our solution in both cases.
Model gallery
In this gallery, you will find a few example 3D models, that we created with our solution. These audio clips were recorded as short guitar solos with background music.
Technical documentation
In this section, we will briefly describe the technical side of our solution.
Application architecture
The image below represents the software architecture of our program used for generating 3D models from music files. The main runner is the main module responsible for the execution of the whole solution. To do so, it uses 3 other modules - Feature extractor, Param normalizer, and Model exporter. Feature extractor can use many modules for feature extraction. All they have to do is realize a simple Metric interface. Each of those modules will be used to extract only a single feature from an input file. Their interaction will be described in the Application execution section. Due to using the blender, it is necessary to use python for implementation.
Application execution
In order to use this application user will open our provided blender file, the import script that realizes our solution and executes the main runner function. Inside that this will happen: Feature extractor loads music file and extracts music features from it. Param normalizer takes those features as input process them to usable values (so they are not too big or too small). Model exporter module takes those normalized features as its input, creates a 3D model in Blender and export it in STL file.
Feature extraction
In this section feature, it is shown how feature extraction is executed inside the Feature extractor module. The extractor will use each selected metric (see User manual section) on the provided input file.
Installation guide
Prerequisites
- Blender (https://www.blender.org/)
Necessary files (download)
- smvit.blend - blender project with all different setting
- main.py - python script for generating 3D model
- requirements.txt - required python libraries to run script
Installing and setting up Blender
- Install Blender. It comes with a python interpreter.
- If you have Python installed and in the path, you need to install python libraries in the python interpreter in the path. If you don’t have Python globally installed, you need to use the provided one. It is located in the Blender installation directory
Blender\your_blender_version\python\bin
.
Install python libraries
- First, you need to determine which python interpreter is Blender using. You need to check if you have Python in the PATH variable. You can do this by executing the command “where python” in the command prompt.
- After you determine which Python is Blender using, you need to install the required libraries. Change directory to where requirements.txt is located, then run
pip install -r requirements.txt
using pip of selected Python.
User manual
Available music formats
- .wav, .mp3
Open blender file (add some comment about admin privileges), choose python, Load script
- After installing Blender you can open the provided smvit.blend file.
-
Then you need to open the Scripting tab in the menu.
- Script should be loaded automatically.
-
If it is not opened and loaded automatically you need to open it. Click Open and select the provided python file.
-
After opening the python file it should look like this.
Set control variables (path, metrics, etc…) and execute script
-
You need to set mandatory settings in the script. Set input_file as the absolute path to the .wav file you want to process. The absolute path to the output directory is stored in export_basepath. Then you need to set boundaries for model size, default settings in 20 cm max and 2.5 cm min (values are stored in meters). Model generation needs 6 values from the input file, u need to set the function to get these 6 values, choose functions from the script and save them in feature_mapping.
- You can execute the script by pressing the “Run Script” button or by keyboard shortcut
ALT + P
.
How to export to STL
- This step is done automatically in script.
-
If you want to export it manually or use a different format you need to go to
File -> Export -> Stl
(or your preferred format). -
You don’t need to change any export settings, all is set in provided Blend file
Available metrics
Sample rate
Sample rate or sampling frequency defines the number of samples per second taken from a continuous signal to make a discrete or digital signal. The most common sampling rate is 44.1 kHz or 44 100 Hz. The sample rate is measured in Hz.
Functions:
- get_sample_rate - returns sample rate of sample in Hz
Duration
Duration is the time during which something exists or lasts. Duration measures the length of a given semple. Duration is measured in seconds.
Functions:
- get_duration - returns duration of sample in seconds
Zero-crossing
A zero-crossing is a point where the sign of a mathematical function (in our case waveform) changes (e.g. from positive to negative), represented by an intercept of the axis (zero value) in the graph of the function. It is a commonly used term in electronics, mathematics, acoustics, and image processing.
Functions:
- get_zero_crossing_count - returns count of zero crossings in entire sample
- get_zero_crossing_count_per_second - returns count of zero crossings per second
Tuning
Tuning is a particular key or set of pitches to which an instrument, especially one with strings, is tuned. Tuning is measured as estimated tuning deviation (fractions of a bin).
Functions:
- get_tuning - returns estimated tuning deviation (fractions of a bin)
Linear Prediction Coefficients
Linear Prediction Coefficients via Burg’s method. We apply Burg’s method to estimate coefficients of a linear filter on a sample of order 2. Burg’s method is an extension to the Yule-Walker approach, which is known as LPC parameter estimation by autocorrelation.
Functions:
- get_positive_first_coefficient - returns first LP coefficient
- get_positive_second_coefficient - returns second LP coefficient
Tempo
In musical terminology, the tempo is the speed or pace of a given piece. In classical music, the tempo is typically indicated with an instruction at the start of a piece and is usually measured in beats per minute.
Functions:
- get_tempo - returns estimated tempo (beats per minute)
Onset
Onset refers to the beginning of a musical note or other sounds. It is related to (but different from) the concept of a transient: all musical notes have an onset but do not necessarily include an initial transient.
Functions:
- get_onset_count - returns count of detected onsets
- get_onset_frequency - returns count of detected onsets per second
- get_onset_max_strength - returns strength of the strongest onset
- get_strongest_onset_position - returns position of the strongest onset
Magnitude
The term magnitude can apply both to the scientist's desire to measure and quantify the physical size and energy of the sound wave and also to the listener's subjective evaluation of the loudness and/or volume of the aural experience. Magnitude in a given sample is divided into bins and then desired values are calculated from these bins. Magnitude is measured in dB.
Functions:
- get_min_magnitude - returns minimal magnitude in the sample
- get_mean_magnitude - returns mean of magnitude in the sample
- get_max_magnitude - returns maximal magnitude in the sample
- get_var_magnitude - returns variance of magnitude in the sample
- get_sem_magnitude - returns standard error of the mean of magnitude in the sample
Frequency
Frequency is the number of occurrences of a repeating event per unit of time. It is also occasionally referred to as temporal frequency to emphasize the contrast to spatial frequency, and ordinary frequency to emphasize the contrast to angular frequency. Frequency in a given sample is divided into bins and then desired values are calculated from these bins. Frequency is measured in Hz.
Functions:
- get_min_frequency - returns minimal frequency in the sample
- get_mean_frequency - returns mean of frequency in the sample
- get_max_frequency - returns maximal frequency in the sample
- get_var_frequency - returns variance of frequency in the sample
- get_sem_frequency - returns standard error of the mean of frequency in the sample
Links