Hi,
I'm running a simple pitch extraction on an audio loop, containing sounds at G2, G3, G4, G5.
The code runs fine both on bela and in SC on my PC.
However when i print the values, i get different results on both platforms.
Bela is off, on the G2 by over a semitone! How is this possible?
freq = tracked pitch
qfreq = rounded pitch
note = midi note
qnote = rounded midi note
Value: SC - bela
freq: 100.008 - 105.955
qfreq: 97.9988 - 103.826
Note: 43.3514 - 44.3579
qNote: 43 - 44
freq: 196.492 - 196.87
qfreq: 195.998 - 195.988
Note: 55.0436 - 55.0769
qNote: 55 - 55
freq: 391.638 - 393.691
qfreq: 391.995 - 391.995
Note: 66.9842 - 67.0747
qNote: 67 - 67
freq: 782.874 - 783.97
qfreq: 783.991 - 783.991
Note: 78.9753 - 78.9995
qNote: 79 - 79
the code on bela
//pitchtracker on bela basic test
// boot settings
s = Server.default;
s.options.numAnalogInChannels = 4; // can be 2, 4 or 8
s.options.numAnalogOutChannels = 4; // can be 2, 4 or 8
s.options.numDigitalChannels = 16;
s.options.maxLogins = 4;
s.options.dacLevel = -2; // sets the gain of the dac to -2 dB
s.options.adcLevel = -20; // sets the gain of the adc to -2 dB
s.options.numMultiplexChannels = 0; // do not enable multiplexer channels
s.options.blockSize = 16;
s.options.numInputBusChannels = 2; // Use only the L/R audio channels
s.options.numOutputBusChannels = 2; // Use only the L/R audio channels
s.options.memSize = 8192 * 16; // the default is 8192 which is quite little
s.boot;
//Boot config end
s.waitForBoot {
// Your code goes here.
// load sample
b = Buffer.read(s, "/root/Bela/projects/sc_mdl/ggggm.wav"); //lute test file
b.numFrames; // Bufferlngth
( //VCO pitch tracking from file read by phasor with Arguments and Printing, Quantization
SynthDef.new(\pitchfollow,{
arg rate=1, inter=2;
var file, freq, hasFreq, sig, mix, qfreq, note, qnote;
file = PlayBuf.ar(1,b.bufnum, loop:1);
//file = BLowPass4.ar(file, 600.0);
# freq = Pitch.kr(in: file, //Input
initFreq: 100.008, //Initial output of Freq 116.541
minFreq: 100.0, //Minimal Frequency of Pitch Detection Window
maxFreq: 800.0, //Maximal Frequency of Pitch Detection Window
execFreq: 100.0, // Pitch Evaluations per Second
median: 1, //Anti Jitter Lag Filter
ampThreshold: 0.25, // Input Threshold for Pitch Evaluation to Run
peakThreshold: 0.7 ); // Inp ut threshold for Pitch Re-Evaluation ???
qfreq = freq.cpsmidi.round.midicps; // rounded quantification
note = freq.cpsmidi;
qnote = freq.cpsmidi.round; // Rounded Midi Note
sig = BLowPass4.ar(Pulse.ar(freq), 600.0);// LPF Pulse VCO
mix = ((sig*0.3) + (file*0.5)); //Mix between sample and vco
Poll.kr(Impulse.kr(0.2), [freq, qfreq, note, qnote], ["freq","qfreq","Note","qNote"]); // Print
Out.ar([0,1], (mix*0.5))// Output bus
}).play(s);
)
}; // end of waitForBoot
the code in SC
( //VCO pitch tracking from file with Arguments and Printing, Quantization
SynthDef.new(\pitchfollow,{
arg rate=1, inter=2;
var file, freq, hasFreq, sig, mix, qfreq, note, qnote;
file = PlayBuf.ar(1,b.bufnum, loop:0);
//file = BLowPass4.ar(file, 600.0);
# freq = Pitch.kr(in: file, //Input
initFreq: 97.9988, //Initial output of Freq 116.541
minFreq: 100.0, //Minimal Frequency of Pitch Detection Window
maxFreq: 800.0, //Maximal Frequency of Pitch Detection Window
execFreq: 100.0, // Pitch Evaluations per Second
median: 1, //Anti Jitter Lag Filter
ampThreshold: 0.25, // Input Threshold for Pitch Evaluation to Run
peakThreshold: 0.6 ); // Inp ut threshold for Pitch Re-Evaluation ???
qfreq = freq.cpsmidi.round.midicps; // rounded quantification
note = freq.cpsmidi;
qnote = freq.cpsmidi.round; // Rounded Midi Note
sig = BLowPass4.ar(Pulse.ar(freq), 600.0);// LPF Pulse VCO
mix = ((sig*0.3) + (file*0.5)); //Mix between sample and vco
Poll.kr(Impulse.kr(0.5), [freq, qfreq, note, qnote], ["freq","qfreq","Note","qNote"]); // Print
Out.ar([0,1], mix)// Output bus
}).play(s);
)
Thanks
Björn