Accurate timer needed for drum sequencer
Hi. I am developing a drum sequencer using VB.net but having trouble with the accuracy of the timing. I've tried the Forms timer, the System timer and I'm now using the Threading version, which I'm timing against a Stopwatch. The only other option I've found is the QueryPerformanceCounter, but that would require polling, which would be a nightmare. At 120 beats per minute, there are 125 milliseconds between beats. This seems to work out most of the time, then there are a couple at 140, which I don't understand. I'm completely new to multithreading, although I've learnt a lot from my mistakes over the last month or so. If anyone knows of a way of getting super-accurate timing, but in a Timer-type environment, using events, please let met know. Or some way of conditionally increasing the priority of the Threading.Timer.
Re: Accurate timer needed for drum sequencer
Re: Accurate timer needed for drum sequencer
Many thanks. I've found one and got it working.
Re: Accurate timer needed for drum sequencer
Quote:
Originally Posted by
Firebeard
At 120 beats per minute, there are 125 milliseconds between beats. This seems to work out most of the time, then there are a couple at 140, which I don't understand.
according to my maths... 120 BPM = 500ms between beats...at 125ms - 140ms your getting between 428 and 480BPM ....
Just remember that most timers are accurate only to ~16 ms and some are as bad as 55ms....
Re: Accurate timer needed for drum sequencer
Sorry, I didn't explain it very well. My system is based around a 2 bar rhythm / arpeggiator pattern made up of 16th notes. It does work out OK at 125ms. I found a Media Timer - I went through the three standard ones (form, system and threading) and they were awful. The one I'm using now I'm testing against a StopWatch and it seems dead on. It even allows for ad hoc changes of tempo, rather than pausing for ages like the form and system timers did. I think I'm at a stage now where I can confirm that any lags in are my code rather than a fundamental infrastructure issue. Unless the stopwatch and timer are consistently inaccurate, but I'm not even going to go there... :)