tweaks to examples (slowing them down at times)

nix
Pierre Alexandre Tremblay 6 years ago
parent 14f78dfc21
commit 9fef109e33

@ -114,6 +114,6 @@ Routine{
//query the single nearest neighbourg via 3 different data scaling. Depending on the random source at the begining, you will get small to large differences between the 3 answers!
[~tree,~normtree,~stdtree].do{|t| t.numNeighbours =1 };
~tree.kNearest(~query_buf, {|x| ("Original:" + x).post;~tree.kNearestDist(~query_buf,1, {|x| (" with a distance of " + x).postln});});
~normtree.kNearest(~normbuf, {|x| ("Normalized:" + x).post;~normtree.kNearestDist(~normbuf,1, {|x| (" with a distance of " + x).postln});});
~stdtree.kNearest(~stdbuf, {|x| ("Standardized:" + x).post; ~stdtree.kNearestDist(~stdbuf,1, {|x| (" with a distance of " + x).postln});});
~tree.kNearest(~query_buf, {|x| ("Original:" + x).post;~tree.kNearestDist(~query_buf, {|x| (" with a distance of " + x).postln});});
~normtree.kNearest(~normbuf, {|x| ("Normalized:" + x).post;~normtree.kNearestDist(~normbuf, {|x| (" with a distance of " + x).postln});});
~stdtree.kNearest(~stdbuf, {|x| ("Standardized:" + x).post; ~stdtree.kNearestDist(~stdbuf, {|x| (" with a distance of " + x).postln});});

@ -39,7 +39,7 @@ Routine{
~mappingresult = Buffer.alloc(s,512);
//make the process then fit the data
~knn = FluidKNNRegressor(s)
~knn = FluidKNNRegressor(s,3,1)
~knn.fit(~simpleInput, ~simpleOutput, action:{"fitting done".postln})
// query 512 points along the line (slow because of all that sync'ing)

@ -112,7 +112,7 @@ code::
~tree.inBus_(~pitchingBus).outBus_(~catchingBus).inBuffer_(~inputPoint).outBuffer_(~predictPoint);
{
var trig = Impulse.kr(ControlRate.ir/2);
var trig = Impulse.kr(4); //can go as fast as ControlRate.ir/2
var point = 2.collect{TRand.kr(0,1,trig)};
point.collect{|p,i| BufWr.kr([p],~inputPoint,i)};
Poll.kr(trig,point);

@ -166,7 +166,7 @@ code::
~kmeans.inBus_(~ib).outBus_(~ob).inBuffer_(~inpPoint).outBuffer_(~outPoint);
//pitching
{
var trig = Impulse.kr(100);
var trig = Impulse.kr(5);
var point = WhiteNoise.kr(1.dup);
var copied;
Poll.kr(trig, point, [\pointX,\pointY]);

@ -163,7 +163,7 @@ code::
~classifier.inBus_(~ib).outBus_(~ob).inBuffer_(~inpPoint).outBuffer_(~outPoint);
//pitching
{
var trig = Impulse.kr(100);
var trig = Impulse.kr(5);
var point = WhiteNoise.kr(1.dup);
Poll.kr(trig, point, [\pointX,\pointY]);
point.collect{ |p,i| BufWr.kr([p],~inpPoint,i)};

@ -129,7 +129,7 @@ FluidBufPitch.process(s,~audio, features: ~pitch_feature);
(
~tempPoint = Buffer.alloc(s,2);
~predictPoint = Buffer.alloc(s,2);
~avgBuf = Buffer.alloc(s,10,2);
~avgBuf = Buffer.alloc(s,100,2);
~pitchingBus = Bus.control;
~catchingBus = Bus.control;
)
@ -138,12 +138,12 @@ FluidBufPitch.process(s,~audio, features: ~pitch_feature);
//Pitching (no pun intended): read frames out of buffer and pass to standardize
{
var audio = BufRd.ar(1,~audio,LFSaw.ar(BufDur.ir(~audio).reciprocal).range(0, BufFrames.ir(~audio)));
var counter = Stepper.ar(Impulse.ar(ControlRate.ir),max:9);
var counter = Stepper.ar(Impulse.ar(ControlRate.ir),max:99);
var trig = HPZ1.ar(counter) < 0;
//average 10 frames: one could use the MovingAverage extension here
//average 100 frames: one could use the MovingAverage extension here
var avg;
BufWr.kr(FluidPitch.kr(audio),~avgBuf,phase:counter);
avg = Mix.new(BufRd.kr(2, ~avgBuf, phase:10.collect{|x|x})) * 0.1;
avg = Mix.new(BufRd.kr(2, ~avgBuf, phase:100.collect{|x|x})) * 0.1;
//assemble data point
BufWr.kr(avg[0],~tempPoint,0);
BufWr.kr(avg[1],~tempPoint,1);

@ -100,7 +100,7 @@ FluidBufMFCC.process(s,~audio, features: ~mfcc_feature);
};
dsWr = FluidDataSetWr.kr(\pca_help_12D, buf: buf, trig: Done.kr(stats));
LocalOut.kr( Done.kr(dsWr));
FreeSelf.kr(count - 98);
FreeSelf.kr(count - 99);
}.play;
)

@ -123,7 +123,7 @@ code::
(
~tempPoint = Buffer.alloc(s,2);
~predictPoint = Buffer.alloc(s,2);
~avgBuf = Buffer.alloc(s,10,2);
~avgBuf = Buffer.alloc(s,100,2);
~pitchingBus = Bus.control;
~catchingBus = Bus.control;
)
@ -133,12 +133,12 @@ code::
//Pitching (no pun intended): read frames out of buffer and pass to standardize
{
var audio = BufRd.ar(1,~audio,LFSaw.ar(BufDur.ir(~audio).reciprocal).range(0, BufFrames.ir(~audio)));
var counter = Stepper.ar(Impulse.ar(ControlRate.ir),max:9);
var counter = Stepper.ar(Impulse.ar(ControlRate.ir),max:99);
var trig = HPZ1.ar(counter) < 0;
//average 10 frames: one could use the MovingAverage extension here
var avg;
BufWr.kr(FluidPitch.kr(audio),~avgBuf,phase:counter);
avg = Mix.new(BufRd.kr(2, ~avgBuf, phase:10.collect{|x|x})) * 0.1;
avg = Mix.new(BufRd.kr(2, ~avgBuf, phase:100.collect{|x|x})) * 0.1;
//assemble data point
BufWr.kr(avg[0],~tempPoint,0);
BufWr.kr(avg[1],~tempPoint,1);

Loading…
Cancel
Save