change to BufThresh to accept rect selection

nix
Pierre Alexandre Tremblay 5 years ago
parent c663657c72
commit e4607bf097

@ -1,31 +1,31 @@
FluidBufThresh : UGen { FluidBufThresh : UGen {
*new1 { |rate, source, destination, threshold = 0, trig = 1, blocking| *new1 { |rate, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, threshold = 0, trig = 1, blocking|
source = source.asUGenInput; source = source.asUGenInput;
destination = destination.asUGenInput; destination = destination.asUGenInput;
source.isNil.if {"FluidBufThresh: Invalid source buffer".throw}; source.isNil.if {"FluidBufThresh: Invalid source buffer".throw};
destination.isNil.if {"FluidBufThresh: Invalid destination buffer".throw}; destination.isNil.if {"FluidBufThresh: Invalid destination buffer".throw};
^super.new1(rate, source, destination, threshold, trig, blocking); ^super.new1(rate, source, startFrame, numFrames, startChan, numChans, destination, threshold, trig, blocking);
} }
*kr { |source, destination, threshold = 0, trig = 1, blocking = 1| *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, threshold = 0, trig = 1, blocking = 1|
^this.new1('control', source, destination, threshold, trig, blocking); ^this.new1('control', source, startFrame, numFrames, startChan, numChans, destination, threshold, trig, blocking);
} }
*process { |server, source, destination, threshold = 0, action| *process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, threshold = 0, action|
^FluidNRTProcess.new( ^FluidNRTProcess.new(
server, this, action, [destination], blocking:1 server, this, action, [destination], blocking:1
).process( ).process(
source, destination, threshold source, startFrame, numFrames, startChan, numChans, destination, threshold
); );
} }
*processBlocking { |server, source, destination, threshold = 0, action| *processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, threshold = 0, action|
^process( ^process(
source, destination, threshold source, startFrame, numFrames, startChan, numChans, destination, threshold
); );
} }
} }

@ -23,6 +23,18 @@ ARGUMENT:: server
ARGUMENT:: source ARGUMENT:: source
The index of the buffer to use as the source material to be processed. The index of the buffer to use as the source material to be processed.
ARGUMENT:: startFrame
The starting point (in samples) from which to copy in the source buffer.
ARGUMENT:: numFrames
The duration (in samples) to copy from the source buffer. The default (-1) copies the full lenght of the buffer.
ARGUMENT:: startChan
The first channel from which to copy in the source buffer.
ARGUMENT:: numChans
The number of channels from which to copy in the source buffer. This parameter will wrap around the number of channels in the source buffer. The default (-1) copies all of the buffer's channel.
ARGUMENT:: destination ARGUMENT:: destination
The index of the buffer to use as the destination for the processed material. The index of the buffer to use as the destination for the processed material.
@ -43,7 +55,7 @@ b = Buffer.sendCollection(s,0.0.series(0.1,1.0))
// and a destination buffer // and a destination buffer
c = Buffer(s) c = Buffer(s)
// play with the threshold // play with the threshold
FluidBufThresh.process(s,b,c,0.5) FluidBufThresh.process(s, b, destination: c, threshold: 0.5)
// retrieve the buffer and enjoy the results. // retrieve the buffer and enjoy the results.
c.getn(0,11,{|x|x.postln;}) c.getn(0,11,{|x|x.postln;})
@ -51,7 +63,15 @@ c.getn(0,11,{|x|x.postln;})
b = Buffer.sendCollection(s,0.0.series(0.1,2.0).scramble,2) b = Buffer.sendCollection(s,0.0.series(0.1,2.0).scramble,2)
b.plot.plotMode_(\points) b.plot.plotMode_(\points)
//process and keep just the top values //process and keep just the top values
FluidBufThresh.process(s,b,c,1.6) FluidBufThresh.process(s, b, destination: c, threshold: 1.6)
//enjoy //enjoy
c.plot.plotMode_(\points) c.plot.plotMode_(\points)
//also works with a subset of the input, resizing the output
b = Buffer.sendCollection(s,0.0.series(0.1,3.0).reshape(3,10).flop.flat,3)
b.plot(separately: true).plotMode_(\points)
//process and keep just the top values
FluidBufThresh.process(s, b,startFrame: 3,numFrames: 4,startChan: 1,numChans: 1,destination: c, threshold: 1.6)
//enjoy
c.plot(separately: true).plotMode_(\points)
:: ::

Loading…
Cancel
Save