I tried it, and it sounds quite good, but not quite like this: https://www.youtube.com/watch?v=muCPjK4nGY4
any other ideas? I tried mapping the amplitude as well, and make a threshold for it to send notes to my electric piano:
(
{
var buf = Buffer.alloc(s, 2048, bufnum:2);
var sig = PlayBuf.ar(2, 1, loop:1);
var analysis = Pitch.kr(sig, minFreq:18.midicps, maxFreq:108.midicps, ampThreshold:0.001);
var amp_anal = Amplitude.kr(sig);
SendReply.kr(Impulse.kr(50), "/anal", [analysis[0][0], amp_anal[0]]);
/*var chain = FFT(buf, sig);
var trig = Impulse.kr(30);
chain[0].pvcalc(80, {
|phas, mag|
SendReply.kr(trig, "/anal", mag);
});*/
}.play
)
(
OSCdef.new(\midiConverter, {
|msg|
msg.postln;
if(msg[4] > 0.01, {
~pno.noteOn(0, msg[3].cpsmidi.asInt, msg[4].linlin(0,1,60,127));
~pno.noteOff(0, msg[3].cpsmidi.asInt,60);
});
}, "/anal");
)