Submit
Browse
Anonymous
Login
RSS
SuperCollider Code
Fork Code: analyze a sample with SCMIR and sort sample segments by similarity
name
code content
~file = "~/Musique/sc/samplekit/loop/lovin.flac".standardizePath; e = SCMIRAudioFile(~file, [[MFCC, 13], [Chromagram, 12]]); // open file for SCMIR b = Buffer.read(Server.default, ~file); // buffer for the Pbind {e.extractFeatures()}.fork; // extract features before creating similarityMatrix m = e.similarityMatrix(unit:10, metric:2); // create similarityMatrix ( // simple buffer player SynthDef(\playersec, { arg out=0, amp=0.1, gate=1, pan=0, freq=200, bufnum, speed=1, pos=0, doneAction=2, loop=0, trigger=1, velamp=1; // pos in seconds var sig; var sig1; sig = PlayBuf.ar(2, bufnum, BufRateScale.kr(bufnum) * speed, trigger, startPos: (pos*BufSampleRate.kr(bufnum)), doneAction:doneAction, loop: loop); sig = sig * EnvGen.ar(\adsr.kr(Env.adsr(0.001,0,1,0.01)),gate,doneAction:doneAction); //sig = Pan2.ar(sig, pan, 1).sum; Out.ar(out, sig * \gain.kr(1) * velamp); }).add; ); ( Pdef(\sortsample, Pbind( \instrument, \playersec, \bufnum, b, // take sample at column 105 and play other columns by order of similarity // pos is position in the sample in seconds // column 105 start at 105*m.reducedrows+0 and ends at 105*m.reducedrows+m.reducedcolumns // we take this slice of array, sort it and return the indexes (.order) // then scale column number to position in second \pos, Pseq(m.matrix[105*m.reducedrows+(0..m.reducedcolumns-1)].order) * b.duration/m.reducedrows, \sustain, b.duration/m.reducedrows, \dur, 1, \gain, 1, ) ).play; );
code description
use markdown for formating
category tags
comma separated, i.g. "wild, siren" (do not enter default SC class names, please)
ancestor(s)
comma separated identificators, i.g. "1-C,1-1,1-4M,1-x"
Private?
the code will be accessible by direct url and not visible in public activity
signup to submit public code without captcha
comment of change