Hey guys,
Can you take a look at my process block. I think thanks to Eyal I finally have AudioPlayHead working. Is there anything that I should do differently?
1st: DBG is a blocking command (it needs to lock until it is allowed to write to the console), so never call DBG from the audio thread (i.e. in processBlock()). Sometimes it is useful if you have no idea what’s going on, but expect the audio to be distorted then.
2nd: float targetSample = beatNum + beatsPerSample; never changes, so there is no point calculating it every time in the sample loop
3rd: leftChannel[sample] *= 0; is the same like setting it to zero, so why multiplying?
4th: leftChannel[sample] *= 1.0f; multiplying with 1.0f is a NOP, why doing it at all?
5th: float beatsPerSample = BPM / mSampleRate * 60.0f; careful with the order of * and /, they are not interchangeable. Better use brackets to make it clear, I as reader wouldn’t know by heart if it goes left to right or right to left without reading it up, so even if it’s correct, better write it explicitly
About the ppq, does it deliver what you expect? TBH, I haven’t played with that part yet, seems like I should check it out
I don’t know, what you plan to do.
If you want to create a metronome, you want to fill the space starting at a full beat with sound for n samples, vs. your code simply set’s zeroes… so I doubt you will hear anything here…