|
|
TITLE:: FluidMelBands
|
|
|
SUMMARY:: A Perceptually Spread Spectral Contour Descriptor in Real-Time
|
|
|
CATEGORIES:: Libraries>FluidDecomposition
|
|
|
RELATED:: Guides/FluCoMa, Guides/FluidDecomposition, Classes/FluidMFCC
|
|
|
|
|
|
DESCRIPTION::
|
|
|
This class implements a spectral shape descriptor where the amplitude is given for a number of equally spread perceptual bands. The spread is based on the Mel scale (https://en.wikipedia.org/wiki/Mel_scale) which is one of the first attempt to mimic pitch perception scientifically. This implementation allows to select the range and number of bands dynamically. It is part of the Fluid Decomposition Toolkit of the FluCoMa project.FOOTNOTE:: This was made possible thanks to the FluCoMa project ( http://www.flucoma.org/ ) funded by the European Research Council ( https://erc.europa.eu/ ) under the European Union’s Horizon 2020 research and innovation programme (grant agreement No 725899).::
|
|
|
|
|
|
The process will return a multichannel control steam of size STRONG::maxNumBands::, which will be repeated if no change happens within the algorythm, i.e. when the hopSize is larger than the server's kr period.
|
|
|
|
|
|
CLASSMETHODS::
|
|
|
|
|
|
METHOD:: kr
|
|
|
The audio rate in, control rate out version of the object.
|
|
|
|
|
|
ARGUMENT:: in
|
|
|
The audio to be processed.
|
|
|
|
|
|
ARGUMENT:: numBands
|
|
|
The number of bands that will be perceptually equally distributed between STRONG::minFreq:: and STRONG::maxFreq::. It is limited by the STRONG::maxNumBands:: parameter. When the number is smaller than the maximum, the output is zero-padded.
|
|
|
|
|
|
ARGUMENT:: minFreq
|
|
|
The lower boundary of the lowest band of the model, in Hz.
|
|
|
|
|
|
ARGUMENT:: maxFreq
|
|
|
The highest boundary of the highest band of the model, in Hz.
|
|
|
|
|
|
ARGUMENT:: maxNumBands
|
|
|
The maximum number of Mel bands that can be modelled. This sets the number of channels of the output, and therefore cannot be modulated.
|
|
|
|
|
|
ARGUMENT:: winSize
|
|
|
The window size. As sinusoidal estimation relies on spectral frames, we need to decide what precision we give it spectrally and temporally, in line with Gabor Uncertainty principles. http://www.subsurfwiki.org/wiki/Gabor_uncertainty
|
|
|
|
|
|
ARGUMENT:: hopSize
|
|
|
The window hop size. As sinusoidal estimation relies on spectral frames, we need to move the window forward. It can be any size but low overlap will create audible artefacts. The -1 default value will default to half of winSize (overlap of 2).
|
|
|
|
|
|
ARGUMENT:: fftSize
|
|
|
The inner FFT/IFFT size. It should be at least 4 samples long, at least the size of the window, and a power of 2. Making it larger allows an oversampling of the spectral precision. The -1 default value will default to windowSize.
|
|
|
|
|
|
ARGUMENT:: maxFFTSize
|
|
|
How large can the FFT be, by allocating memory at instantiation time. This cannot be modulated.
|
|
|
|
|
|
RETURNS::
|
|
|
A KR signal of STRONG::maxNumBands:: channels, giving the measure amplitudes for each band. The latency is winSize.
|
|
|
|
|
|
|
|
|
EXAMPLES::
|
|
|
|
|
|
code::
|
|
|
//create a monitoring bus for the descriptors
|
|
|
b = Bus.new(\control,0,40);
|
|
|
|
|
|
//create a monitoring window for the values
|
|
|
|
|
|
(
|
|
|
w = Window("Mel Bands Monitor", Rect(10, 10, 620, 320)).front;
|
|
|
a = MultiSliderView(w,Rect(10, 10, 600, 300)).elasticMode_(1).isFilled_(1);
|
|
|
)
|
|
|
|
|
|
//run the window updating routine.
|
|
|
(
|
|
|
r = Routine {
|
|
|
{
|
|
|
b.get({ arg val;
|
|
|
{
|
|
|
if(w.isClosed.not) {
|
|
|
a.value = val;
|
|
|
}
|
|
|
}.defer
|
|
|
});
|
|
|
0.01.wait;
|
|
|
}.loop
|
|
|
}.play
|
|
|
)
|
|
|
|
|
|
//play a simple sound to observe the values
|
|
|
(
|
|
|
x = {
|
|
|
var source = SinOsc.ar(LFTri.kr(0.1).exprange(80,800),0,0.1);
|
|
|
Out.kr(b,FluidMelBands.kr(source,maxNumBands:40) / 50);
|
|
|
source.dup;
|
|
|
}.play;
|
|
|
)
|
|
|
|
|
|
// free this source
|
|
|
x.free
|
|
|
|
|
|
// load a more exciting one
|
|
|
c = Buffer.read(s,File.realpath(FluidMelBands.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
|
|
|
|
|
|
// analyse with parameters to be changed
|
|
|
(
|
|
|
x = {arg bands = 40, low = 20, high = 20000;
|
|
|
var source = PlayBuf.ar(1,c,loop:1);
|
|
|
Out.kr(b,FluidMelBands.kr(source, bands, low, high, 40) / 10);
|
|
|
source.dup;
|
|
|
}.play;
|
|
|
)
|
|
|
|
|
|
// observe the number of bands. The unused ones at the top are not updated
|
|
|
x.set(\bands,20)
|
|
|
|
|
|
// back to the full range
|
|
|
x.set(\bands,40)
|
|
|
|
|
|
// focus all the bands on a mid range
|
|
|
x.set(\low,320, \high, 8000)
|
|
|
|
|
|
// focusing on the low end shows the fft resolution issue. One could restart the analysis with a larger fft to show more precision
|
|
|
x.set(\low,20, \high, 160)
|
|
|
|
|
|
// back to full range
|
|
|
x.set(\low,20, \high, 20000)
|
|
|
|
|
|
// free everything
|
|
|
x.free;b.free;c.free;r.stop;
|
|
|
::
|
|
|
|
|
|
STRONG::A musical example::
|
|
|
|
|
|
CODE::
|
|
|
// todo: port the Max one
|
|
|
::
|