Drum Machine code snippet enjoy - color coded timing and volume levels.
This program works on XP machines but Vista users will need to copy DX8VB.DLL from an XP system into the Windows\System folder of Vista, and register it using regsvr32.
Last edited by technorobbo; May 4th, 2009 at 07:18 PM.
1) A longer "metronome(?)" region, so the "song" can be longer
I'm designing it to be a pattern based Drum Machine where the patterns are then arranged in to a song.
Originally Posted by vbfbryce
2) The ability to make it loop automatically
That would be Song Mode
Originally Posted by vbfbryce
3) The ability to have it stop at the end of the "notes" (not play all the way through #96, or whatever the end of the available area is...)
96 ticks is based on the lowest common denominator for a 16th note and a triplet 16th note. 4/4 time obvoiusly other time signature exist but most pop falls into these 2 categories. If you a Rush, Alex Van Halen, SoundGarden or Dave Brubeck then you crave non-pop signatures. It can be implemented down the line but right now I'm concentrating on Song Mode.
Getting better and better! , but this one (April 30th) uses a lot of CPU, older versions didn't use any or wasn't even noticeable.
The other one used a timer control but the millisecond resolution led to spotty beats per minute adjustments 120 BPM (and many others) wasn't actually achieveable (119 or 121) due to rounding. I had to use the microsecond resolution to achieve fine BPM adjustment. Since there are no interrupt driven calls to resolve the issue I had to resort to a timing loop and QueryPerformanceCounter. I kept the timer for the graphics since timing there wasn't totally critical.
First let me say that the next version due to post I reduced the cpu usage by a novel combination of timer and QueryPerformanceCounter. The next version will include song mode BTW. Now to answer your question.
QueryPerformanceCounter is current value of the high-resolution performance counter. The high performance counter has a resolution that is unique to your machines speed and processor. QueryPerformanceFrequency gets you how many ticks there are per second in your counter. I subdivide this so I get the 12 tick per quarter note resolution depending on the tempo you choose.
copymemory's role is necessary because both these functions return a 64 bit number that vb cant handle. to make it work properly it gets copied directly into a currency data type so it doesn't get translated by vb (vb would not make use of the decimal portion so you won't get a true 64 bit number).
Last edited by technorobbo; May 2nd, 2009 at 10:10 AM.
Song Mode Posted as well as a song mode Demo. Timing is no longer a loop it uses QueryPerformanceCounter TimeStamps to reduce CPU usage. (Edgemeal -Thanks for keeping me thinking about it), by Setting the timer at a high resolution (5ms) I could check the timerstamp with out using a loop. Much smoother performance.