Happy New Year, Jucy people!
I’m a c++ noob moderately competent in PHP/AS3, aiming to build a drum machine (very much like Bram Bos’ Hammerhead).
I thought the first thing I should do was build a metronome that plays a note on a sampling synth every 500ms (120bpm)
So far I have…
… three basic classes >> MainComponent, Timer, Synth.
… pulled apart the juce demo, and made a Synth class which triggers a *.wav
synth->SamplerSound->AudioFormatReader->external *.wav
… built a Timerthread, set with top priority, which uses Time::waitForMillisecondCounter() to trigger every 500ms. This class then ActionBroadcasts out to the Main Component
… the Main Component ActionListens out for the Timer, and then in the callback has a noteOn/Off call to the Synth (and has the buttons/keyboard/Audio IO settings etc)
It all kinda works: it all triggers, and the tempo is rightish.
I used a closed hat sample, ran it against Rebirth, and there was a varying phase each time it triggered. DBG(String(Time::getMillisecondCounterHiRes())) at the noteOn point showed that there was a 10~12ms variance in timing. The tempo wasn’t slipping/drifting, it was just triggered up early/late
Maybe I am being pedantic, but I might as well get this much sorted before I continue. is my approach wrong? I tried a different approach with loading a wav into a TransportAudioSource, with similar results.
In short: help!