|0.1.0||Jul 24, 2019|
A small library for reliable, fast spectrogram generation and visualisation
Tizol provides a
Spectrogram object that allows the user to create spectrograms from raw audio data or audio files, and visualise said spectrograms. The computed spectrogram and visualised images are intended to be as-close-to identical to those computed by librosa, and should be a drop in replacement for them.
Tizol's computation is based heavily off librosa - it uses a simple short time fourier transform (STFT) to generate a raw spectrogram, which is then converted from an amplitude representation to a power representation, before finally being normalised so that elements of the spectrogram fall in the [0,1] range.
In librosa terms (omitting the final normalisation), the implementation of
from_file is roughly as follows:
samplerate = 44100 (y, sr) = librosa.load(filename, sr=samplerate, res_type='kaiser_best') S = librosa.stft(y) M = librosa.core.magphase(S) # This is implicitly done by the STFT spectrogram = librosa.amplitude_to_db(M, ref=np.max)[0:1024, :]
Tizol provides the
Spect::as_image() method for visualising already-computed spectrograms. This method is unfortunately quite slow as in order to maintain parity with the output of librosa, it uses the
Magma colourmap from the scarlet crate to compute pixel colours. For some reason, this computation is very slow, and even with parallelisation it is still roughly 10x slower than computing the actual spectrogram.
Spectrogram's support protobuffers through the prost crate, meaning that spectrograms implement the
Tizol is part of the "Ellington" project - a set of tools designed to make it easier for swing dance DJ's to automatically calculate the tempo of swing music. Each component of the project is named after a member of (or arranger for) Duke Ellington's band. Tizol is named after Juan Tizol, a solid rock of the trombone section, and the composer of "Caravan", one of the most famous jazz standards.