Hi all,
I am using SuperCollider and FluCoMa to create a classifier (much like the tutorial already posted, but with a broader set of instruments). I was wondering whether FluidDataSetWr stops recording data into the FluidDataSet during silences in an audio buffer or if it’s possible to ensure this happens?
I have tried to write up a synth controller that auto detects amplitude and then sends a reply to the client to add points to the fluid data set when the amplitude is above a certain threshold, but for some reason, no points are being recorded. Maybe I have a silly mistake in my code as well…
~nmfccs = 13;
~mfccbuf = Buffer.alloc(s,13);
~timbredata = FluidDataSet(s);
~labels = [FluidLabelSet(s), FluidLabelSet(s), FluidLabelSet(s)];
~counter = 0;
// function to build an amplitude detecting SynthDef that sends its name and amplitude value as a reply out of the server from a factory made SynthDef.
~amp_reply_synth_def_constructor = {
arg synthDefName;
SynthDef.new(\++synthDefName, {
arg bufnum=0, start=1;
var playBuf, trig, amp, mfccs;
playBuf = PlayBuf.ar(2, bufnum, BufRateScale.ir(bufnum), start, doneAction:2);
trig = Impulse.ar(30);
amp = Amplitude.kr(playBuf);
mfccs = FluidMFCC.kr(playBuf, ~nmfccs, startCoeff:1, maxNumCoeffs: ~nmfccs);
FluidKrToBuf.kr(mfccs, ~mfccbuf);
SendReply.ar(trig, '/'++synthDefName.asString, amp);
Out.ar(0, playBuf);
}).add;
};
// Function to build a given Synth with an amplitude reply based on a synthDef name and a given buf num.
~amp_reply_synth_init = {
arg synthDefName, buf;
var synth, newSynthDef;
newSynthDef = ~amp_reply_synth_def_constructor.value(synthDefName);
synth = Synth(synthDefName, [\bufnum, buf]);
};
~osc_def_point_adder_builder = {
arg oscPath;
var smoothingArray, counter;
smoothingArray = Array.fill(10, {arg i; 0});
counter = 0;
OSCdef(\analy, {|msg, time|
var avg;
// put 10 values into an array
smoothingArray.put(counter % 10, msg[3]);
// average values
avg = smoothingArray.median;
// increment counter
counter = counter + 1;
//Boolean test for whether rolling average amplitude is over desired level. Add point if true.
if(avg > 0.0009, { ~add_point.value(oscPath); });
}, oscPath);
};
// Function to add points to timbre data and labels
~add_point = {
arg oscPath;
var id, labels;
id = "example-%".format(~counter);
labels = oscPath.asString.split($-);
~timbredata.addPoint(id,~mfccbuf);
~labels.do({
arg item, i;
item.addLabel(id, labels[i]);
});
~counter = ~counter + 1;
};
// amp reply synth init test code - do one by one for now...
~singlePath = PathName.new("/path/to/train/aluminum-brush-fortissimo.wav");
b = Buffer.read(s, ~singlePath.fullPath, 0, -1);
~osc_def_point_adder_builder.value('aluminum-brush-fortissimo');
~amp_reply_synth_init.value('aluminum-brush-fortissimo', b);