I have been experimenting with using the Synthesis toolkit for an audio project. I wrote a quick program below, that generates a WAV file of duration 1 sec with MIDI note 49. Actually, the program generates two such files, one using a "Bowed" instrument and the other using a "PercFlut" instrument. Strangely, when I playback the two WAV files that were generated, the frequencies are not the same. With the Bowed instrument, the dominant frequency for the same MIDI note seems to be 440 HZ. For the PrecFlut instrument, the dominant frequency seems to be somewhere around 210 HZ.
What am I doing wrong? Any help will be highly appreciated.
Thanks and here is my code:
#include <iostream>
#include <Voicer.h>
#include <Instrmnt.h>
#include <FileWvOut.h>
#include <Bowed.h>
#include <PercFlut.h>
using namespace stk;
// WAV file generated Note = 49. Duration = 1 second
void createFile(Voicer &voicer, StkFrames &frames, Instrmnt *instrmnt, const char *filename)
{
voicer.addInstrument(instrmnt, 1);
FileWvOut output;
output.openFile(filename, 1, FileWrite::FILE_WAV, Stk::STK_SINT16);
long tag1 = voicer.noteOn(49, 25, 1);
voicer.tick(frames, 1);
voicer.noteOff(tag1, 0);
output.tick(frames);
output.closeFile();
}
int main(int argc, char *argv[])
{
Voicer voicer;
StkFrames frames(44100 * 1, 1);
Instrmnt *bowed = new Bowed();
createFile(voicer, frames, bowed, "bowed.wav");
Instrmnt *percflut = new PercFlut();
createFile(voicer, frames, percflut, "percflut.wav");
delete bowed;
delete percflut;
}