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.

45 lines
929B

  1. #include "../src/KSSynth.hpp"
  2. #include "standalone_helpers.hpp"
  3. #include <iostream>
  4. struct KSGen : StepHandler
  5. {
  6. KSSynth s;
  7. KSGen() : s( -0.9, 0.9, 44100 ) { }
  8. virtual int dostep( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
  9. double streamTime, RtAudioStreamStatus status ) override
  10. {
  11. unsigned int i, j;
  12. double *buffer = (double *) outputBuffer;
  13. for ( i=0; i<nBufferFrames; i++ ) {
  14. *buffer++ = s.step();
  15. }
  16. if( ! s.active )
  17. return 1;
  18. return 0;
  19. }
  20. };
  21. int main( int argc, char **argv )
  22. {
  23. KSGen gen;
  24. std::cout << "packets " << gen.s.numInitPackets() << "\n";
  25. gen.s.filtAtten = 3.0;
  26. gen.s.filtParamA = 0.3;
  27. gen.s.packet = KSSynth::RANDOM;
  28. float freq = 440;
  29. for( int i=0; i<=12; ++i )
  30. {
  31. float mul = pow( 2.0, i / 12.0f );
  32. gen.s.trigger( freq * mul );
  33. gen.playAudioUntilStepsDone();
  34. }
  35. }