Merge branch 'refactor/macro-purge' into log-scaling
commit
0b61aed2b9
@ -1,47 +1,47 @@
|
|||||||
FluidBufSTFT : FluidBufProcessor {
|
FluidBufSTFT : FluidBufProcessor {
|
||||||
|
|
||||||
*kr { |source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0,windowSize = 1024, hopSize = -1, fftSize = -1, trig = 1, blocking = 1|
|
*kr { |source, startFrame = 0, numFrames = -1, startChan = 0, magnitude, phase, resynthesis, inverse = 0,windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, trig = 1, blocking = 1|
|
||||||
|
|
||||||
// source = source.asUGenInput;
|
// source = source.asUGenInput;
|
||||||
|
|
||||||
// source.isNil.if {"FluidBufScale: Invalid source buffer".throw};
|
// source.isNil.if {"FluidBufScale: Invalid source buffer".throw};
|
||||||
source = source ? -1;
|
source = source ? -1;
|
||||||
magnitudeBuffer = magnitudeBuffer ? -1;
|
magnitude = magnitude ? -1;
|
||||||
phaseBuffer = phaseBuffer ? -1;
|
phase = phase ? -1;
|
||||||
resynthesisBuffer = resynthesisBuffer ? - 1;
|
resynthesis = resynthesis ? - 1;
|
||||||
|
|
||||||
^FluidProxyUgen.kr(\FluidBufSTFTTrigger, -1, source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize,trig, blocking);
|
^FluidProxyUgen.kr(\FluidBufSTFTTrigger, -1, source, startFrame, numFrames, startChan, magnitude, phase, resynthesis, inverse, padding, windowSize, hopSize, fftSize, trig, blocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
|
*process { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitude, phase, resynthesis, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1, freeWhenDone = true, action|
|
||||||
|
|
||||||
// source = source.asUGenInput;
|
// source = source.asUGenInput;
|
||||||
|
|
||||||
// source.isNil.if {"FluidBufSTFT: Invalid source buffer".throw};
|
// source.isNil.if {"FluidBufSTFT: Invalid source buffer".throw};
|
||||||
source = source ? -1;
|
source = source ? -1;
|
||||||
magnitudeBuffer = magnitudeBuffer ? -1;
|
magnitude = magnitude ? -1;
|
||||||
phaseBuffer = phaseBuffer ? -1;
|
phase = phase ? -1;
|
||||||
resynthesisBuffer = resynthesisBuffer ? - 1;
|
resynthesis = resynthesis ? - 1;
|
||||||
|
|
||||||
^this.new(
|
^this.new(
|
||||||
server, nil, [magnitudeBuffer,phaseBuffer,resynthesisBuffer].select{|b| b != -1}
|
server, nil, [magnitude,phase,resynthesis].select{|b| b != -1}
|
||||||
).processList(
|
).processList(
|
||||||
[source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize, 0], freeWhenDone, action
|
[source, startFrame, numFrames, startChan, magnitude, phase, resynthesis, inverse, padding, windowSize, hopSize, fftSize, 0], freeWhenDone, action
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1,freeWhenDone = true, action|
|
*processBlocking { |server, source, startFrame = 0, numFrames = -1, startChan = 0, magnitude, phase, resynthesis, inverse = 0, windowSize = 1024, hopSize = -1, fftSize = -1, padding = 1,freeWhenDone = true, action|
|
||||||
|
|
||||||
// source = source.asUGenInput;
|
// source = source.asUGenInput;
|
||||||
source = source ? -1;
|
source = source ? -1;
|
||||||
magnitudeBuffer = magnitudeBuffer ? -1;
|
magnitude = magnitude ? -1;
|
||||||
phaseBuffer = phaseBuffer ? -1;
|
phase = phase ? -1;
|
||||||
resynthesisBuffer = resynthesisBuffer ? - 1;
|
resynthesis = resynthesis ? - 1;
|
||||||
|
|
||||||
^this.new(
|
^this.new(
|
||||||
server, nil, [magnitudeBuffer,phaseBuffer,resynthesisBuffer].select{|b| b != -1}
|
server, nil, [magnitude,phase,resynthesis].select{|b| b != -1}
|
||||||
).processList(
|
).processList(
|
||||||
[source, startFrame, numFrames, startChan, magnitudeBuffer, phaseBuffer, resynthesisBuffer, inverse, windowSize, hopSize, fftSize,1], freeWhenDone, action
|
[source, startFrame, numFrames, startChan, magnitude, phase, resynthesis, inverse, padding, windowSize, hopSize, fftSize, 1], freeWhenDone, action
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,62 @@
|
|||||||
|
TITLE:: FluidBufSelect
|
||||||
|
summary:: Cherry pick values from a buffer
|
||||||
|
categories:: FluidCorpusManipulation
|
||||||
|
related:: Classes/FluidBufSelectEvery
|
||||||
|
|
||||||
|
DESCRIPTION::
|
||||||
|
Pick sets of values from a buffer, described in terms of a list of frame indices and channel numbers.
|
||||||
|
|
||||||
|
CLASSMETHODS::
|
||||||
|
|
||||||
|
private::new1
|
||||||
|
|
||||||
|
METHOD:: process, processBlocking
|
||||||
|
Run the process on the given sever, and perfrom code::action:: when done
|
||||||
|
|
||||||
|
ARGUMENT:: server
|
||||||
|
The link::Classes/Server:: on which to run
|
||||||
|
|
||||||
|
ARGUMENT:: source
|
||||||
|
The link::Classes/Buffer:: to select values from
|
||||||
|
|
||||||
|
ARGUMENT:: destination
|
||||||
|
The link::Classes/Buffer:: to write the selected data to
|
||||||
|
|
||||||
|
ARGUMENT:: indices
|
||||||
|
A 0-based list of frame indices to recover. Default is [-1], meaning all frames
|
||||||
|
|
||||||
|
ARGUMENT:: channels
|
||||||
|
A 0-based list of channel numbers to recover. Default is [-1], meaning all frames
|
||||||
|
|
||||||
|
ARGUMENT:: freeWhenDone
|
||||||
|
Free the server instance when processing complete. Default true
|
||||||
|
|
||||||
|
ARGUMENT:: action
|
||||||
|
Runs when processing is complete
|
||||||
|
|
||||||
|
EXAMPLES::
|
||||||
|
code::
|
||||||
|
//send a known collection where the value of each frame in each channel is encoded
|
||||||
|
//chan
|
||||||
|
b = Buffer.sendCollection(s,30.collect{|x| x.mod(6) + (x.div(6) * 0.1)},6)
|
||||||
|
//check the ranges (thus showing a plotter error...)
|
||||||
|
b.plot(separately: true).plotMode_(\points)
|
||||||
|
//you can also check the collection itself if in doubt
|
||||||
|
b.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//let's make a destination buffer
|
||||||
|
c = Buffer(s);
|
||||||
|
|
||||||
|
//using default values, we copy everything:
|
||||||
|
FluidBufSelect.process(s,b,c,action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//more powerful copying, resizing the destination accordingly
|
||||||
|
FluidBufSelect.process(s,b,c, indices: [1,3], channels: [2,4], action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//observe the order can be anything, and -1 (default) passes everything in that dimension
|
||||||
|
FluidBufSelect.process(s,b,c, indices: [ -1 ] , channels: [3, 1, 4], action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
::
|
||||||
|
|
||||||
@ -0,0 +1,77 @@
|
|||||||
|
TITLE:: FluidBufSelectEvery
|
||||||
|
summary:: Extract every N samples / channels from a buffer
|
||||||
|
categories:: FluidCorpusManipulation
|
||||||
|
related:: Classes/FluidBufSelect
|
||||||
|
|
||||||
|
DESCRIPTION::
|
||||||
|
Pick every N frames and / or channels from a buffer, described in terms of independent hop sizes for frames and channels
|
||||||
|
|
||||||
|
CLASSMETHODS::
|
||||||
|
|
||||||
|
private::new1
|
||||||
|
|
||||||
|
METHOD:: process, processBlocking
|
||||||
|
Run the process on the given sever, and perfrom code::action:: when done
|
||||||
|
|
||||||
|
ARGUMENT:: server
|
||||||
|
The link::Classes/Server:: on which to run
|
||||||
|
|
||||||
|
ARGUMENT:: source
|
||||||
|
The link::Classes/Buffer:: to select values from
|
||||||
|
|
||||||
|
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 link::Classes/Buffer:: to write the selected data to
|
||||||
|
|
||||||
|
ARGUMENT:: frameHop
|
||||||
|
Take every `framehop` frames. Default = 1 = all frames (where 2 would be every other frame, etc.)
|
||||||
|
|
||||||
|
ARGUMENT:: channelHop
|
||||||
|
Take every `channelhop` channels. Default = 1 = all channels (where 2 would be every other channel, etc.)
|
||||||
|
|
||||||
|
ARGUMENT:: freeWhenDone
|
||||||
|
Free the server instance when processing complete. Default true
|
||||||
|
|
||||||
|
ARGUMENT:: action
|
||||||
|
Runs when processing is complete
|
||||||
|
|
||||||
|
EXAMPLES::
|
||||||
|
|
||||||
|
code::
|
||||||
|
EXAMPLES::
|
||||||
|
Didactic
|
||||||
|
code::
|
||||||
|
//send a known collection where the value of each frame in each channel is encoded
|
||||||
|
//chan
|
||||||
|
b = Buffer.sendCollection(s,30.collect{|x| x.mod(6) + (x.div(6) * 0.1)},6)
|
||||||
|
//check the ranges (thus showing a plotter error...)
|
||||||
|
b.plot(separately: true).plotMode_(\points)
|
||||||
|
//you can also check the collection itself if in doubt
|
||||||
|
b.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//let's make a destination buffer
|
||||||
|
c = Buffer(s);
|
||||||
|
|
||||||
|
//using default values, we copy everything:
|
||||||
|
FluidBufSelectEvery.process(s,b, destination: c, action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//more powerful copying, resizing the destination accordingly
|
||||||
|
FluidBufSelectEvery.process(s,b, destination: c, frameHop: 2, channelHop: 3, action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
|
||||||
|
//source buffer boundaries still apply before the hopping selection
|
||||||
|
FluidBufSelectEvery.process(s,b, startFrame: 1, numFrames: 3, startChan: 2, numChans: 3, destination: c, frameHop: 1, channelHop: 2, action: {c.query});
|
||||||
|
c.getToFloatArray(action: {|x|x.round(0.1).postln;});
|
||||||
|
::::
|
||||||
Loading…
Reference in New Issue