Feature/peaks (#143)
* working frankenstein freq only * removed all the unused arguments * now with mag out * now with the buffer version * change the interface to singular like other bufSTFT * added logFreq and linMag * change of interface (sortBy to order) * last SC commit - object overview addednix
parent
2ab8f1a509
commit
d42ccf1e8d
@ -0,0 +1,51 @@
|
|||||||
|
FluidBufSineFeature : FluidBufProcessor {
|
||||||
|
|
||||||
|
*kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, frequency = -1, magnitude = -1, numPeaks = 10, detectionThreshold = -96, order = 0, freqUnit = 0, magUnit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, trig = 1, blocking = 0|
|
||||||
|
|
||||||
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
||||||
|
|
||||||
|
source = source.asUGenInput;
|
||||||
|
frequency = frequency !? {frequency.asUGenInput} ?? {-1};
|
||||||
|
magnitude = magnitude !? {magnitude.asUGenInput} ?? {-1};
|
||||||
|
|
||||||
|
source.isNil.if {"FluidBufSineFeature: Invalid source buffer".throw};
|
||||||
|
|
||||||
|
^FluidProxyUgen.multiNew(\FluidBufSineFeatureTrigger, -1, source, startFrame, numFrames, startChan, numChans, frequency, magnitude, padding, numPeaks, numPeaks, detectionThreshold, order, freqUnit, magUnit, windowSize, hopSize, fftSize, maxFFTSize, trig, blocking);
|
||||||
|
}
|
||||||
|
|
||||||
|
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, frequency = -1, magnitude = -1, numPeaks = 10, detectionThreshold = -96, order = 0, freqUnit = 0, magUnit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
||||||
|
|
||||||
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
||||||
|
|
||||||
|
source = source.asUGenInput;
|
||||||
|
frequency = frequency !? {frequency.asUGenInput} ?? {-1};
|
||||||
|
magnitude = magnitude !? {magnitude.asUGenInput} ?? {-1};
|
||||||
|
|
||||||
|
source.isNil.if {"FluidBufSineFeature: Invalid source buffer".throw};
|
||||||
|
|
||||||
|
^this.new(
|
||||||
|
server, nil, [frequency, magnitude].select{|x| x!= -1}
|
||||||
|
).processList(
|
||||||
|
[source, startFrame, numFrames, startChan, numChans, frequency, magnitude, padding, numPeaks, numPeaks, detectionThreshold, order, freqUnit, magUnit, windowSize, hopSize, fftSize,maxFFTSize,0],freeWhenDone,action
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, frequency = -1, magnitude = -1, numPeaks = 10, detectionThreshold = -96, order = 0, freqUnit = 0, magUnit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
||||||
|
|
||||||
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
||||||
|
|
||||||
|
source = source.asUGenInput;
|
||||||
|
frequency = frequency !? {frequency.asUGenInput} ?? {-1};
|
||||||
|
magnitude = magnitude !? {magnitude.asUGenInput} ?? {-1};
|
||||||
|
|
||||||
|
source.isNil.if {"FluidBufSineFeature: Invalid source buffer".throw};
|
||||||
|
|
||||||
|
^this.new(
|
||||||
|
server, nil, [frequency, magnitude].select{|x| x!= -1}
|
||||||
|
).processList(
|
||||||
|
[source, startFrame, numFrames, startChan, numChans, frequency, magnitude, padding, numPeaks, numPeaks, detectionThreshold, order, freqUnit, magUnit, windowSize, hopSize, fftSize,maxFFTSize,1],freeWhenDone,action
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
FluidBufSineFeatureTrigger : FluidProxyUgen {}
|
||||||
@ -0,0 +1,37 @@
|
|||||||
|
FluidSineFeature : FluidRTMultiOutUGen {
|
||||||
|
*kr { arg in = 0, numPeaks = 10, detectionThreshold = -96, order = 0, freqUnit = 0, magUnit = 0, windowSize= 1024, hopSize= -1, fftSize= -1, maxFFTSize = -1, maxNumPeaks = nil;
|
||||||
|
|
||||||
|
maxNumPeaks = maxNumPeaks ? numPeaks;
|
||||||
|
|
||||||
|
^this.multiNew('control', in.asAudioRateInput(this), numPeaks, maxNumPeaks, detectionThreshold, order, freqUnit, magUnit, windowSize, hopSize, fftSize, maxFFTSize)
|
||||||
|
}
|
||||||
|
|
||||||
|
init { arg ... theInputs;
|
||||||
|
inputs = theInputs;
|
||||||
|
^this.initOutputs(inputs.at(2),rate);//this instantiate the number of output from the maxNumPeaks in the multiNew order
|
||||||
|
}
|
||||||
|
|
||||||
|
checkInputs {
|
||||||
|
if(inputs.at(8).rate != 'scalar') {
|
||||||
|
^(": maxNumPeaks cannot be modulated.");
|
||||||
|
};
|
||||||
|
if(inputs.at(7).rate != 'scalar') {
|
||||||
|
^(": maxFFTSize cannot be modulated.");
|
||||||
|
};
|
||||||
|
^this.checkValidInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
initOutputs{|numChans,rate|
|
||||||
|
if(numChans.isNil or: {numChans < 1})
|
||||||
|
{
|
||||||
|
Error("No input channels").throw
|
||||||
|
};
|
||||||
|
|
||||||
|
channels = Array.fill(numChans * 2, { |i|
|
||||||
|
OutputProxy('control',this,i);
|
||||||
|
});
|
||||||
|
^channels
|
||||||
|
}
|
||||||
|
|
||||||
|
numOutputs { ^(channels.size); }
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue