Wednesday, January 23, 2013

Play It Again

The gears of progress creak forward once again!  There is nothing very monumental to report, but at least now my CoCo sings when you work the controls...

Hip To Be Square

The CoCo actually has two potential sources of audio output.  The higher quality output comes from the 6-bit DAC, which is capable of reproducing reasonably complex waveforms with the help of the CPU feeding it wave samples.  This isn't terribly difficult to use, but it isn't terribly simple either.  Plus, sharing the DAC for reading the controller further complicates its usage.

The other audio output on the CoCo is a 1-bit digital output used for generating square waves.  This sort of output is very simple to use, and was quite common in devices of the same era as the CoCo.  The tonal quality produced by this output isn't particularly pure or melodic, but it does have a certain richness to it.  Plus, it happens to be the same technique used by the original Simon hardware.

Time Critical

Audio tones vary according to their frequency.  The key to generating different frequencies is timing.  The square wave output of the CoCo needs to be switched at intervals that are timed reasonably precisely in order to generate consistently accurate tones.  But how?

Without external hardware, I can only think of three ways to do accurate timing on a CoCo:  cycle counting; vertical sync; and horizontal sync.  Instruction cycle counting is reliable, but it is difficult to apply to dynamic changes (e.g. playing different tones).  Vertical sync occurs 60 times per second, only enabling generation of tones up to 30 Hz.  That leaves leaves horizontal sync.

Horizontal sync on the CoCo fires 15720 times per second, enabling generation of tones up to 7860 Hz.  While the audiophiles will be horrified at such a low sample rate, the truth is that this covers a very useful range of tones.  Most importantly, it more than covers the range of tones required to play Simon.

Bugle Call

Legend has it that the creator of Simon sought long and hard for a set of tones that would always sound "in tune" no matter the order in which they were played.  The tones played by Simon are said to have been inspired by the notes of a bugle.  That may be so, but mimicking bugle tones doesn't quite match my vintage Simon game.

Luckily, some kind soul has gone through the trouble of reverse engineering the original Simon game and (more importantly) publishing that information for all to see.  With that info I was easily able to tune my implementation to more closely match the original.  That said, the bugle notes do sound a bit better -- I'm not sure which set of tones I will ultimately use!


Time is ticking, and I only have another week to finish-up.  Hopefully I can find some time this weekend to implement the game logic, etc.  To find-out how that goes, you'll have to stay tuned... :-)

No comments:

Post a Comment