updated 'myfirstdataset' example with less 'WeeFuzzyCentred' paths

nix
Pierre Alexandre Tremblay 6 years ago
parent 1268ef20d3
commit 9ea55585f7

@ -13,17 +13,19 @@ if(s.hasBooted.not){"Warning: server not running".postln};
//STEP 1: Get some files //STEP 1: Get some files
( (
// ~path = nil Buffer.freeAll;
// FileDialog.new(fileMode:2,okFunc:{|x| ~path = x[0]}); FileDialog.new(fileMode:2,okFunc:{|x| ~path = x[0];
~path="/Users/owen/Documents/16bitBoxes/";
~audioBuffers = SoundFile.collectIntoBuffers(~path+/+'*',s); ~audioBuffers = SoundFile.collectIntoBuffers(~path+/+'*',s);
~lookup = Dictionary(n:~audioBuffers.size); ~lookup = Dictionary(n:~audioBuffers.size);
~audioBuffers.do{|b| ~lookup.add(b.path->b)} ~audioBuffers.do{|b| ~lookup.add(b.path->b)};
});
) )
//STEP 2: Make a FluidDataSet //STEP 2: Make a FluidDataSet
~dataset = FluidDataSet.new(s,"mfccs", 96) //12 dims * 4 stats * 2 derivatives ~dataset = FluidDataSet.new(s,"mfccs", 96) //12 dims * 4 stats * 2 derivatives
//STEP 3A: EITHER populate the dataset like so (and cry about how long the data point assembly takes) //STEP 3A: EITHER populate the dataset like so (and cry about how long the data point assembly takes)
(
Routine{ Routine{
~audioBuffers.do{|b| ~audioBuffers.do{|b|
var tmpMFCCs = Buffer.new(s); var tmpMFCCs = Buffer.new(s);
@ -49,13 +51,25 @@ Routine{
tmpMFCCs.free; tmpMFCCs.free;
}; };
}.play }.play
)
//check //check
~dataset.size({|x| x.postln}) ~dataset.size({|x| x.postln})
//save //save
~dataset.write("/Users/owen/Documents/16bitBoxes/mfccs.json") (
FileDialog.new(fileMode: 0, acceptMode: 1, okFunc:{|x| var file = x[0];
//if the file exists and is a json, delete it
if ((file.splitext[1] == "json") && (File.existsCaseSensitive(file)), {File.delete(file);"File Overwritten".postln;});
//if not json, make it so
if (file.splitext[1] != "json", {file = file ++ ".json";});
// then write
~dataset.write(file);
});
)
//STEP 3B: OR load in one you rolled eearlier //STEP 3B: OR load in one you rolled earlier
~dataset.read("/Users/owen/Documents/16bitBoxes/mfccs.json") FileDialog.new(fileMode: 0, acceptMode: 0, okFunc:{|x| ~dataset.read(x[0])});
//peek //peek
c = Buffer.new(s) c = Buffer.new(s)
@ -64,12 +78,12 @@ c = Buffer.new(s)
/*************************************/ /*************************************/
//FluidKDTree //FluidKDTree
~kdtree = FluidKDTree.new(s) ~kdtree = FluidKDTree.new(s)
~kdtree.index(~dataset,action:{"index".postln}) ~kdtree.fit(~dataset,action:{"fit".postln})
//match //match
~kdtree.kNearest(c,5,{|x| ~matches = x}) ~kdtree.kNearest(c,5,{|x| ~matches = x;})
~kdtree.kNearestDist(c,5,{|x| x.postln}) ~kdtree.kNearestDist(c,5,{|x| x.postln})
~lookup[~matches[4]].play ~lookup[~matches[4]].postln
/*************************************/ /*************************************/
//FluidKMeans //FluidKMeans

Loading…
Cancel
Save