// ex6.cpp / Music 3SI / Lecture 2 // Takes ADC input for a given duration (arg. #2 [s]) // and saves it as a wave file (arg. #1) // // Mac OS X with StkX: // g++ -g -o ex6 ex6.cpp -framework StkX // // CCRMA Linux machines: // g++ -g -o ex6 ex6.cpp -I/usr/include/stk -lstk -lasound -ljack // // Usage: ./ex6 output_file duration // Example: ./ex6 sinewave.raw 440.0 2.0 // // Created by Woon Seung Yeo on 4/13/06. // Copyright 2006 CCRMA, Stanford University. All rights reserved. // When used with StkX, these headers should be replaced with "#include " #include "RtWvIn.h" #include "FileWvOut.h" int main (int argc, char* const argv[]) { char* waveOutName = argv[1]; float length = atof ( argv[2] ); Stk::setSampleRate( 44100.0 ); RtWvIn adc; // RtWvIn: realtime input from ADC FileWvOut output; output.openFile( waveOutName, 1, FileWrite::FILE_WAV, Stk::STK_SINT16 ); for ( int i=0; i<(44100*length); i++ ) output.tick( adc.tick() ); return 0; }