You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
926B

  1. // foursine.cpp STK tutorial program
  2. #include "SineWave.h"
  3. #include "FileWvOut.h"
  4. #include <cstdlib>
  5. using namespace stk;
  6. int main()
  7. {
  8. // Set the global sample rate before creating class instances.
  9. Stk::setSampleRate( 44100.0 );
  10. int i;
  11. FileWvOut output;
  12. SineWave inputs[4];
  13. // Set the sine wave frequencies.
  14. for ( i=0; i<4; i++ )
  15. inputs[i].setFrequency( 220.0 * (i+1) );
  16. // Define and open a 16-bit, four-channel AIFF formatted output file
  17. try {
  18. output.openFile( "foursine.aif", 4, FileWrite::FILE_AIF, Stk::STK_SINT16 );
  19. }
  20. catch (StkError &) {
  21. exit( 1 );
  22. }
  23. // Write two seconds of four sines to the output file
  24. StkFrames frames( 88200, 4 );
  25. for ( i=0; i<4; i++ )
  26. inputs[i].tick( frames, i );
  27. output.tick( frames );
  28. // Now write the first sine to all four channels for two seconds
  29. for ( i=0; i<88200; i++ ) {
  30. output.tick( inputs[0].tick() );
  31. }
  32. return 0;
  33. }