It can be really easy to get stuck in the cycle of “I want to do this, but I should really do this first, and that means getting back to this other thing, and…” and somehow never getting anything done. So sometimes you just have to throw your hands in the air, pick a fresh topic, delete all the pending comments you meant to deal with (sorry, folks!) and do something. Do anything! In that spirit, I’ve hooked my 6502 breadboard computer back up, hacked together a very quick and dirty audio generator, and taught a pile of sand to sing a Christmas carol:
This was all done in a rush to get it done before the holiday, so the result is even more of a rat’s nest of wires than the rest of the P:65 computer. I’m looking forward to cleaning that up a bit next week, and hopefully I’ll be able to write a more detailed post about how it works. There are some complications about how the “sound card” interfaces with the computer that I really ought to write down before I forget them!
Some credit where due: I got the general idea of how to do the audio from James Sharman’s Audio From Scratch Youtube series. Definitely check out his videos – he’s built an entire CPU from 7400-series logic, and he does an excellent job explaining the process. My audio generator isn’t exactly the same as his because I had to cobble it together from parts I had on hand, but it’s very much the same principle.
I also followed his idea of translating a MIDI file into code the computer could execute. In my case, I wrote a simple C++ program in visual studio that read a .mid file and output a block of C instructions. I then copied those instructions into a sound player program for the P:65 that I built with the CC65 compiler. Surprisingly, the entire software side came together in just a few hours, including learning how to interpret the MIDI file format! By the way, if you want the particular Jingle Bells MIDI file I used, I found it here.