Plot the audio-analysis images of this gallery.
Clone or fork the repository folder and get into the folder.
Make sure you have a stereo wav file in the folder, like the example aural30sec-001-WLP.wav
.
Make the scripts executable $ chmod +x split-and-mix.sh
.
Run in the terminal
$ ./split-and-mix.sh
This will take all the wav files in the repository folder and generate in yourfolder
the wav files to be analysed in sonic-annotator. The script uses sox, so you will have to install this first, for example brew install sox
.
The script will create a mono mixed 16bit version of your stereo file and split the channels in left and right.
The naming righ
is for string uniformity.
#!/bin/bash
for f in *.wav;
do
sox "$f" -b 16 "yourfolder/${f:0:${#f}-4}-left.wav" remix 1
sox "$f" -b 16 "yourfolder/${f:0:${#f}-4}-righ.wav" remix 2
sox "$f" -b 16 "yourfolder/${f:0:${#f}-4}-mono.wav" remix 1,2
done
Now move to yourfolder
:
$ cd yourfolder
You have now two choices: (i) you generate new csv below with sonic-annotator, (ii) you test the script with the csv provided.
You will need to have sonic-annotator installed.
To generate the files with sonic-annotator you need to use a transform file loudness.n3
like this and run the following script, also here.
Remember again to make the batch wav file script executable $ chmod +x runLoudness.sh
.
#!/bin/bash
for f in *.wav;
do
sonic-annotator -t loudness.n3 "$f" -w csv
done
If you want to select only some files apply the transorm from terminal.
$ sonic-annotator -t loudness.n3 *.wav -w csv
You can use $ sonic-annotator -t loudness.n3 *.wav -w csv --csv-force
if you are overwiting csv files.
After having generated the analysis files, or to test this example, you can run spectralLoudSub.py with aural30sec-001-WLP-mono.wav by typing in the terminal:
python spectralLoudSub.py *mono.wav
This will look for all wave files ending in mono.wav
and run the script.
The script plots the spectrogram for the given file and looks for the left and right csv file of the given file removing the last part *abcd.wav
.
This is because sonic-annotator transforms a given file in output
filetitle.wav_vamp_vamp-libxtract_loudness_loudness.csv
.
Therefore, we clean the termination and read the already generated csv files for left and right channel. The script takes the data an plots the loudness representation above the spectrogram, plotting the difference between left and right channel, on the Y = 0 axis.