|
|
|
|
@ -1,23 +1,47 @@
|
|
|
|
|
FluidBufPitch : FluidBufProcessor{
|
|
|
|
|
|
|
|
|
|
*kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, trig = 1, blocking = 0|
|
|
|
|
|
const <features=#[\pitch, \confidence];
|
|
|
|
|
classvar featuresLookup;
|
|
|
|
|
|
|
|
|
|
*initClass {
|
|
|
|
|
featuresLookup = Dictionary.with(*this.features.collect{|x,i| x->(1<<i)});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*prWarnUnrecognised {|sym| ("WARNING: FluidBufPitch -" + sym + "is not a recognised option").postln}
|
|
|
|
|
|
|
|
|
|
*prProcessSelect {|a|
|
|
|
|
|
var bits;
|
|
|
|
|
a.asBag.countsDo{|item,count,i|
|
|
|
|
|
if(count > 1) { ("Option '" ++ item ++ "' is repeated").warn};
|
|
|
|
|
};
|
|
|
|
|
bits = a.collect{ |sym|
|
|
|
|
|
(featuresLookup[sym.asSymbol] !? {|x| x} ?? {this.prWarnUnrecognised(sym); 0})
|
|
|
|
|
}.reduce{|x,y| x | y};
|
|
|
|
|
^bits
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, select, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, trig = 1, blocking = 0|
|
|
|
|
|
|
|
|
|
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
|
|
|
|
|
|
|
|
|
var selectbits = select !? {this.prProcessSelect(select)} ?? {this.prProcessSelect(this.features)};
|
|
|
|
|
|
|
|
|
|
source = source.asUGenInput;
|
|
|
|
|
features = features.asUGenInput;
|
|
|
|
|
|
|
|
|
|
source.isNil.if {"FluidBufPitch: Invalid source buffer".throw};
|
|
|
|
|
features.isNil.if {"FluidBufPitch: Invalid features buffer".throw};
|
|
|
|
|
|
|
|
|
|
^FluidProxyUgen.kr(\FluidBufPitchTrigger, -1, source, startFrame, numFrames, startChan, numChans, features, padding, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, trig, blocking);
|
|
|
|
|
^FluidProxyUgen.kr(\FluidBufPitchTrigger, -1, source, startFrame, numFrames, startChan, numChans, features, padding, selectbits, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, trig, blocking);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
|
|
|
|
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, select, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
|
|
|
|
|
|
|
|
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
|
|
|
|
|
|
|
|
|
var selectbits = select !? {this.prProcessSelect(select)} ?? {this.prProcessSelect(this.features)};
|
|
|
|
|
|
|
|
|
|
source = source.asUGenInput;
|
|
|
|
|
features = features.asUGenInput;
|
|
|
|
|
|
|
|
|
|
@ -27,14 +51,16 @@ FluidBufPitch : FluidBufProcessor{
|
|
|
|
|
^this.new(
|
|
|
|
|
server, nil, [features]
|
|
|
|
|
).processList(
|
|
|
|
|
[source, startFrame, numFrames, startChan, numChans, features, padding, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, 0], freeWhenDone, action
|
|
|
|
|
[source, startFrame, numFrames, startChan, numChans, features, padding, selectbits, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, 0], freeWhenDone, action
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
|
|
|
|
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, features, select, algorithm = 2, minFreq = 20, maxFreq = 10000, unit = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
|
|
|
|
|
|
|
|
|
var maxFFTSize = if (fftSize == -1) {windowSize.nextPowerOfTwo} {fftSize};
|
|
|
|
|
|
|
|
|
|
var selectbits = select !? {this.prProcessSelect(select)} ?? {this.prProcessSelect(this.features)};
|
|
|
|
|
|
|
|
|
|
source = source.asUGenInput;
|
|
|
|
|
features = features.asUGenInput;
|
|
|
|
|
|
|
|
|
|
@ -44,7 +70,7 @@ FluidBufPitch : FluidBufProcessor{
|
|
|
|
|
^this.new(
|
|
|
|
|
server, nil, [features]
|
|
|
|
|
).processList(
|
|
|
|
|
[source, startFrame, numFrames, startChan, numChans, features, padding, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, 1], freeWhenDone, action
|
|
|
|
|
[source, startFrame, numFrames, startChan, numChans, features, padding, selectbits, algorithm, minFreq, maxFreq, unit, windowSize, hopSize, fftSize, maxFFTSize, 1], freeWhenDone, action
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|