From dcc0509cb319cb8f18b15540c9c98026f12e54ef Mon Sep 17 00:00:00 2001 From: Pierre Alexandre Tremblay Date: Sun, 13 Dec 2020 21:49:01 +0000 Subject: [PATCH] more small tweaks --- .../11-compositing-datasets.scd | 24 +++++++++---------- .../12-windowed-clustered-segmentation.scd | 16 ++++++------- .../2-3Dscaling.scd | 22 ++++++++--------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/release-packaging/Examples/dataset/1-learning examples/11-compositing-datasets.scd b/release-packaging/Examples/dataset/1-learning examples/11-compositing-datasets.scd index 687958f..8c69f75 100644 --- a/release-packaging/Examples/dataset/1-learning examples/11-compositing-datasets.scd +++ b/release-packaging/Examples/dataset/1-learning examples/11-compositing-datasets.scd @@ -2,10 +2,10 @@ // define a few datasets ( -~pitchDS = FluidDataSet(s,\pitch11); -~loudDS = FluidDataSet(s,\loud11); -~mfccDS = FluidDataSet(s,\mfcc11); -~durDS = FluidDataSet(s,\dur11); +~pitchDS = FluidDataSet(s); +~loudDS = FluidDataSet(s); +~mfccDS = FluidDataSet(s); +~durDS = FluidDataSet(s); //define as many buffers as we have parallel voices/threads in the extractor processing (default is 4) ~pitchbuf = 4.collect{Buffer.new}; @@ -102,7 +102,7 @@ t = Main.elapsedTime; /////////////////////////////////////////////////////// //reduce the MFCC timbral space stats (many potential ways to explore here... - 2 are provided to compare, with and without the derivatives before running a dimension reduction) -~tempDS = FluidDataSet(s,\temp11); +~tempDS = FluidDataSet(s); ~query = FluidDataSetQuery(s); ~query.addRange(0,24);//add only means and stddev of the 12 coeffs... @@ -115,12 +115,12 @@ t = Main.elapsedTime; // standardizing before the PCA, as argued here: // https://scikit-learn.org/stable/auto_examples/preprocessing/plot_scaling_importance.html ~stan = FluidStandardize(s); -~stanDS = FluidDataSet(s,\stan11); +~stanDS = FluidDataSet(s); ~stan.fitTransform(~tempDS,~stanDS) //shrinking A: using 2 stats on the values, and 2 stats on the redivative (12 x 2 x 2 = 48 dim) ~pca = FluidPCA(s,4);//shrink to 4 dimensions -~timbreDSd = FluidDataSet(s,\timbreDSd11); +~timbreDSd = FluidDataSet(s); ~pca.fitTransform(~stanDS,~timbreDSd,{|x|x.postln;})//accuracy //shrinking B: using only the 2 stats on the values @@ -133,7 +133,7 @@ t = Main.elapsedTime; //keep its own PCA so we can keep the various states for later transforms ~pca2 = FluidPCA(s,4);//shrink to 4 dimensions -~timbreDS = FluidDataSet(s,\timbreDS11); +~timbreDS = FluidDataSet(s); ~pca2.fitTransform(~tempDS,~timbreDS,{|x|x.postln;})//accuracy // comparing NN for fun @@ -181,7 +181,7 @@ Routine{ /////////////////////////////////////////////////////// // compositing queries - defining a target and analysing it -~globalDS = FluidDataSet(s,\global11); +~globalDS = FluidDataSet(s); // define a source ~targetsound = Buffer.read(s,File.realpath(FluidBufPitch.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/Tremblay-ASWINE-ScratchySynth-M.wav",42250,44100); @@ -267,9 +267,9 @@ Routine{ // make sure to define and describe the source above (lines 178 to 201) // let's make normalised versions of the 3 datasets, keeping the normalisers separate to query later -~loudDSn = FluidDataSet(s,\loud11n); -~pitchDSn = FluidDataSet(s,\pitch11n); -~timbreDSn = FluidDataSet(s,\timbre11n); +~loudDSn = FluidDataSet(s); +~pitchDSn = FluidDataSet(s); +~timbreDSn = FluidDataSet(s); ~normL = FluidNormalize(s) ~normP = FluidNormalize(s) diff --git a/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd b/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd index 49205ab..2385216 100644 --- a/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd +++ b/release-packaging/Examples/dataset/1-learning examples/12-windowed-clustered-segmentation.scd @@ -1,10 +1,10 @@ // load a source folder -~loader = FluidLoadFolder("/Volumes/machins/projets/newsfeed/sons/textes/Audio/synth"); +~loader = FluidLoadFolder(File.realpath(FluidBufPitch.class.filenameSymbol).dirname.withTrailingSlash ++ "../AudioFiles/"); ~loader.play; //slightly oversegment with novelty //segments should still make sense but might cut a few elements in 2 or 3 -~slicer = FluidSliceCorpus({ |src,start,num,dest| FluidBufNoveltySlice.kr(src,start,num,indices:dest, feature: 1, kernelSize: 29, threshold: 0.05, filterSize: 5, hopSize: 128)}); +~slicer = FluidSliceCorpus({ |src,start,num,dest| FluidBufNoveltySlice.kr(src,start,num,indices:dest, feature: 1, kernelSize: 29, threshold: 0.1, filterSize: 5, hopSize: 128)}); ~slicer.play(s, ~loader.buffer,~loader.index); //test the segmentation by looping them @@ -14,7 +14,7 @@ d = {arg start=0, end = 44100; BufRd.ar(1, ~loader.buffer, Phasor.ar(0,1,start,end,start),0,1); }.play; -w = Window.new.front; +w = Window.new(bounds:Rect(100,100,400,60)).front; b = ControlSpec(0, ~originalindices.size - 1, \linear, 1); // min, max, mapping, step c = StaticText(w, Rect(340, 20, 50, 20)).align_(\center); a = Slider(w, Rect(10, 20, 330, 20)) @@ -29,8 +29,8 @@ a = Slider(w, Rect(10, 20, 330, 20)) ~featuresbuf = 4.collect{Buffer.new}; ~statsbuf = 4.collect{Buffer.new}; ~flatbuf = 4.collect{Buffer.new}; -~slicesMFCC = FluidDataSet(s,\slicesM); -~slicesShapes = FluidDataSet(s,\slicesS); +~slicesMFCC = FluidDataSet(s); +~slicesShapes = FluidDataSet(s); ~extractor = FluidProcessSlices({|src,start,num,data| var features, stats, writer, flatten,mfccBuf, statsBuf, flatBuf, label, voice; label = data.key; @@ -54,12 +54,12 @@ a = Slider(w, Rect(10, 20, 330, 20)) //we overlap the analysis with the last (original) slice to check for continuity ( ~winSize = 4;//the number of consecutive items to split in 2 classes; -~curated = FluidDataSet(s,\curatedDS); +~curated = FluidDataSet(s); ~query = FluidDataSetQuery(s); ~stan = FluidStandardize(s); ~kmeans = FluidKMeans(s,2,1000); -~windowDS = FluidDataSet(s,\windowDS); -~windowLS = FluidLabelSet(s,\windowLS); +~windowDS = FluidDataSet(s); +~windowLS = FluidLabelSet(s); ) //curate stats (MFCCs) diff --git a/release-packaging/Examples/dataset/2-various other examples/scaling-dimension-as-weighting/2-3Dscaling.scd b/release-packaging/Examples/dataset/2-various other examples/scaling-dimension-as-weighting/2-3Dscaling.scd index 2d47818..71b7e7f 100644 --- a/release-packaging/Examples/dataset/2-various other examples/scaling-dimension-as-weighting/2-3Dscaling.scd +++ b/release-packaging/Examples/dataset/2-various other examples/scaling-dimension-as-weighting/2-3Dscaling.scd @@ -12,14 +12,14 @@ ~query = FluidDataSetQuery(s); ~stan = FluidStandardize(s); ~norm = FluidNormalize(s); -~sourceR = FluidDataSet(s,\a3DsourceR); -~sourceG = FluidDataSet(s,\a3DsourceG); -~sourceB = FluidDataSet(s,\a3DsourceB); -~scaledR = FluidDataSet(s,\a3DscaledR); -~scaledG = FluidDataSet(s,\a3DscaledG); -~scaledB = FluidDataSet(s,\a3DscaledB); -~composited = FluidDataSet(s,\a3Dcomposited); -~labels = FluidLabelSet(s,\a3Dlabels); +~sourceR = FluidDataSet(s); +~sourceG = FluidDataSet(s); +~sourceB = FluidDataSet(s); +~scaledR = FluidDataSet(s); +~scaledG = FluidDataSet(s); +~scaledB = FluidDataSet(s); +~composited = FluidDataSet(s); +~labels = FluidLabelSet(s); ) //Make some random, but clustered test points, each descriptor category in a separate dataset @@ -81,7 +81,7 @@ w.front; //Visualise: ( -w = Window("stanClasses", Rect(128, 64, 820, 120)); +w = Window("stanClasses", Rect(128, 204, 820, 120)); w.drawFunc = { Pen.use{ ~compodict2["data"].keysValuesDo{|key, colour| @@ -115,7 +115,7 @@ w.front; //Visualise: ( -w = Window("normClasses", Rect(128, 64, 820, 120)); +w = Window("normClasses", Rect(128, 344, 820, 120)); w.drawFunc = { Pen.use{ ~compodict2["data"].keysValuesDo{|key, colour| @@ -147,7 +147,7 @@ w.front; //Visualise: ( -w = Window("norm10rClasses", Rect(128, 64, 820, 120)); +w = Window("norm10rClasses", Rect(128, 484, 820, 120)); w.drawFunc = { Pen.use{ ~compodict2["data"].keysValuesDo{|key, colour|