- 1-bit sound engine for 83+/84+ series
- 14 Jun 2020 07:38:11 pm
- Last edited by fghsgh on 25 Sep 2020 11:34:51 am; edited 2 times in total
I've had 90% of this lying around for a few months and decided to finally finish it.
Its main features are:
Its cons are:
Here are a few previews of the sound:
1bit.wav (77 bytes of data) (recorded at 192 kHz samplerate)
lifecaps.mp3 (173 bytes of data) (resampled to 22050 Hz to get rid of aliasing artifacts that happened because I was recording it at 44100 Hz)
The binary data for the second one of these was generated by a script I made that takes care of the quirks of the format for you. This would make it possible to create longer songs (as long as they don't surpass the 32 KiB maximum filesize this thing has).
I plan to release this in a few weeks, probably. However, I also want to create a challenge for you all in reverse-engineering it, so I will probably not release the source code yet.
Here is the binary data of lifecaps.mp3, try to figure out the format! (shouldn't be too hard because I aligned it already)
Code:
EDIT: For posterity, I already explained the format on the Discord channel #z80-ez80.
EDIT: I also already shared the program binary and source in chat. However, although the source is mostly correct, it is a slightly newer version (that is also broken by the way), because I overwrote it. It's mostly the same though, and combining a disassembly of the binary and the source I did include should be good enough.
EDIT: I recovered the original source and added more comments!
Its main features are:
- 4 square wave channels
- 16-bit frequency control
- 8-bit duty cycle control
- L/R mask control
- jumps inside the song data
- support for arbitrary code execution to facilitate complex jump structures within the song
- ~17 kHz effective sample rate (depends on CPU frequency)
- ~68 Hz refresh rate (depends on CPU frequency)
- 0cc delay when reading the next note
- reading song data directly from the archive
- the entire player is 496 bytes (EDIT: 512 bytes after debugging and a few nice features like pressing ON to interrupt playback)
Its cons are:
- doesn't run on regular 83+
- no noise channel
- file format is pretty big at 6 bytes per note
- channels are not separated inside the song data meaning you can't have one channel repeating a short bit and another channel doing a longer bit, although the arbitrary code execution it supports could help by generating song data on the fly
- there is no GUI, right now you just store the name of the appvar you want to play into Ans
Here are a few previews of the sound:
1bit.wav (77 bytes of data) (recorded at 192 kHz samplerate)
lifecaps.mp3 (173 bytes of data) (resampled to 22050 Hz to get rid of aliasing artifacts that happened because I was recording it at 44100 Hz)
The binary data for the second one of these was generated by a script I made that takes care of the quirks of the format for you. This would make it possible to create longer songs (as long as they don't surpass the 32 KiB maximum filesize this thing has).
I plan to release this in a few weeks, probably. However, I also want to create a challenge for you all in reverse-engineering it, so I will probably not release the source code yet.
Here is the binary data of lifecaps.mp3, try to figure out the format! (shouldn't be too hard because I aligned it already)
Code:
00000000: 4602 80 03 0012 F.....
00000006: 0803 80 03 0024 .....$
0000000c: 8401 4c 03 0036 ..L..6
00000012: c200 4c 03 0036 ..L..6
00000018: d203 80 03 0048 .....H
0000001e: 8b04 80 03 0012 ......
00000024: dd02 80 03 0012 ......
0000002a: e901 4c 03 0036 ..L..6
00000030: f400 4c 03 0036 ..L..6
00000036: 8b04 80 03 0024 .....$
0000003c: b905 80 03 0012 ......
00000042: 1905 80 03 0012 ......
00000048: 4a04 80 03 0024 J....$
0000004e: 2502 4c 03 0036 %.L..6
00000054: 1201 4c 03 0036 ..L..6
0000005a: 6703 80 03 0024 g....$
00000060: 8d02 80 03 0012 ......
00000066: 2502 80 03 0012 %.....
0000006c: dd02 80 03 0024 .....$
00000072: 8d02 4c 03 0036 ..L..6
00000078: 4601 4c 03 0036 F.L..6
0000007e: 6703 80 03 0024 g....$
00000084: 4a04 80 03 0012 J.....
0000008a: dd02 80 03 006c .....l
00000090: d203 80 03 006c .....l
00000096: 6802 4c 03 006c h.L..l
0000009c: 3401 4c 03 006c 4.L..l
000000a2: 0000 00 00 4100 0000 ....A...
000000aa: c397dd ...
EDIT: For posterity, I already explained the format on the Discord channel #z80-ez80.
EDIT: I also already shared the program binary and source in chat. However, although the source is mostly correct, it is a slightly newer version (that is also broken by the way), because I overwrote it. It's mostly the same though, and combining a disassembly of the binary and the source I did include should be good enough.
EDIT: I recovered the original source and added more comments!