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.

35 lines
773B

  1. /*
  2. ** Just showing how to use the standalone helpers to make a mono generator which gets
  3. ** punped to default output quickly and easily
  4. */
  5. #include "standalone_helpers.hpp"
  6. #include <iostream>
  7. #include <cstdlib>
  8. struct SawGen : StepHandler
  9. {
  10. double lastValue;
  11. SawGen() : lastValue( 0 ) {}
  12. virtual int dostep( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
  13. double streamTime, RtAudioStreamStatus status ) override
  14. {
  15. unsigned int i, j;
  16. double *buffer = (double *) outputBuffer;
  17. for ( i=0; i<nBufferFrames; i++ ) {
  18. *buffer++ = lastValue;
  19. lastValue += 0.015;
  20. if ( lastValue >= 1.0 ) lastValue -= 2.0;
  21. }
  22. return 0;
  23. }
  24. };
  25. int main()
  26. {
  27. SawGen sg;
  28. sg.playAudioUntilEnterPressed();
  29. }