楽器(ギター)から音符を検出できる処理アプリを作成しようとしています。たとえば、開いている「A」の音符が再生された場合、画面に音符を表示したり、画像を表示したりするなど、それに基づいて何かをしたいと思います。
私は立ち往生していて、それを正しく行っているかどうか、またはどのように進めればよいかわかりません。私が理解していることから、基本周波数を取得する必要がありますか? もしそうなら、どうすればそれを手に入れることができますか?今ノートを演奏すると、ノートが進行するにつれてスケッチにさまざまな周波数が表示されるようです。音符か何かの始まりだけを取得しようとすることになっていますか?
わからない場合は、私は初心者なので、優しくしてください;)これまでのところ、次のとおりです。
/* sketch to measure frequencies */
import ddf.minim.analysis.*;
import ddf.minim.*;
Minim minim;
AudioInput in;
FFT fft;
void setup()
{
size(512, 200, P3D);
minim = new Minim(this);
in = minim.getLineIn(Minim.STEREO, 2048);
// create an FFT object that has a time-domain buffer
// the same size as jingle's sample buffer
// note that this needs to be a power of two
// and that it means the size of the spectrum
// will be 512. see the online tutorial for more info.
fft = new FFT(in.bufferSize(), 44100);
}
void draw()
{
background(0);
stroke(255);
// perform a forward FFT on the audip that's coming in
fft.forward(in.mix);
for(int i = 0; i < fft.specSize(); i++)
{
// draw the line for frequency band i, scaling it by 4 so we can see it a bit better
line(i, height, i, height - fft.getBand(i) * 4);
//print out the frequency. Am I supposed to be multiplying the value by 2048?
println( (fft.getFreq(i) * 2048));
}
fill(255);
}
void stop()
{
// always close Minim audio classes when you finish with them
in.close();
minim.stop();
super.stop();
}