2

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;
}
Karthik
  • 719
  • 2
  • 11
  • 18
  • Have you considered different spectral signs of these instruments (and harmonics)? What was used to measure the outputted frequency? If the second one was around 220Hz, it doesnt necessarily mean that the note is incorrect. – Bartek Banachewicz May 18 '12 at 11:29
  • When I playback both the WAV files (bowed.wav and percflut.wav), they don't sound the same (from a frequency standpoint). I used Audacity and obtained a frequency spectrum for both files. That's how I was able to infer the fundamental frequencies. – Karthik May 18 '12 at 11:46
  • I wonder if they're tuned to standard A440 by default. Wikipedia says something about Midi Tuning Standard, which allows to assign different frequencies to any possible keys. I really have no clue, but I'm trying to find out what is the problem here... – Bartek Banachewicz May 18 '12 at 11:53

0 Answers0