Post

Coding 4 Fun Drum Machine (in VB.NET)

The Coding 4 Fun - Building a Drum Machine with DirectSound article that Duncan Mackenzie brought to my attention looked pretty interesting, however, it doesn’t have a VB.NET version.  Although the C# version runs well enough and you can use it as a resource to build your own ideas from, I just couldn’t leave well enough alone.  So, last night, I converted it to VB.NET.  Ran into a few glitches due to the little differences C# and VB.NET have in regards to arrays, division operator and C# ++ operator.  I don’t know if anyone else is interested in the VB.NET source, so if you are, leave a comment and I’ll see what I can do.

Also, this is the first project that I’ve used the C#->VB.NET conversion tool that comes with the VB.NET Resource Kit.  It turns out its and updated version of the one I downloaded over a year ago.  They’ve improved the conversion process a bit; however, there are still enough gotchas that you must know C# in order to complete a conversion.

UPDATE: I made a few more changes to the sample.  Modified it so that the not so representative progress bar is replaced by another beat control and increased the timer resolution so that you can see approximately what beat is taking place as the mix progresses.  I also removed the play and stop from the menu and added a Start/Stop button with the accelerator key of ALT+S.  Finally, added visual styles… after all, everyone is running XP or newer, aren’t they?  Here’s a screen shot:

Drum Machine

UPDATE: Yet another update, I’ve zipped up the project and you can download it here. In order to play with this, you will need to make sure you have the DirectX 9.0 SDK installed.

This post is licensed under CC BY 4.0 by the author.