// ex5.cpp / Music 120 / Lecture 2 // Loops a sound sample file (arg. #1) at certain frequency (arg. #2 [Hz]) to DAC // for a given duration (arg. #3 [s]) // // Mac OS X with StkX: // g++ -g -o ex5 ex5.cpp -framework StkX -D__STKX__ // // CCRMA Linux machines: // g++ -g -o ex5 ex5.cpp -I/usr/include/stk -lstk -lasound -ljack // // Usage: ./ex5 input_rawfile frequency duration // Example: ./ex5 sinewave.raw 440.0 2.0 // // Created by Woon Seung Yeo on Thu, 28 Sep 2006 01:52:42 -0700. // Copyright 2006 CCRMA, Stanford University. All rights reserved. #ifdef __STKX__ #include #else #include "WaveLoop.h" #include "RtWvOut.h" #endif int main (int argc, char* const argv[]) { char* waveInName = argv[1]; float frequency = atof( argv[2] ); float length = atof ( argv[3] ); Stk::setSampleRate( 44100.0 ); WaveLoop input; input.openFile( Stk::rawwavePath() + waveInName, true ); input.setFrequency( frequency ); RtWvOut dac; // RtWvOut: realtime output to DAC for ( int i=0; i<(44100*length); i++ ) dac.tick( input.tick() ); input.closeFile(); return 0; }