@ -1,7 +1,7 @@
FluidAudioTransport : UGen {
init { |...theInputs|
theInputs.postln;
theInputs;
inputs = theInputs;
this.specialIndex = 1; //two audio inputs
// ^this.initOutputs(1,rate);
@ -182,7 +182,6 @@ b.play
// create a new buffer as destinations
c = Buffer.new(s);
OSCFunc.trace(false)
//run the process on them
(
// with basic params
@ -145,16 +145,16 @@ b.play
Routine{
var t = Main.elapsedTime;
var proc = FluidBufAmpSlice.process(s,b, indices: c, fastRampUp: 10,fastRampDown: 2205,slowRampUp: 4410,slowRampDown: 4410, onThreshold: 10,offThreshold: 5);
proc.wait;
c.query;
(Main.elapsedTime - t).postln;
}.play
)
// list the indicies of detected attacks - the two input channels have been summed.
c.getn(0,c.numFrames,{|item|(item * 2).postln;})
@ -92,7 +92,6 @@ FluidBufAudioTransport.process(s,b,source2:c,destination:d,interpolation:0.5,act
// listen to the source and the result
b.play
c.play
d.updateInfo
d.play
// more interesting sources: two cardboard bowing gestures
@ -72,8 +72,9 @@ d = Buffer.new(s);
// with basic params (basic summing of each full buffer in all dimensions)
FluidBufCompose.process(s, source: b, destination: d).wait;
FluidBufCompose.process(s, source: c, destination: d, destGain: 1.0).wait;
FluidBufCompose.process(s, source: b, destination: d);
FluidBufCompose.process(s, source: c, destination: d, destGain: 1.0);
s.sync;
d.query;
d.play;
}.play;
@ -83,7 +83,7 @@ b = Buffer.read(s,~randomsoundfile.path,action:{"Sound Loaded".postln});
~flatdata = Buffer.new;
//Pitch analysis, writes pitches as frequecnies to chan 0, confidences [0-1] to chan 1
//Pitch analysis, writes pitches as frequencies to chan 0, confidences [0-1] to chan 1
FluidBufPitch.process(s,b,numFrames:512 * 10,numChans:1,features:~pitchdata,action:{"Pitch Analysis Done".postln});
// Flatten and print the flat buffer. We expect to see larger numbers (20-2000) interleaved with smaller (0-1)
@ -94,4 +94,13 @@ FluidBufFlatten.process(s,~pitchdata,~flatdata,axis:1,action:{
})
//changing the axis, we see all large numbers first
FluidBufFlatten.process(s,~pitchdata,~flatdata,axis:0,action:{
~flatdata.loadToFloatArray(action:{ |a|
a.postln;
::
@ -125,7 +125,7 @@ code::
d = Buffer.new(s);
e = Buffer.new(s);
OSCFunc.trace(true, true)
// run with basic parameters
@ -175,7 +175,7 @@ y = Buffer.new(s);
~fft_size = 1024;
~frame_size = 512;
~hop_size = 256;
~which_component = 3;
~which_component = 1;
// matrix factorisation, requesting everything - wait for the computation time to appear.
@ -72,5 +72,6 @@ b = Buffer.read(s,~path+/+"Nicol-LoopE-M.wav")
t = Buffer.read(s,~path+/+"Tremblay-SA-UprightPianoPedalWide.wav")
o = Buffer.new
FluidBufNMFCross.process(s,t,b,o,action:{"Ding".postln})
//wait for it to be done. It is a long process.
o.play
@ -70,7 +70,7 @@ Routine{
// play with the scaling
FluidBufScale.process(s, b, destination: c, inputLow: 0, inputHigh: 1, outputLow: 20, outputHigh:10).wait;
// retrieve the buffer and enjoy the results.
c.getn(0,10,{|x|x.postln;})
c.getn(0,10,{|x|x.round(0.000001).postln;})
@ -186,7 +186,6 @@ c = Buffer.new(s);
// run the stats and send back the values
FluidBufStats.process(s, b, stats:c, numDerivs:1, action:{c.getn(0,c.numFrames * c.numChannels,{|item|d = item; d.postln})});
OSCFunc.allEnabled
//looking at the result is not easy to grasp, since it is interleaved: first number is mean of L, second is mean of R, third is stddev of L, fourth is stddev or R
//this will make it tidier - the first value of each line is Left, the second is Right
@ -59,7 +59,7 @@ c = Buffer(s)
// play with the threshold
FluidBufThresh.process(s, b, destination: c, threshold: 0.5)
c.getn(0,11,{|x|x.postln;})
c.getn(0,11,{|x|x.round(0.000001).postln;})
// also works in multichannel - explore the following buffer
b = Buffer.sendCollection(s,0.0.series(0.1,2.0).scramble,2)
@ -77,5 +77,5 @@ FluidBufThresh.process(s, b,startFrame: 3,numFrames: 4,startChan: 1,numChans: 1,
//enjoy
c.plot(separately: true).plotMode_(\points)
c.query
c.getn(0,4,{|x|x.postln;})
c.getn(0,4,{|x|x.round(0.000001).postln;})
@ -123,7 +123,6 @@ fork{
STRONG:: Merging Datasets::
s.dumpOSC
code::
//this is how to add items between 2 datasets.
//create 2 datasets
@ -131,7 +130,7 @@ code::
~dsA = FluidDataSet.new(s);
~dsB = FluidDataSet.new(s);
Dictionary.new
//feed them items with same dimensions but different labels
~dsA.load(Dictionary.newFrom([\cols, 1, \data, Dictionary.newFrom([\one,1,\two,2])]));
~dsB.load(Dictionary.newFrom([\cols, 1, \data, Dictionary.newFrom([\three,3,\four,4])]));
@ -120,9 +120,8 @@ fork{
~points.do{|x,i|
~tmpbuf.setn(0,x);
~dataSet.addPoint(i,~tmpbuf);
// s.sync
}
@ -137,7 +136,6 @@ fork{
// prepare a simple query
~query.filter(0,"<",0.04);
~query.addColumn(2);
~query.transform(~dataSet, ~out);
// check the result
@ -98,7 +98,7 @@ fork{
// Limit the search to an acceptable distance in a radius
// Define a point, and observe typical distance values
~p = [ 0.2,0.2];
~p = [ 0.4,0.4];
~tmpbuf = Buffer.loadCollection(s, ~p, 1, {
~tree.kNearestDist(~tmpbuf,{ |a|a.postln;~nearest = a;});
@ -129,7 +129,7 @@ For instance, whilst fitting the tree against some n-dimensional descriptor data
,(
var inputBuffer = Buffer.alloc(s,2);
var outputBuffer = Buffer.alloc(s,10);//5 neighbours * 2D data points
@ -67,7 +67,6 @@ A function to run when complete, taking an array of the counts for each category
EXAMPLES::
Server.default.options.outDevice = "Built-in Output"
@ -106,10 +105,6 @@ fork{
~kmeans.size;
~kmeans.dump;
~clusters.getLabel(0,{|clusterID|
(0.asString+clusterID).postln;
});
// Retrieve labels of clustered points
~assignments = Array.new(128);
@ -157,8 +152,6 @@ subsection:: Queries in a Synth
This is the equivalent of predictPoint, but wholly on the server
outputPoint.getToFloatArray(action:{|a|a.postln})
{
var trig = Impulse.kr(5);
@ -62,7 +62,7 @@ code::
~test = FluidDataSet(s);
~mapping = FluidLabelSet(s);
//Make some clumped 2D points and place into a DataSet
~examplepoints = [[0.5,0.5],[-0.5,0.5],[0.5,-0.5],[-0.5,-0.5]];
@ -93,7 +93,7 @@ d = Dictionary.with(
~classifier.predict(~test, ~mapping, 1);
//Return labels of clustered points
//Return labels of clustered points - wait for the dump to be done
~assignments = Array.new(~testpoints.size);
fork{
@ -175,7 +175,7 @@ code::
var outputPoint = LocalBuf(1);
point.collect{|p,i| BufWr.kr([p],inputPoint,i)};
~classifier.kr(trig,inputPoint,outputPoint);
SinOsc.ar((BufRd.kr(1,outputPoint,0,interpolation:0) + 69).midicps,mul: 0.1);
SinOsc.ar((BufRd.kr(1,outputPoint,0,interpolation:0) + 69).midicps, mul: 0.1);
@ -89,7 +89,7 @@ x = {arg type = 0;
// change the wave types, observe the amplitude invariance of the descriptors, apart from the leftmost coefficient
x.set(\type, 1)
~winRange = 50; //adjust the range above and below 0 to zoom in or out on the MFCC
~winRange = 5; //adjust the range above and below 0 to zoom in or out on the MFCC
x.set(\type, 2)
x.set(\type, 0)
// free this source
@ -124,10 +124,9 @@ code::
//Run the test data through the network, into the predicted labelset
~classifier.predict(~testdata,~predictedlabels,action:{"Test complete".postln});
OSCFunc.trace(true,true)
//get labels from server
~predictedlabels.dump(action:{|d|~labelsdict = d["data"]};~labelsdict.postln);
~predictedlabels.dump(action:{|d| ~labelsdict = d["data"]; ~labelsdict.postln});
//Visualise: we're hoping to see colours neatly mapped to quandrants...
@ -112,7 +112,7 @@ c = Buffer.new(s);
// train only 2 seconds
Routine {
FluidBufNMF.process(s,b,0,88200,0,1, c, ~bases, components:10,fftSize:2048);
FluidBufNMF.process(s,b,0,88200,0,1, c, ~bases, components:10,fftSize:2048).wait;
@ -197,7 +197,7 @@ c = Buffer.new(s);
FluidBufNMF.process(s,b,0,88200,0,1, c, ~bases, components:8, hopSize:256, fftSize:2048);
FluidBufNMF.process(s,b,0,88200,0,1, c, ~bases, components:8, hopSize:256, fftSize:2048).wait;
@ -130,7 +130,6 @@ FluidBufPitch.process(s,~audio, features: ~pitch_feature);
~inbuf = Buffer.loadCollection(s,0.5.dup);
~outbuf = Buffer.new(s);
~normalizer.transformPoint(~inbuf,~outbuf,{|x|x.postln;x.getn(0,2,{|y|y.postln;};)});
OSCFunc.trace(false,true)
//Server side queries
@ -66,7 +66,6 @@ EXAMPLES::
s.boot;
//Preliminaries: we want some audio, a couple of FluidDataSets, some Buffers and a FluidRobustScale
// FluidRobustScale.dumpAllMethods
~audiofile = File.realpath(FluidBufPitch.class.filenameSymbol).dirname +/+ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav";
~raw = FluidDataSet(s);