Timer, Triggering audio


#1

how come i cant use type Timer for a call back function?..I have a play button to launch audio but im not sure how to get a timer to start?


#2

How about buttonClicked > startTimer() ?


#3

Because you don’t understand C++ yet? :wink: You’ve correctly derived your class from Timer, but you need to implement the timerCallback function, per the documentation:

virtual void timerCallback ()=0

so, in your class declaration, replace Timer timerCallback; with void timerCallback() override; and implement that function to do what you want on the timer. As well, Subaru pointed out, you will need to call startTimer as well.


#4

If your plan is to sequence sounds musically with a Timer : just don’t. It’s not going to work reliably. To properly do it, you will need to count time in samples yourself in your audio processing function and so on. (Also remember that if the played sounds would overlap, you will need to implement the polyphony too.)

For simple testing purposes, a Timer will work, but like was suggested above, don’t have a Timer as a member variable, it’s not designed to work like that.