From 00e064086ed5f405bc478bef1a1993a508f6570d Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Thu, 12 Mar 2020 13:58:48 +0000 Subject: [PATCH] (buf)melband has now a the normalize flag in the help and in the class def --- release-packaging/Classes/FluidBufMelBands.sc | 16 ++++++++-------- release-packaging/Classes/FluidMelBands.sc | 4 ++-- .../HelpSource/Classes/FluidBufMelBands.schelp | 3 +++ .../HelpSource/Classes/FluidMelBands.schelp | 13 ++++++++----- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/release-packaging/Classes/FluidBufMelBands.sc b/release-packaging/Classes/FluidBufMelBands.sc index c9fa718..6ec3f8f 100644 --- a/release-packaging/Classes/FluidBufMelBands.sc +++ b/release-packaging/Classes/FluidBufMelBands.sc @@ -1,5 +1,5 @@ FluidBufMelBands : UGen { - *new1 { |rate, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, windowSize = 1024, hopSize = -1, fftSize = -1, doneAction = 0, blocking = 0| + *new1 { |rate, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, normalize = 1, windowSize = 1024, hopSize = -1, fftSize = -1, doneAction = 0, blocking = 0| var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize}; @@ -13,26 +13,26 @@ FluidBufMelBands : UGen { //whatever has been passed in language-side (e.g maxFFTSize still exists as a parameter for the server plugin, but makes less sense here: it just needs to be set to a legal value) // same for maxNumBands which is passed numBands - ^super.new1(rate, source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, numBands, windowSize, hopSize, fftSize, maxFFTSize, doneAction, blocking); + ^super.new1(rate, source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, numBands, normalize, windowSize, hopSize, fftSize, maxFFTSize, doneAction, blocking); } - *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, windowSize = 1024, hopSize = -1, fftSize = -1, doneAction = 0| - ^this.multiNew(\control, source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, numBands, windowSize, hopSize, fftSize, doneAction); + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, normalize = 1, windowSize = 1024, hopSize = -1, fftSize = -1, doneAction = 0| + ^this.multiNew(\control, source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, numBands, normalize, windowSize, hopSize, fftSize, doneAction); } - *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, windowSize = 1024, hopSize = -1, fftSize = -1, action| + *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, normalize = 1, windowSize = 1024, hopSize = -1, fftSize = -1, action| ^FluidNRTProcess.new( server, this, action, [features] ).process( - source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, windowSize, hopSize, fftSize + source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, normalize, windowSize, hopSize, fftSize ); } - *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, windowSize = 1024, hopSize = -1, fftSize = -1, action| + *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, numBands = 40, minFreq = 20, maxFreq = 20000, normalize = 1, windowSize = 1024, hopSize = -1, fftSize = -1, action| ^FluidNRTProcess.new( server, this, action, [features], blocking:1 ).process( - source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, windowSize, hopSize, fftSize + source, startFrame, numFrames, startChan, numChans, features, numBands, minFreq, maxFreq, normalize, windowSize, hopSize, fftSize ); } } \ No newline at end of file diff --git a/release-packaging/Classes/FluidMelBands.sc b/release-packaging/Classes/FluidMelBands.sc index 3021006..db0aa35 100644 --- a/release-packaging/Classes/FluidMelBands.sc +++ b/release-packaging/Classes/FluidMelBands.sc @@ -1,7 +1,7 @@ FluidMelBands : MultiOutUGen { - *kr { arg in = 0, numBands = 40, minFreq = 20, maxFreq = 20000, maxNumBands = 120, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = 16384; - ^this.multiNew('control', in.asAudioRateInput(this), numBands, minFreq, maxFreq, maxNumBands, windowSize, hopSize, fftSize, maxFFTSize); + *kr { arg in = 0, numBands = 40, minFreq = 20, maxFreq = 20000, maxNumBands = 120, normalize = 1, windowSize = 1024, hopSize = -1, fftSize = -1, maxFFTSize = 16384; + ^this.multiNew('control', in.asAudioRateInput(this), numBands, minFreq, maxFreq, maxNumBands, normalize, windowSize, hopSize, fftSize, maxFFTSize); } init {arg ...theInputs; diff --git a/release-packaging/HelpSource/Classes/FluidBufMelBands.schelp b/release-packaging/HelpSource/Classes/FluidBufMelBands.schelp index b02a2f0..972c838 100644 --- a/release-packaging/HelpSource/Classes/FluidBufMelBands.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufMelBands.schelp @@ -48,6 +48,9 @@ ARGUMENT:: minFreq ARGUMENT:: maxFreq The highest boundary of the highest band of the model, in Hz. +ARGUMENT:: normalize + This flag enables the scaling of the output to preserve the energy per band. It is on (1) by default. + ARGUMENT:: windowSize The window size. As spectral description 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 diff --git a/release-packaging/HelpSource/Classes/FluidMelBands.schelp b/release-packaging/HelpSource/Classes/FluidMelBands.schelp index ae986ee..94a33fa 100644 --- a/release-packaging/HelpSource/Classes/FluidMelBands.schelp +++ b/release-packaging/HelpSource/Classes/FluidMelBands.schelp @@ -28,6 +28,9 @@ ARGUMENT:: maxFreq 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:: normalize + This flag enables the scaling of the output to preserve the energy per band. It is on (1) by default. + ARGUMENT:: windowSize 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 @@ -59,7 +62,7 @@ a = MultiSliderView(w,Rect(10, 10, 600, 300)).elasticMode_(1).isFilled_(1); //run the window updating routine. ( -~winRange = 100; +~winRange = 0.1; r = Routine { { b.get({ arg val; @@ -78,7 +81,7 @@ r = Routine { ( x = { var source = SinOsc.ar(LFTri.kr(0.1).exprange(80,800),0,0.1); - Out.kr(b,FluidMelBands.kr(source,maxNumBands:40) / 50); + Out.kr(b,FluidMelBands.kr(source,maxNumBands:40)); source.dup; }.play; ) @@ -99,7 +102,7 @@ x = {arg bands = 40, low = 20, high = 20000; ) //set the winRange to a more informative value -~winRange = 400; +~winRange = 0.05; // observe the number of bands. The unused ones at the top are not updated x.set(\bands,20) @@ -154,7 +157,7 @@ var stepMel = rangeMel / 41; arg i; var freqMel = (stepMel * (i +1)) + lowMel; var freq = ((freqMel/ 1127.01048).exp - 1 ) * 700; - {SinOsc.ar(freq,mul:Lag.kr(In.kr(b,40)[i],512*SampleDur.ir,0.00005))}.play(d,1,addAction:\addToTail); + {SinOsc.ar(freq,mul:Lag.kr(In.kr(b,40)[i],512*SampleDur.ir,0.5))}.play(d,1,addAction:\addToTail); }); ) @@ -193,7 +196,7 @@ x = { var stepMel = rangeMel / 41; var freqMel = (stepMel * (i +1)) + lowMel; var freq = ((freqMel/ 1127.01048).exp - 1 ) * 700; - SinOsc.ar(freq,mul:Lag.kr(In.kr(b,40)[i],512*SampleDur.ir,0.00005))}.play(d,1,addAction:\addToTail); + SinOsc.ar(freq,mul:Lag.kr(In.kr(b,40)[i],512*SampleDur.ir,0.5))}.play(d,1,addAction:\addToTail); }); )