A pitch and chroma implementation in written Java
The implementation is based on http://resources.mpi-inf.mpg.de/MIR/chromatoolbox/
After loading the .wav file using the Wave
class, we can use the Chroma
class to generate the chroma.
The signal2Chroma
function gets as input a wave file and returns a 2D matrix which represents the chroma.
String filename = "data/piano.wav"; // THE PATH TO THE WAV FILE
Wave wave = new Wave(filename);
Chroma chromaGenerator = new Chroma();
double [][] chroma;
chroma = chromaGenerator.signal2Chroma(wave.getNormalizedAmplitudes());
DataAccess dal = new DataAccess();
dal.writeMatrixToFile(chroma,"src/test/resources/data/chroma.txt");
In order to visualize the chroma, you can use the python script inside the python folder.
cd into the python folder and type:
python plot_matrix.py --chroma 'src/test/resources/data/chroma.txt'