/* 1st sheet of assignment1: FluteNote.cpp use one highlighter color for custom names, one color for Stk, one for C and C++ */ /* for components from Stk, see http://www-ccrma.stanford.edu/software/stk or stk-4.0/doc/html/index.html */ #include "Flute.h" #include "RtWvOut.h" #include "WvOut.h" /* entry point for the application */ int main (void) { int nChans = 2; int sampleHz = 48000; Stk::setSampleRate (sampleHz); RtWvOut *dac = new RtWvOut (nChans); WvOut *wavFile = new WvOut ("/zap/test.wav", nChans); Flute *f = new Flute (100.0); int sampleCounter = 0; int end = (int) (1.0 * sampleHz); int on = (int) (0.0 * sampleHz); int off = (int) (0.1 * sampleHz); while (sampleCounter < end) { if (sampleCounter == on) f->noteOn (440.0, 0.5); if (sampleCounter == off) f->noteOff (0.1); double sample = f->tick (); dac->tick (sample); wavFile->tick (sample); sampleCounter++; } delete wavFile; delete dac; delete f; }