I’m making a drum machine at the moment in C#. Regular playing works as expected (the user makes patterns, selects BPM and press play; the beat is determined by a timer that is set to [b:1as79g6q]60 / BPM[/b:1as79g6q]).
I’ve been experimenting with WAVWRITER for output (with INIT_NORMAL), and it works although there’s always some delay before the first beat is played (naturally since the WAVWRITER starts writing immediately.
I’m trying to switch to WAVWRITER_NRT (and INIT_STREAM_FROM_UPDATE), by I’m having trouble finding the right delay between calls to [b:1as79g6q]system::update()[/b:1as79g6q]. I’ve tried to sleep at different intervals (10 ms, 10.66 ms, 20 ms, 21.33 ms, and so on), but the resulting file is always played at a faster or slower beat (note: it’s not the pitch of the sounds that’s altered, it’s just that the [i:1as79g6q]beat[/i:1as79g6q] is faster/slower, i.e. a snare playes earlier than it should).
Playback rate is 44100 Hz, 16 bits, stereo (with buffersize 1024; I tried [b:1as79g6q](44100 / 1024) * 1000[/b:1as79g6q] for delay, but it’s still to fast).
- NisseBosseLasse asked 8 years ago
- You must login to post comments
Please login first to submit.