post new sync help file condensing

nix
Pierre Alexandre Tremblay 7 years ago
parent 35281d6604
commit c83213b1de

@ -71,29 +71,29 @@ d = Buffer.new(s);
)
// with basic params (basic summing of each full buffer in all dimensions)
FluidBufCompose.process(s, source: b.bufnum, destination: d.bufnum);
FluidBufCompose.process(s, source: c.bufnum, destination: d.bufnum, destGain: 1.0);
FluidBufCompose.process(s, source: b, destination: d);
FluidBufCompose.process(s, source: c, destination: d, destGain: 1.0);
d.query;
d.play;
//constructing a mono buffer, with a quiet punch from the synth, with a choked piano resonance from the left channel
d.free; d = Buffer.new(s);
FluidBufCompose.process(s, source: b.bufnum, numFrames: 9000, gain: 0.5, destination: d.bufnum);
FluidBufCompose.process(s, source: c.bufnum, startFrame:30000, numFrames:44100, numChans:1, gain:0.9, destination: d.bufnum, destGain: 1.0);
FluidBufCompose.process(s, source: b, numFrames: 9000, gain: 0.5, destination: d);
FluidBufCompose.process(s, source: c, startFrame:30000, numFrames:44100, numChans:1, gain:0.9, destination: d, destGain: 1.0);
d.query;
d.play;
//constructing a stereo buffer, with the end of the mono synth in both channels, with a piano resonance in swapped stereo
d.free; d = Buffer.new(s);
FluidBufCompose.process(s, source: b.bufnum, startFrame: 441000, numChans: 2, gain: 0.6, destination: d.bufnum);
FluidBufCompose.process(s, source: c.bufnum, numFrames: 78000, startChan: 1, numChans: 2, gain: 0.5, destStartFrame: 22050, destination: d.bufnum, destGain: 1.0);
FluidBufCompose.process(s, source: b, startFrame: 441000, numChans: 2, gain: 0.6, destination: d);
FluidBufCompose.process(s, source: c, numFrames: 78000, startChan: 1, numChans: 2, gain: 0.5, destStartFrame: 22050, destination: d, destGain: 1.0);
d.query;
d.play;
//constructing a one second buffer: the first second of each buffer, the mono synth on the right, the piano on the left
d.free; d = Buffer.new(s);
FluidBufCompose.process(s, source: b.bufnum, numFrames: 44100, numChans: 1, destStartChan: 1, destination: d.bufnum);
FluidBufCompose.process(s, source: c.bufnum, numFrames:44100, numChans:1, destination: d.bufnum, destGain: 1.0);
FluidBufCompose.process(s, source: b, numFrames: 44100, numChans: 1, destStartChan: 1, destination: d);
FluidBufCompose.process(s, source: c, numFrames:44100, numChans:1, destination: d, destGain: 1.0);
d.query;
d.play;
::
@ -112,16 +112,15 @@ f = Buffer.new(s);
// encode the mid (in c) and the side (in d)
(
FluidBufCompose.process(s,b.bufnum, numChans: 1, gain: -3.0.dbamp, destination: c.bufnum);
FluidBufCompose.process(s,b.bufnum, numChans: 1, gain: -3.0.dbamp, destination: d.bufnum);
FluidBufCompose.process(s,b.bufnum, numChans: 1, gain: -3.0.dbamp, startChan: 1, destination: c.bufnum, destGain: 1.0);
FluidBufCompose.process(s,b.bufnum, numChans: 1, gain: -3.0.dbamp * -1.0, startChan: 1, destination: d.bufnum, destGain: 1.0);
FluidBufCompose.process(s,b, numChans: 1, gain: -3.0.dbamp, destination: c);
FluidBufCompose.process(s,b, numChans: 1, gain: -3.0.dbamp, destination: d);
FluidBufCompose.process(s,b, numChans: 1, gain: -3.0.dbamp, startChan: 1, destination: c, destGain: 1.0);
FluidBufCompose.process(s,b, numChans: 1, gain: -3.0.dbamp * -1.0, startChan: 1, destination: d, destGain: 1.0);
)
// (optional) compare auraly the stereo with the MS
c.query;d.query;
b.play;
{PlayBuf.ar(1,[c.bufnum,d.bufnum])}.play;
{PlayBuf.ar(1,[c,d])}.play;
// The geeky bit: copy the side (buffer d) on itself with specific amplitudes and delays, in effect applying a FIR filter through expensive convolution
@ -131,7 +130,7 @@ b.play;
e.free; e = Buffer.new(s);
(
[1.0, -1.0].do({ arg x,y;
FluidBufCompose.process(s, d.bufnum, gain: x, destStartFrame: y, destination: e.bufnum, destGain: 1.0);
FluidBufCompose.process(s, d, gain: x, destStartFrame: y, destination: e, destGain: 1.0);
});
)
@ -139,7 +138,7 @@ e.free; e = Buffer.new(s);
e.free; e = Buffer.new(s);
(
[0.8, -0.32, -0.24, -0.16, -0.08].do({ arg x,y;
FluidBufCompose.process(s, d.bufnum, gain: x, destStartFrame: y, destination: e.bufnum, destGain: 1.0);
FluidBufCompose.process(s, d, gain: x, destStartFrame: y, destination: e, destGain: 1.0);
});
)
@ -147,24 +146,22 @@ e.free; e = Buffer.new(s);
e.free; e = Buffer.new(s);
(
[0.982494, -0.066859, -0.064358, -0.061897, -0.059477, -0.057098, -0.054761, -0.052466, -0.050215, -0.048007, -0.045843, -0.043724, -0.041649, -0.03962, -0.037636, -0.035697, -0.033805, -0.031959, -0.030159, -0.028406, -0.026699, -0.025038, -0.023425, -0.021857, -0.020337].do({ arg x,y;
FluidBufCompose.process(s, d.bufnum, gain: x, destStartFrame: y, destination: e.bufnum, destGain: 1.0);
FluidBufCompose.process(s, d, gain: x, destStartFrame: y, destination: e, destGain: 1.0);
});
)
// play the high-passed side buffer
e.query;
e.play;
// if you want to try the other filters, do not forget to clear the destination buffer since it will add programmatically onto itself and would not create the expected frequency response
// decode the MS back to stereo
(
FluidBufCompose.process(s,c.bufnum, numChans: 2, gain: -3.0.dbamp, destination: f.bufnum);
FluidBufCompose.process(s,e.bufnum, gain: -3.0.dbamp, destination: f.bufnum, destGain: 1.0);
FluidBufCompose.process(s,e.bufnum, gain: -3.0.dbamp * -1.0, destination: f.bufnum, destStartChan: 1, destGain: 1.0);
FluidBufCompose.process(s,c, numChans: 2, gain: -3.0.dbamp, destination: f);
FluidBufCompose.process(s,e, gain: -3.0.dbamp, destination: f, destGain: 1.0);
FluidBufCompose.process(s,e, gain: -3.0.dbamp * -1.0, destination: f, destStartChan: 1, destGain: 1.0);
)
// query and play
f.query;
// play the MS processed version
f.play;
// compare with the original

