-
February 21st, 2014, 07:55 PM
#1
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.
-
February 23rd, 2014, 02:00 PM
#2
Re: Accurate timer needed for drum sequencer
-
February 24th, 2014, 10:14 AM
#3
Re: Accurate timer needed for drum sequencer
Many thanks. I've found one and got it working.
-
February 26th, 2014, 04:35 AM
#4
Re: Accurate timer needed for drum sequencer
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....
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
February 26th, 2014, 04:58 AM
#5
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...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|