CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: utz on July 29, 2015, 12:34:32 PM

Title: rawp music routine for TI-82/83/83+/84+
Post by: utz on July 29, 2015, 12:34:32 PM
As a byproduct of stuff I'm currently working on, I ported my rawp sound engine from ZX Spectrum to TI Z80. Thanks to the faster CPU, it sounds much, much better than the original Speccy version. Unfortunately the routine is fairly large and does not use interrupts, so it is not too terribly useful for games. Maybe you'll find it useful for the 1-bit forum competition (https://codewalr.us/index.php?topic=606.0) though ;)

Anyway, for those of you who aren't aware of the original engine, here's the feature list:

- 2 tone channels
- 13 different waveforms
- limited volume control
- 1 interrupting hihat sound
- per-step tempo control

For your convenience, the routine comes with an XM (https://en.wikipedia.org/wiki/XM_%28file_format%29) converter. So you can compose your music in something like Milkytracker (http://www.milkytracker.org/?download) and then compile it using the provided scripts (Win/*nix). Note that this requires Perl (https://www.perl.org/get.html) to be installed on your computer.

download (http://irrlichtproject.de/downloads/rawp-ti.zip)
sound example (https://www.dropbox.com/s/pdjcsokptpepb6x/rawp-ti-test.mp3?dl=1)
Title: Re: rawp music routine for TI-82/83/83+/84+
Post by: Snektron on July 29, 2015, 03:32:21 PM
Cool. Is the source included? I'd love to get an inner knowlege of sound engines
Title: Re: rawp music routine for TI-82/83/83+/84+
Post by: utz on July 29, 2015, 11:30:03 PM
Yes, source is included. It's even annotated to some extend, but overall this one is rather tricky to understand. Basically what happens here is this: There are some specially crafted samples to create the waveforms. Each sample is 256 bytes, with each byte representing an output state (on or off). Groups of 4 bytes are combined and interpreted as a volume level by the player. Consequently, there are 5 OUT commands per channel (4 levels + silence). So you can think of the samples as a sort of PCM format, but instead of packing 2⁸ volume levels in one byte or 2¹⁶ in a word, you pack 5 volume levels in 4 bytes. This is done so the player can read the sample data as fast as possible.

Mind you, the engine was optimized for a 3,5 MHz machine and is now running in 6 MHz, so there is room for improvements. Especially if you'd think about targetting 15 MHz.
Title: Re: rawp music routine for TI-82/83/83+/84+
Post by: Dream of Omnimaga on August 10, 2015, 03:23:26 AM
I replied to this but here's a repost since my post was lost: I loved how this sounded like. It seemed like MIDI but in lower sample rate. It would definitively be interesting to hear music made with this :)