From 0b2007d116794ba66c1f5179abfaeb9f68dc8c2a Mon Sep 17 00:00:00 2001 From: Ted Moore Date: Wed, 5 Jan 2022 17:23:31 -0500 Subject: [PATCH] fluid waveform spectrogram scratch paper --- ...luidWaveform spectrogram scratch paper.scd | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 test/FluidWaveform spectrogram scratch paper.scd diff --git a/test/FluidWaveform spectrogram scratch paper.scd b/test/FluidWaveform spectrogram scratch paper.scd new file mode 100644 index 0000000..1d86849 --- /dev/null +++ b/test/FluidWaveform spectrogram scratch paper.scd @@ -0,0 +1,85 @@ +// FluidWaveform + +( +s.waitForBoot{ + b = Buffer.read(s,FluidFilesPath("Tremblay-AaS-AcousticStrums-M.wav")); + m = Buffer(s); + + ~csv_colors = CSVFileReader.readInterpret("/Users/macprocomputer/Desktop/_flucoma/CETperceptual_csv_0_1/CET-L08.csv"); + + // ~csv_colors.shape.postln; + // ~csv_colors[0].postln; + + ~colors = ~csv_colors.collect{ + arg row; + Color.fromArray(row); + }; + + // ~colors[0].postln; + + s.sync; + FluidBufSTFT.processBlocking(s,b,magnitude:m); + s.sync; + w = Window("spectrogram test",Rect(0,0,1600,900)); + w.background_(Color.white); + + m.loadToFloatArray(action:{ + arg mags; + // var maxItem; + // var minItem; + + mags = mags / mags.maxItem; + + mags = mags.log10 * 20; + + "one thing: %".format(mags[100]).postln; + + mags = mags.clump(m.numChannels); + + mags = mags.collect{ + arg frame; + frame.resamp1(w.bounds.height); + }; + + mags = mags.flop.collect{ + arg row; + row.resamp1(w.bounds.width); + }.flop; + + mags.shape.postln; + + //maxItem = mags.collect(_.maxItem).maxItem; + // minItem = mags.collect(_.minItem).minItem; + + // maxItem.postln; + + mags = mags.collect{ + arg frame; + frame.collect{ + arg mag; + mag.linlin(-120.0,0.0,0.0,255.0).asInteger; + }; + }; + + 100.do{ + // mags[rrand(0,mags.size-1)].choose.postln; + }; + + ~uv = UserView(w,w.bounds) + .drawFunc_{ + mags.do{ + arg frame, x; + frame.do{ + arg mag, y; + // mag.postln; + Pen.addRect(Rect(x,w.bounds.height - y,1,1)); + Pen.fillColor_(~colors[mag]); + Pen.fill; + } + } + }; + + w.front; + }); +}; +) \ No newline at end of file