Created
October 12, 2020 22:02
-
-
Save kybr/7cc717a3c763d3402e4c605ceca46d31 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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