The Jim Patchell Windows Programming Page
First Posted January 1, 2005
 Updated March 9, 2005

Overlapped RS232 Programming
January 1, 2005
    If you have ever tried to write a program that accessed the comm ports under Win32, you have probably been overwhelmed by the large number of convoluted functions you have to deal with in order to do this.  It is posible to open up the RS232 port on Non-overlapped mode, however, there are several problems with doing this, and if you have done it, you may have run into them.  By using the overlapped mode, the comm ports do work pretty much as you would expect, although, still not, in my opinion, perfectly.  Of course, there are probably still some features I don't know about that would even cure these problems.

    What you will find here is a zip file of a skeleton program that opens up an RS232 port and provides functions for reading and writing to the port.

    Now, one of the problems still with using the Overlapped mode is that you need to have a thread that reads the characters that come back into the PC.  In the code, you will find this in a function called WorkerThread.  Yeah, not exactly an original name, but what the heck.  This worker thread is pretty simple.  It reads the character in and prints it into a static text box in the main dialog.  Now in a real program you will most likely have some sort of parser, be it simple or complex, that will look for messages in the data coming back.  Once you have located your messages you can do several things.  You can act on them directly, or you can send a notification back to the main dialog box by using PostMessage and sending user defined messages, just like I did for the message that notifies the main dialog box that the thread has stopped.

    As of January 1, 2005, I have not actually tested this code, although, most of it has been used before (that is no garentee).  Still for the time being, it should give you a good idea of how to proceed.

    Source Code for Overlapped RS232

A Simple Soft Synth for MicroSquish Window
March 9, 2005
    This is a very simple softsynth that I did for running under Microsoft Windows.  It should run with Windows98, Windows2000, Windows XP and Windows ME.  I have only tried it on Windows XP running on a 2GHz Pentium.  There is a chance a slower computer could sound strange.  So, what you will find here is the source code and an executable for a very simple program that compiles, hopefully, with Microsoft Visual C++ 6.0.  I cannot predict what it will do with other versions of the compiler.

    There is not a whole lot that I can think of to say about this program.  Basically, I open up an audio out channel and set up two buffers.  The buffers are then ping-ponged as they empty out.  There is a synth engine routine that is called that fills the buffers up with data when a buffer is ready.

    Oh, yes, there is a simple little sequencer that plays a couple of little tunes.

    The modules that I implemented are a VCO, Multimode VCF, VCA, and a simple envelope generator.

    Source Code for Soft Synth Program