updated dataset demos

nix
Pierre Alexandre Tremblay 5 years ago
parent 37bdb06954
commit 1efc9427c5

@ -1,19 +1,20 @@
s.reboot;
//Preliminaries: we want some audio, a couple of FluidDataSets, some Buffers
(
~raw = FluidDataSet(s,\MLP40);
~raw = FluidDataSet(s,\Mel40);
~norm = FluidDataSet(s,\Mel40n);
~retrieved = FluidDataSet(s,\ae2);
~audio = Buffer.read(s,File.realpath(FluidBufMelBands.class.filenameSymbol).dirname +/+ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav");
~melfeatures = Buffer.new(s);
~stats = Buffer.alloc(s, 7, 40);
~datapoint = Buffer.alloc(s, 40);
~mlp = FluidMLPRegressor(s,[10,2,10],1,1,2,10000,0.01,0.1,10,0);
~mlp = FluidMLPRegressor(s,[9,2,9],activation: 1,outputActivation: 1,tapIn: 0,tapOut: 2,maxIter: 10000,learnRate: 0.1,momentum: 0.1,batchSize: 10,validation: 0.1);
~normalizer = FluidNormalize(s);
)
// process the melbands
FluidBufMelBands.process(s,~audio, features: ~melfeatures,action: {\done.postln;});
~raw.free
// Divide the time series in 100, and take the mean of each segment and add this as a point to
// the 'raw' FluidDataSet
(
@ -31,15 +32,19 @@ FluidBufMelBands.process(s,~audio, features: ~melfeatures,action: {\done.postln;
dsWr = FluidDataSetWr.kr(\MLP40, buf: buf, trig: Done.kr(stats));
LocalOut.kr( Done.kr(dsWr));
FreeSelf.kr(count - 99);
Poll.kr(trig,count);
}.play;
)
// wait for the post window to acknoledge the job is done.
// normalize the input
~normalizer.fitTransform(~raw,~norm);
//we can then run the AE - the server might become yellow :)
~mlp.fit(~raw,~raw,{|x|x.postln;});
~mlp.fit(~norm,~norm,{|x|x.postln;});
//we can then retrieve the hidden layer #2
~mlp.predict(~raw,~retrieved)
~mlp.predict(~norm,~retrieved)
//check the structure of retrieved
~retrieved.print
@ -47,17 +52,17 @@ FluidBufMelBands.process(s,~audio, features: ~melfeatures,action: {\done.postln;
//let's normalise it for display
~normData = FluidDataSet(s,\ae2N);
~reducedarray = Array.new(100);
~normalizer = FluidNormalize(s);
~normalizer.fitTransform(~retrieved,~normData, action:{
~normalView = FluidNormalize(s);
(
~normalView.fitTransform(~retrieved,~normData, action:{
~normData.dump{|x| 100.do{|i|
~reducedarray.add(x["data"][i.asString])
}};
});
)
~normData.print
~reducedarray.postln;
//Visualise the 2D projection of our original 12D data
(
d = ~reducedarray.flatten(1).unlace.deepCollect(1, { |x| x.normalize});

@ -7,12 +7,12 @@
~flatbuf = 4.collect{Buffer.new};
// here we instantiate a loader which creates a single large buffer with a dictionary of what was included in it
// ~loader = FluidLoadFolder("/Volumes/machins/projets/newsfeed/smallnum/");
~loader = FluidLoadFolder("/Volumes/machins/projets/newsfeed/segments/");
// ~loader = FluidLoadFolder("/Volumes/machins/projets/newsfeed/sons/smallnum/");
~loader = FluidLoadFolder("/Volumes/machins/projets/newsfeed/sons/segments/");
// here we instantiate a further slicing step if needs be, which iterate through all the items of the FluidLoadFolder and slice the slices with the declared function. Here it is a very picky onset slicer
~slicer = FluidSliceCorpus({ |src,start,num,dest|
FluidBufOnsetSlice.kr(src,start,num,metric: 9, minSliceLength: 17, indices:dest, threshold:2)
FluidBufOnsetSlice.kr(src,start,num,metric: 9, minSliceLength: 17, indices:dest, threshold:2,blocking: 1)
});
// here we instantiate a process of description and dataset writing, which will run each slice of the previous slice and write the entry. Note the chain of Done.kr triggers.
@ -20,10 +20,10 @@
var mfcc, stats, writer, flatten,mfccBuf, statsBuf, flatBuf, label, voice;
label = data.key;
voice = data.value[\voice];
mfcc = FluidBufMFCC.kr(src,startFrame:start,numFrames:num,numChans:1,features:~mfccbuf[voice],trig:1);
stats = FluidBufStats.kr(~mfccbuf[voice],stats:~statsbuf[voice],trig:Done.kr(mfcc));
flatten = FluidBufFlatten.kr(~statsbuf[voice],~flatbuf[voice],trig:Done.kr(stats));
writer = FluidDataSetWr.kr(~ds,label, -1, ~flatbuf[voice], Done.kr(flatten))
mfcc = FluidBufMFCC.kr(src,startFrame:start,numFrames:num,numChans:1,features:~mfccbuf[voice],trig:1,blocking: 1);
stats = FluidBufStats.kr(~mfccbuf[voice],stats:~statsbuf[voice],trig:Done.kr(mfcc),blocking: 1);
flatten = FluidBufFlatten.kr(~statsbuf[voice],~flatbuf[voice],trig:Done.kr(stats),blocking: 1);
writer = FluidDataSetWr.kr(~ds,label, -1, ~flatbuf[voice], Done.kr(flatten),blocking: 1)
});
)

Loading…
Cancel
Save