From e4607bf097dc3adb7dbb40b0f2b460a29ac98494 Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Wed, 16 Sep 2020 12:39:24 +0100 Subject: [PATCH] change to BufThresh to accept rect selection --- release-packaging/Classes/FluidBufThresh.sc | 16 ++++++------- .../HelpSource/Classes/FluidBufThresh.schelp | 24 +++++++++++++++++-- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/release-packaging/Classes/FluidBufThresh.sc b/release-packaging/Classes/FluidBufThresh.sc index 30ba0fd..ca4c942 100644 --- a/release-packaging/Classes/FluidBufThresh.sc +++ b/release-packaging/Classes/FluidBufThresh.sc @@ -1,31 +1,31 @@ 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; destination = destination.asUGenInput; source.isNil.if {"FluidBufThresh: Invalid source 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| - ^this.new1('control', source, destination, threshold, trig, blocking); + *kr { |source, startFrame = 0, numFrames = -1, startChan = 0, numChans = -1, destination, threshold = 0, trig = 1, blocking = 1| + ^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( server, this, action, [destination], blocking:1 ).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( - source, destination, threshold + source, startFrame, numFrames, startChan, numChans, destination, threshold ); } } diff --git a/release-packaging/HelpSource/Classes/FluidBufThresh.schelp b/release-packaging/HelpSource/Classes/FluidBufThresh.schelp index 3540851..e20fa7b 100644 --- a/release-packaging/HelpSource/Classes/FluidBufThresh.schelp +++ b/release-packaging/HelpSource/Classes/FluidBufThresh.schelp @@ -23,6 +23,18 @@ ARGUMENT:: server ARGUMENT:: source 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 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 c = Buffer(s) // 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. 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.plot.plotMode_(\points) //process and keep just the top values -FluidBufThresh.process(s,b,c,1.6) +FluidBufThresh.process(s, b, destination: c, threshold: 1.6) //enjoy 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) ::