@ -129,8 +129,7 @@ code::
(
Routine{
t = Main.elapsedTime;
FluidBufHPSS.process(s, b.bufnum, harmonic: c.bufnum, percussive: d.bufnum);
s.sync;
FluidBufHPSS.process(s, b, harmonic: c, percussive: d);
(Main.elapsedTime - t).postln;
}.play
)
@ -141,14 +140,13 @@ c.play;
d.play;
//nullsumming tests
{(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
{(PlayBuf.ar(1,c))+(PlayBuf.ar(1,d))+(-1*PlayBuf.ar(1,b,doneAction:2))}.play
//more daring parameters, in mode 2
(
Routine{
t = Main.elapsedTime;
FluidBufHPSS.process(s, b, harmonic: c, percussive: d, residual:e, harmFilterSize:31, maskingMode:2, harmThreshFreq1: 0.005, harmThreshAmp1: 7.5, harmThreshFreq2: 0.168, harmThreshAmp2: 7.5, percThreshFreq1: 0.004, percThreshAmp1: 26.5, percThreshFreq2: 0.152, percThreshAmp2: 26.5,winSize:4096,hopSize:512);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
@ -161,7 +159,7 @@ d.play;
e.play;
//still nullsumming
{PlayBuf.ar(1,c.bufnum) + PlayBuf.ar(1,d.bufnum) + PlayBuf.ar(1,e.bufnum) - PlayBuf.ar(1,b.bufnum,doneAction:2)}.play;
{PlayBuf.ar(1,c) + PlayBuf.ar(1,d) + PlayBuf.ar(1,e) - PlayBuf.ar(1,b,doneAction:2)}.play;
::
STRONG::A stereo buffer example.::
@ -178,15 +176,13 @@ FluidBufCompose.process(s, c, numFrames:b.numFrames, startFrame:555000,destStart
b.play
// create 2 new buffers as destinations
d = Buffer.new(s);
e = Buffer.new(s);
d = Buffer.new(s); e = Buffer.new(s);
//run the process on them
(
Routine{
t = Main.elapsedTime;
FluidBufHPSS.process(s, b, harmonic: d, percussive:e);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)

@ -128,8 +128,8 @@ Routine {
b.sine2([500],[1], false, false);
c.sine2([5000],[1],false, false);
s.sync;
FluidBufCompose.process(s,b.bufnum, destination:d.bufnum);
FluidBufCompose.process(s,c.bufnum, destStartFrame:44100, destination:d.bufnum, destGain:1);
FluidBufCompose.process(s,b, destination:d);
FluidBufCompose.process(s,c, destStartFrame:44100, destination:d, destGain:1);
s.sync;
d.query;
}.play;
@ -142,8 +142,7 @@ d.play //////(beware !!!! loud!!!)
(
// separate them in 2 ranks
Routine {
FluidBufNMF.process(s, d.bufnum, destination:e.bufnum, bases: f.bufnum, activations:g.bufnum, rank:2);
s.sync;
FluidBufNMF.process(s, d, destination:e, bases: f, activations:g, rank:2);
e.query;
f.query;
g.query;
@ -174,29 +173,28 @@ y = Buffer.new(s);
~fft_size = 1024;
~frame_size = 512;
~hop_size = 256;
~which_rank = 1;
~which_rank = 3;
)
// matrix factorisation, requesting everything
// matrix factorisation, requesting everything - wait for the computation time to appear.
(
Routine{
t = Main.elapsedTime;
FluidBufNMF.process(s,b, 0,-1,0,-1,c,x,0,y,0,5,100,~frame_size,~hop_size,~fft_size);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
//look at the resynthesised ranks, the bases and the activations
c.plot;x.plot; y.plot;
c.plot; x.plot; y.plot;
//null test of the sum of sources
{(PlayBuf.ar(5,c.bufnum,doneAction:2).sum)+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
{(PlayBuf.ar(5,c,doneAction:2).sum)+(-1*PlayBuf.ar(1,b,doneAction:2))}.play
// play the ranks spread in the stereo field
{Splay.ar(PlayBuf.ar(5,c.bufnum,doneAction:2))}.play
{Splay.ar(PlayBuf.ar(5,c,doneAction:2))}.play
//play a single source
{PlayBuf.ar(5,c.bufnum,doneAction:2)[~which_rank].dup}.play
{PlayBuf.ar(5,c,doneAction:2)[~which_rank].dup}.play
//play noise using one of the bases as filter.
(
@ -205,7 +203,7 @@ c.plot;x.plot; y.plot;
chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar());
chain = chain.pvcollect(~fft_size, {|mag, phase, index|
[mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]];
[mag * BufRd.kr(5,x,DC.kr(index),0,1)[~which_rank]];
});
IFFT(chain);
@ -213,16 +211,16 @@ c.plot;x.plot; y.plot;
)
//play noise using one of the activations as envelope.
{WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank])*0.5}.play
{WhiteNoise.ar(BufRd.kr(5,y,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank])*0.5}.play
//play noise through both matching activation and filter
(
{
var chain;
chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar(BufRd.kr(5,y.bufnum,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank]*12),0.5,1);
chain = FFT(LocalBuf(~fft_size), WhiteNoise.ar(BufRd.kr(5,y,Phasor.ar(1,1/~hop_size,0,(b.numFrames / ~hop_size + 1)),0,1)[~which_rank]*12),0.5,1);
chain = chain.pvcollect(~fft_size, {|mag, phase, index|
[mag * BufRd.kr(5,x.bufnum,DC.kr(index),0,1)[~which_rank]];
[mag * BufRd.kr(5,x,DC.kr(index),0,1)[~which_rank]];
});
[0,IFFT(chain)];
@ -246,28 +244,23 @@ y = Buffer.new(s);
// train only 2 seconds
(
Routine {
FluidBufNMF.process(s,b.bufnum,0,88200,0,1, c.bufnum, x.bufnum, rank:10);
s.sync;
FluidBufNMF.process(s,b,0,88200,0,1, c, x, rank:10);
c.query;
}.play;
)
// find the rank that has the picking sound by changing which channel to listen to
(
~element = 1;
{PlayBuf.ar(10,c.bufnum)[~element]}.play
~element = 4;
{PlayBuf.ar(10,c)[~element]}.play
)
// copy all the other ranks on itself and the picking basis as the sole component of the 1st channel
(
Routine{
z = (0..9);
FluidBufCompose.process(s, x.bufnum, startChan: z.removeAt(~element), numChans: 1, destination: e.bufnum);
s.sync;
e.query;
s.sync;
z.do({|chan| FluidBufCompose.process(s, x.bufnum, startChan:chan, numChans: 1, destStartChan: 1, destination: e.bufnum, destGain:1)});
s.sync;
FluidBufCompose.process(s, x, startChan: z.removeAt(~element), numChans: 1, destination: e);
z.do({|chan| FluidBufCompose.process(s, x, startChan:chan, numChans: 1, destStartChan: 1, destination: e, destGain:1)});
e.query;
}.play;
)
@ -276,7 +269,6 @@ Routine{
(
Routine{
FluidBufNMF.process(s, b, destination: c, bases: e, basesMode: 2, activations: y, rank:2);
s.sync;
c.query;
}.play;
)
@ -285,7 +277,7 @@ Routine{
c.play
// it even null-sums
{(PlayBuf.ar(2,c.bufnum,doneAction:2).sum)-(PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
{(PlayBuf.ar(2,c,doneAction:2).sum)-(PlayBuf.ar(1,b,doneAction:2))}.play
::
STRONG::Updating Bases: The process can update bases provided as seed.::
@ -307,8 +299,8 @@ Routine {
b.sine2([500],[1], false, false);
c.sine2([5000],[1],false, false);
s.sync;
FluidBufCompose.process(s,b.bufnum, destination:d.bufnum);
FluidBufCompose.process(s,c.bufnum, destStartFrame:44100, destination:d.bufnum, destGain:1);
FluidBufCompose.process(s,b, destination:d);
FluidBufCompose.process(s,c, destStartFrame:44100, destination:d, destGain:1);
s.sync;
d.query;
}.play;
@ -335,7 +327,6 @@ e.query
// use the seeding basis, without updating
Routine {
FluidBufNMF.process(s, d, destination:f, bases: e, basesMode: 2, activations:g, rank:3);
s.sync;
e.query;
f.query;
g.query;
@ -355,7 +346,6 @@ g.plot;
// use the seeding bases, with updating this time
Routine {
FluidBufNMF.process(s, d, destination:f, bases: e, basesMode: 1, activations:g, rank:3);
s.sync;
e.query;
f.query;
g.query;

@ -74,8 +74,7 @@ c = Buffer.new(s);
// with basic params
Routine{
t = Main.elapsedTime;
FluidBufNoveltySlice.process(s,b.bufnum, indices: c.bufnum, threshold:0.6);
s.sync;
FluidBufNoveltySlice.process(s,b, indices: c, threshold:0.6);
(Main.elapsedTime - t).postln;
}.play
)
@ -86,14 +85,14 @@ c.query;
//loops over a splice with the MouseX
(
{
BufRd.ar(1, b.bufnum,
BufRd.ar(1, b,
Phasor.ar(0,1,
BufRd.kr(1, c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1),
BufRd.kr(1, c.bufnum,
MouseX.kr(1, BufFrames.kr(c.bufnum)), 0, 1),
BufRd.kr(1,c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1)), 0, 1);
BufRd.kr(1, c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1),
BufRd.kr(1, c,
MouseX.kr(1, BufFrames.kr(c)), 0, 1),
BufRd.kr(1,c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1)), 0, 1);
}.play;
)
::
@ -108,7 +107,7 @@ c = Buffer.new(s);
)
// process with a given filterSize
FluidBufNoveltySlice.process(s,b.bufnum, indices: c.bufnum, kernSize:31, threshold:0.3, filterSize:0)
FluidBufNoveltySlice.process(s,b, indices: c, kernSize:31, threshold:0.3, filterSize:0)
//check the number of slices: it is the number of frames in the transBuf minus the boundary index.
c.query;
@ -116,11 +115,11 @@ c.query;
//play slice number 2
(
{
BufRd.ar(1, b.bufnum,
BufRd.ar(1, b,
Line.ar(
BufRd.kr(1, c.bufnum, DC.kr(2), 0, 1),
BufRd.kr(1, c.bufnum, DC.kr(3), 0, 1),
(BufRd.kr(1, c.bufnum, DC.kr(3)) - BufRd.kr(1, c.bufnum, DC.kr(2), 0, 1) + 1) / s.sampleRate),
BufRd.kr(1, c, DC.kr(2), 0, 1),
BufRd.kr(1, c, DC.kr(3), 0, 1),
(BufRd.kr(1, c, DC.kr(3)) - BufRd.kr(1, c, DC.kr(2), 0, 1) + 1) / s.sampleRate),
0,1);
}.play;
)
@ -152,8 +151,7 @@ c = Buffer.new(s);
// with basic params
Routine{
t = Main.elapsedTime;
FluidBufNoveltySlice.process(s,b.bufnum, indices: c.bufnum, threshold:0.6);
s.sync;
FluidBufNoveltySlice.process(s,b, indices: c, threshold:0.6);
(Main.elapsedTime - t).postln;
}.play
)

@ -89,8 +89,7 @@ c = Buffer.new(s);
// with basic params
Routine{
t = Main.elapsedTime;
FluidBufOnsetSlice.process(s,b.bufnum, indices: c.bufnum, threshold:0.5);
s.sync;
FluidBufOnsetSlice.process(s,b, indices: c, threshold:0.5);
(Main.elapsedTime - t).postln;
}.play
)
@ -101,14 +100,14 @@ c.query;
//loops over a splice with the MouseX
(
{
BufRd.ar(1, b.bufnum,
BufRd.ar(1, b,
Phasor.ar(0,1,
BufRd.kr(1, c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1),
BufRd.kr(1, c.bufnum,
MouseX.kr(1, BufFrames.kr(c.bufnum)), 0, 1),
BufRd.kr(1,c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1)), 0, 1);
BufRd.kr(1, c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1),
BufRd.kr(1, c,
MouseX.kr(1, BufFrames.kr(c)), 0, 1),
BufRd.kr(1,c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1)), 0, 1);
}.play;
)
::
@ -132,7 +131,6 @@ c = Buffer.new(s);
Routine{
t = Main.elapsedTime;
FluidBufOnsetSlice.process(s,b, indices: c, threshold:0.1);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)

@ -86,20 +86,17 @@ d = Buffer.new(s);
(
Routine{
t = Main.elapsedTime;
FluidBufSines.process(s, b.bufnum, sines: c.bufnum, residual:d.bufnum);
s.sync;
FluidBufSines.process(s, b, sines: c, residual:d);
(Main.elapsedTime - t).postln;
}.play
)
// listen to each component
c.query;
c.play;
d.query;
d.play;
//nullsumming tests
{(PlayBuf.ar(1, c.bufnum)) + (PlayBuf.ar(1,d.bufnum)) - (PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
{(PlayBuf.ar(1, c)) + (PlayBuf.ar(1,d)) - (PlayBuf.ar(1,b,doneAction:2))}.play
::
STRONG::A stereo buffer example.::
@ -116,15 +113,13 @@ FluidBufCompose.process(s, c, numFrames:b.numFrames, startFrame:555000,destStart
b.play
// create 2 new buffers as destinations
d = Buffer.new(s);
e = Buffer.new(s);
d = Buffer.new(s); e = Buffer.new(s);
//run the process on them
(
Routine{
t = Main.elapsedTime;
FluidBufSines.process(s, b, sines: d, residual:e, threshold:0.3);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)

@ -79,12 +79,11 @@ b = Buffer.read(s,File.realpath(FluidBufTransientSlice.class.filenameSymbol).dir
c = Buffer.new(s);
)
// with basic parameters
// with basic parameters (wait for the computation time to appear)
(
Routine{
t = Main.elapsedTime;
FluidBufTransientSlice.process(s,b, indices:c);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
@ -95,26 +94,27 @@ c.query;
//loops over a splice
(
{
BufRd.ar(1, b.bufnum,
BufRd.ar(1, b,
Phasor.ar(0,1,
BufRd.kr(1, c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1),
BufRd.kr(1, c.bufnum,
MouseX.kr(1, BufFrames.kr(c.bufnum)), 0, 1),
BufRd.kr(1,c.bufnum,
MouseX.kr(0, BufFrames.kr(c.bufnum) - 1), 0, 1)), 0, 1);
BufRd.kr(1, c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1),
BufRd.kr(1, c,
MouseX.kr(1, BufFrames.kr(c)), 0, 1),
BufRd.kr(1,c,
MouseX.kr(0, BufFrames.kr(c) - 1), 0, 1)), 0, 1);
}.play;
)
// with everything changed to make it much better, at the cost of computation time (only 10 seconds are processed here)
// with everything changed to make it much better, at the cost of computation time (only 10 seconds are processed here, again wait for the (longer) computation time to appear)
(
Routine{
t = Main.elapsedTime;
FluidBufTransientSlice.process(s,b, 0, 220500, 0, 1, c, 200, 2048, 1024, 1, 3, 1, 15, 30, 4410);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)
// play with the same player above to hear the segmentation difference
::
STRONG::A stereo buffer example.::
@ -125,6 +125,7 @@ b = Buffer.alloc(s,88200,2);
// add some stereo clicks and listen to them
((0..3)*22050+11025).do({|item,index| b.set(item+(index%2), 1.0)})
b.play
// create a new buffer as destinations
@ -136,7 +137,6 @@ c = Buffer.new(s);
Routine{
t = Main.elapsedTime;
FluidBufTransientSlice.process(s,b, indices: c, threshFwd: 1.2);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)

@ -88,31 +88,31 @@ d = Buffer.new(s);
(
Routine{
t = Main.elapsedTime;
FluidBufTransients.process(s,b.bufnum, transients:c.bufnum, residual:d.bufnum);
s.sync;
FluidBufTransients.process(s,b, transients:c, residual:d);
(Main.elapsedTime - t).postln;
}.play
);
// wait for the duration to appear in the post window as a cue that the computation is finished
c.query;
c.play;
d.query;
d.play;
//nullsumming tests
{(PlayBuf.ar(1,c.bufnum))+(PlayBuf.ar(1,d.bufnum))+(-1*PlayBuf.ar(1,b.bufnum,doneAction:2))}.play
{(PlayBuf.ar(1,c))+(PlayBuf.ar(1,d))+(-1*PlayBuf.ar(1,b,doneAction:2))}.play
// with everything changed to make it much better, at the cost of computation time (only 5 seconds are processed here)
(
Routine{
t = Main.elapsedTime;
FluidBufTransients.process(s,b.bufnum, 0, 220500, 0, 1, c.bufnum, d.bufnum, 200, 2048, 1024, 1, 3, 1, 15, 30);
s.sync;
FluidBufTransients.process(s,b, 0, 220500, 0, 1, c, d, 200, 2048, 1024, 1, 3, 1, 15, 30);
(Main.elapsedTime - t).postln;
}.play
)
// wait for the duration to appear in the post window as a cue that the computation is finished
c.play;
d.play;
::
STRONG::A stereo buffer example.::
@ -129,15 +129,13 @@ FluidBufCompose.process(s, c, numFrames:b.numFrames, startFrame:555000, destStar
b.play
// create 2 new buffers as destinations
d = Buffer.new(s);
e = Buffer.new(s);
d = Buffer.new(s); e = Buffer.new(s);
//run the process on them
(
Routine{
t = Main.elapsedTime;
FluidBufTransients.process(s, b, transients: d, residual:e, threshFwd:1.2, debounce:40);
s.sync;
(Main.elapsedTime - t).postln;
}.play
)

@ -102,19 +102,19 @@ CODE::
b = Buffer.read(s,File.realpath(FluidHPSS.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
// run with basic parameters (left is harmonic, right is percussive)
{FluidHPSS.ar(PlayBuf.ar(1,b.bufnum,loop:1))}.play
{FluidHPSS.ar(PlayBuf.ar(1,b,loop:1))}.play
// run in mode 1
{FluidHPSS.ar(PlayBuf.ar(1,b.bufnum,loop:1),17,51,1,0.05,40,0.1,-40)}.play
{FluidHPSS.ar(PlayBuf.ar(1,b,loop:1),17,51,1,0.05,40,0.1,-40)}.play
// run in mode 2, listening to:
//the harmonic stream
{FluidHPSS.ar(PlayBuf.ar(1,b.bufnum,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[0].dup}.play
{FluidHPSS.ar(PlayBuf.ar(1,b,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[0].dup}.play
// the percussive stream
{FluidHPSS.ar(PlayBuf.ar(1,b.bufnum,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[1].dup}.play
{FluidHPSS.ar(PlayBuf.ar(1,b,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[1].dup}.play
// the residual stream
{FluidHPSS.ar(PlayBuf.ar(1,b.bufnum,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[2].dup}.play
{FluidHPSS.ar(PlayBuf.ar(1,b,loop:1),15,31,2,0.05,40,0.1,-40, 0.1, -10, 0.2, 10)[2].dup}.play
// null test (the process add a latency of ((harmFilterSize - 1) * hopSize) + winSize) samples
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidHPSS.ar(sig, 17, 31).sum - DelayN.ar(sig, 1, ((((17 - 1) * 512) + 1024) / s.sampleRate))]}.play
{var sig = PlayBuf.ar(1,b,loop:1); [FluidHPSS.ar(sig, 17, 31).sum - DelayN.ar(sig, 1, ((((17 - 1) * 512) + 1024) / s.sampleRate))]}.play
::

@ -52,7 +52,7 @@ RETURNS::
EXAMPLES::
STRONG::A didactic example::
CODE::
CODE::
(
// create buffers
b= Buffer.alloc(s,44100);
@ -67,8 +67,8 @@ Routine {
b.sine2([500],[1], false, false);
c.sine2([5000],[1],false, false);
s.sync;
FluidBufCompose.process(s,b.bufnum, destination:d.bufnum);
FluidBufCompose.process(s,c.bufnum, destStartFrame:44100, destination:d.bufnum, destGain:1);
FluidBufCompose.process(s,b, destination:d);
FluidBufCompose.process(s,c, destStartFrame:44100, destination:d, destGain:1);
s.sync;
d.query;
}.play;
@ -81,39 +81,37 @@ d.play //////(beware !!!! loud!!!)
(
// separate them in 2 ranks
Routine {
FluidBufNMF.process(s, d.bufnum, bases: e.bufnum, rank:2);
FluidBufNMF.process(s, d, bases: e, rank:2);
s.sync;
e.query;
}.play
)
// check for 2 spikes in the spectra
e.query
e.plot
// test the activations values with test one, another, or both ideal material
{FluidNMFMatch.kr(SinOsc.ar(500),e.bufnum,2)}.plot(1)
{FluidNMFMatch.kr(SinOsc.ar(500),e,2)}.plot(1)
{FluidNMFMatch.kr(SinOsc.ar(5000),e.bufnum,2)}.plot(1)
{FluidNMFMatch.kr(SinOsc.ar(5000),e,2)}.plot(1)
{FluidNMFMatch.kr(SinOsc.ar([500,5000]).sum,e.bufnum,2)}.plot(1)
{FluidNMFMatch.kr(SinOsc.ar([500,5000]).sum,e,2)}.plot(1)
::
STRONG::A pick compressor::
CODE::
CODE::
//set some buffers
(
b = Buffer.read(s,File.realpath(FluidNMFMatch.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-AcousticStrums-M.wav");
c = Buffer.new(s);
x = Buffer.new(s);
e = Buffer.alloc(s,1,1);
e = Buffer.new(s);
)
// train only 2 seconds
(
Routine {
FluidBufNMF.process(s,b.bufnum,0,88200,0,1, c.bufnum, x.bufnum, rank:10,fftSize:2048);
s.sync;
FluidBufNMF.process(s,b,0,88200,0,1, c, x, rank:10,fftSize:2048);
c.query;
}.play;
)
@ -121,20 +119,16 @@ Routine {
// wait for the query to print
// then find the rank that has the picking sound by changing which channel to listen to
(
~element = 3;
{PlayBuf.ar(10,c.bufnum)[~element]}.play
~element = 6;
{PlayBuf.ar(10,c)[~element]}.play;
)
// copy all the other ranks on itself and the picking basis as the sole component of the 1st channel
(
Routine{
z = (0..9);
FluidBufCompose.process(s, x.bufnum, startChan: z.removeAt(~element), numChans: 1, destination: e.bufnum);
s.sync;
e.query;
s.sync;
z.do({|chan| FluidBufCompose.process(s, x.bufnum, startChan:chan, numChans: 1, destStartChan: 1, destination: e.bufnum, destGain:1)});
s.sync;
FluidBufCompose.process(s, x, startChan: z.removeAt(~element), numChans: 1, destination: e);
z.do({|chan| FluidBufCompose.process(s, x, startChan:chan, numChans: 1, destStartChan: 1, destination: e, destGain:1)});
e.query;
}.play;
)
@ -142,7 +136,7 @@ Routine{
e.plot;
//using this trained basis we can see the envelop (activations) of each rank
{FluidNMFMatch.kr(PlayBuf.ar(1,b.bufnum),e.bufnum,2,fftSize:2048)}.plot(1);
{FluidNMFMatch.kr(PlayBuf.ar(1,b),e,2,fftSize:2048)}.plot(1);
// the left/top activations are before, the pick before the sustain.
//we can then use the activation value to sidechain a compression patch that is sent in a delay
@ -150,7 +144,7 @@ e.plot;
{
var source, todelay, delay1, delay2, delay3, feedback, mod1, mod2, mod3, mod4;
//read the source
source = PlayBuf.ar(1, b.bufnum);
source = PlayBuf.ar(1, b);
// generate modulators that are coprime in frequency
mod1 = SinOsc.ar(1, 0, 0.001);
@ -160,7 +154,7 @@ e.plot;
// compress the signal to send to the delays
todelay = DelayN.ar(source,0.1, 800/44100, //delaying it to compensate for FluidNMFMatch's latency
LagUD.ar(K2A.ar(FluidNMFMatch.kr(source,e.bufnum,2,fftSize:2048)[0]), //reading the channel of the activations on the pick basis
LagUD.ar(K2A.ar(FluidNMFMatch.kr(source,e,2,fftSize:2048)[0]), //reading the channel of the activations on the pick basis
80/44100, // lag uptime (compressor's attack)
1000/44100, // lag downtime (compressor's decay)
(1/(2.dbamp) // compressor's threshold inverted
@ -193,8 +187,7 @@ e = Buffer.new(s);
// train where all objects are present
(
Routine {
FluidBufNMF.process(s,b.bufnum,130000,150000,0,1, c.bufnum, x.bufnum, rank:10);
s.sync;
FluidBufNMF.process(s,b,130000,150000,0,1, c, x, rank:10);
c.query;
}.play;
)
@ -203,36 +196,34 @@ Routine {
// then find a rank for each item you want to find. You could also sum them. Try to find a rank with a good object-to-rest ratio
(
~dog =2;
{PlayBuf.ar(10,c.bufnum)[~dog]}.play
{PlayBuf.ar(10,c)[~dog]}.play
)
(
~bird = 5;
{PlayBuf.ar(10,c.bufnum)[~bird]}.play
~bird = 3;
{PlayBuf.ar(10,c)[~bird]}.play
)
// copy at least one other rank to a third rank, a sort of left-over channel
(
Routine{
FluidBufCompose.process(s, x.bufnum, startChan:~dog, numChans: 1, destination: e.bufnum);
FluidBufCompose.process(s, x.bufnum, startChan:~bird, numChans: 1, destStartChan: 1, destination: e.bufnum, destGain:1);
s.sync;
(0..9).removeAll([~dog,~bird]).do({|chan|FluidBufCompose.process(s,x.bufnum, startChan:chan, numChans: 1, destStartChan: 2, destination: e.bufnum, destGain:1)});
s.sync;
FluidBufCompose.process(s, x, startChan:~dog, numChans: 1, destination: e);
FluidBufCompose.process(s, x, startChan:~bird, numChans: 1, destStartChan: 1, destination: e, destGain:1);
(0..9).removeAll([~dog,~bird]).do({|chan|FluidBufCompose.process(s,x, startChan:chan, numChans: 1, destStartChan: 2, destination: e, destGain:1)});
e.query;
}.play;
)
e.plot;
//using this trained basis we can then see the activation...
//using this trained basis we can then see the activation... (wait for 5 seconds before it prints!)
(
{
var source, blips;
//read the source
source = PlayBuf.ar(2, b.bufnum);
blips = FluidNMFMatch.kr(source.sum,e.bufnum,3);
}.plot(10);
source = PlayBuf.ar(2, b);
blips = FluidNMFMatch.kr(source.sum,e,3);
}.plot(5);
)
// ...and use some threshold to 'find' objects...
@ -240,9 +231,9 @@ e.plot;
{
var source, blips;
//read the source
source = PlayBuf.ar(2, b.bufnum);
blips = Schmidt.kr(FluidNMFMatch.kr(source.sum,e.bufnum,3),0.5,[10,1,1000]);
}.plot(10);
source = PlayBuf.ar(2, b);
blips = Schmidt.kr(FluidNMFMatch.kr(source.sum,e,3),0.5,[10,1,1000]);
}.plot(5);
)
// ...and use these to sonify them
@ -250,8 +241,8 @@ e.plot;
{
var source, blips, dogs, birds;
//read the source
source = PlayBuf.ar(2, b.bufnum);
blips = Schmidt.kr(FluidNMFMatch.kr(source.sum,e.bufnum,3),0.5,[10,1,1000]);
source = PlayBuf.ar(2, b);
blips = Schmidt.kr(FluidNMFMatch.kr(source.sum,e,3),0.5,[10,1,1000]);
dogs = SinOsc.ar(100,0,Lag.kr(blips[0],0.05,0.15));
birds = SinOsc.ar(1000,0,Lag.kr(blips[1],0.05,0.05));
[dogs, birds] + source;
@ -272,8 +263,8 @@ c.query
(
{
var source, resynth;
source = PlayBuf.ar(2, b.bufnum,loop:1).sum;
resynth = SinOsc.ar((21..108).midicps, 0, FluidNMFMatch.kr(source,c.bufnum,88,10,4096).madd(0.002)).sum;
source = PlayBuf.ar(2, b,loop:1).sum;
resynth = SinOsc.ar((21..108).midicps, 0, FluidNMFMatch.kr(source,c,88,10,4096).madd(0.002)).sum;
[source, resynth]
}.play
)
@ -283,14 +274,14 @@ c.query
(
{
var source, resynth, chain, trig, acts;
source = PlayBuf.ar(2,b.bufnum,loop:1).sum;
source = PlayBuf.ar(2,b,loop:1).sum;
// built in attack detection, delayed until the stable part of the sound
chain = FFT(LocalBuf(256), source);
trig = TDelay.kr(Onsets.kr(chain, 0.5),0.1);
// samples and holds activation values that are scaled and capped, in effect thresholding them
acts = Latch.kr(FluidNMFMatch.kr(source,c.bufnum,88,10,4096).linlin(15,20,0,0.1),trig);
acts = Latch.kr(FluidNMFMatch.kr(source,c,88,10,4096).linlin(15,20,0,0.1),trig);
// resynths as in the previous example, with the values sent back to the language
resynth = SinOsc.ar((21..108).midicps, 0, acts).sum;

@ -66,16 +66,16 @@ code::
b = Buffer.read(s,File.realpath(FluidOnsetSlice.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Nicol-LoopE-M.wav");
// basic param (the process add a latency of winSize samples
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidOnsetSlice.ar(sig) * 0.5, DelayN.ar(sig, 1, 1024/ s.sampleRate)]}.play
{var sig = PlayBuf.ar(1,b,loop:1); [FluidOnsetSlice.ar(sig) * 0.5, DelayN.ar(sig, 1, 1024/ s.sampleRate)]}.play
// other parameters
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidOnsetSlice.ar(sig, 2, 0.06, 55, 7, 0, 128, 64) * 0.5, DelayN.ar(sig, 1, (128)/ s.sampleRate)]}.play
{var sig = PlayBuf.ar(1,b,loop:1); [FluidOnsetSlice.ar(sig, 2, 0.06, 55, 7, 0, 128, 64) * 0.5, DelayN.ar(sig, 1, (128)/ s.sampleRate)]}.play
// more musical trans-trigged autopan
(
{
var sig, trig, syncd, pan;
sig = PlayBuf.ar(1,b.bufnum,loop:1);
sig = PlayBuf.ar(1,b,loop:1);
trig = FluidOnsetSlice.ar(sig, 1, 1.8, 100, 8, 0, 128);
syncd = DelayN.ar(sig, 1, ( 128 / s.sampleRate));
pan = TRand.ar(-1,1,trig);

@ -59,12 +59,11 @@ CODE::
b = Buffer.read(s,File.realpath(FluidSines.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
// run with large parameters - left is sinusoidal model, right is residual
{FluidSines.ar(PlayBuf.ar(1,b.bufnum,loop:1),threshold: 0.2, minTrackLen: 2, winSize: 2048, fftSize: 8192)}.play
{FluidSines.ar(PlayBuf.ar(1,b,loop:1),threshold: 0.2, minTrackLen: 2, winSize: 2048, fftSize: 8192)}.play
// interactive parameters with a narrower bandwidth
{FluidSines.ar(PlayBuf.ar(1,b.bufnum,loop:1),30,MouseX.kr(), 5, winSize: 1000, hopSize: 200, fftSize: 4096)}.play
{FluidSines.ar(PlayBuf.ar(1,b,loop:1),30,MouseX.kr(), 5, winSize: 1000, hopSize: 200, fftSize: 4096)}.play
// null test (the process add a latency of (( hopSize * minTrackLen) + winSize) samples
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidSines.ar(sig).sum - DelayN.ar(sig, 1, ((( 512 * 15) + 1024)/ s.sampleRate))]}.play
::
{var sig = PlayBuf.ar(1,b,loop:1); [FluidSines.ar(sig).sum - DelayN.ar(sig, 1, ((( 512 * 15) + 1024)/ s.sampleRate))]}.play
::

@ -54,18 +54,18 @@ CODE::
b = Buffer.read(s,File.realpath(FluidTransientSlice.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
// basic param (the process add a latency of (blockSize + padSize - order) samples
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidTransientSlice.ar(sig) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate))]}.play
{var sig = PlayBuf.ar(1,b,loop:1); [FluidTransientSlice.ar(sig) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate))]}.play
// other parameters
{var sig = PlayBuf.ar(1,b.bufnum,loop:1); [FluidTransientSlice.ar(sig,order:80,minSlice:2205) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 80)/ s.sampleRate))]}.play
{var sig = PlayBuf.ar(1,b,loop:1); [FluidTransientSlice.ar(sig,order:80,minSlice:2205) * 0.5, DelayN.ar(sig, 1, ((256 + 128 - 80)/ s.sampleRate))]}.play
// more musical trans-trigged autopan
(
{
var sig, trig, syncd, pan;
sig = PlayBuf.ar(1,b.bufnum,loop:1);
sig = PlayBuf.ar(1,b,loop:1);
trig = FluidTransientSlice.ar(sig,order:10,minSlice:4410);
syncd = DelayN.ar(sig, 1, ((256 + 128 - 10)/ s.sampleRate));
syncd = DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate));
pan = TRand.ar(-1,1,trig);
Pan2.ar(syncd,pan);
}.play

@ -56,11 +56,11 @@ CODE::
b = Buffer.read(s,File.realpath(FluidTransients.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-AaS-SynthTwoVoices-M.wav");
// basic parameters
{FluidTransients.ar(PlayBuf.ar(1, b.bufnum, loop:1))}.play
{FluidTransients.ar(PlayBuf.ar(1, b, loop:1))}.play
// tweaked parameterss
{FluidTransients.ar(PlayBuf.ar(1, b.bufnum, loop:1), 80, threshFwd:MouseX.kr(0,5), threshBack:MouseY.kr(0,2))}.play
{FluidTransients.ar(PlayBuf.ar(1, b, loop:1), 80, threshFwd:MouseX.kr(0,5), threshBack:MouseY.kr(0,2))}.play
// null test (the process add a latency of (blockSize + padding - order) samples
{var sig = PlayBuf.ar(1, b.bufnum, loop:1); [FluidTransients.ar(sig).sum - DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate))]}.play
::
{var sig = PlayBuf.ar(1, b, loop:1); [FluidTransients.ar(sig).sum - DelayN.ar(sig, 1, ((256 + 128 - 20)/ s.sampleRate))]}.play
::

Loading…
Cancel
Save