Skip to content

Instantly share code, notes, and snippets.

@kybr
Created October 12, 2020 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kybr/7cc717a3c763d3402e4c605ceca46d31 to your computer and use it in GitHub Desktop.
Save kybr/7cc717a3c763d3402e4c605ceca46d31 to your computer and use it in GitHub Desktop.
/* Gamma - Generic processing library
See COPYRIGHT file for authors and license information
Example: Periodic Timing
Author: Lance Putnam, 2015
Description:
This demonstrates how to use a phase accumulator as a periodic timer to trigger
events.
*/
#include "../AudioApp.h"
#include "Gamma/Oscillator.h"
using namespace gam;
class MyApp : public AudioApp{
public:
Accum<> tmr; // Phase accumulator
void onAudio(AudioIOData& io){
// Set period of timer, in seconds
tmr.period(1);
while(io()){
float s = 0;
// Accum's function operator returns true after each period
if(tmr()){
s = 0.2;
std::cout << "Click!\n";
}
io.out(0) = io.out(1) = s;
}
}
};
int main(){
MyApp().start();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment