/********************************************/
/* main.cpp */
/* Test main program for SimpString.cpp */
/* Compatible with STK version 4.2.1. */
/* Julius Smith, 2000-2005. */
/********************************************/
#include "FileWvOut.h"
#include "SimpString.h"
#include "Stk.h"
#include <stdlib.h>
#include <ctype.h>
int main(int argc,char *argv[])
{
long i;
FileWvOut output("test"); /* creates test.wav */
SimpString *simpString = new SimpString(/* lowest pitch */ 50.0);
StkFloat srate = Stk::sampleRate();
simpString->noteOn(srate/100.0 /* 100-sample period */,
1.0 /* amplitude */,
0.25 /* pluck position (0:1) */
);
output.tick(simpString->tick(1.0)); /* impulse */
for (i=1;i<srate;i++) {
output.tick(simpString->tick(0));
}
delete simpString;
return(0);
}
In the STK, every sound-producing module is expected to implement the tick function (or ``method'', if you prefer) which computes and returns one sample of audio output. The argument of the tick function, if present, is normally a single sample of audio input for the module (such as is needed by a digital filter module). Multichannel output may be handled by the tickFrame function, and both tick and tickFrame can handle multiple samples per call. See the STK documentation for details.
When the main program is executed, it creates a soundfile in the current working directory by performing the following steps:
Stk::setSampleRate(newsrate);