YM playback on the YMZ284
After building the YMZ284 sound board for my MC3 computer I had only really used a fraction of the YMZ284's possible potential. This chip could do so much more. It's older sibling the YM2149, with identical register structure, was actually used in the Atari ST among several other systems. It so happens that the YM music/chiptune file format from the Atari ST, originally designed by Arnaud Carré, is really interesting. It does not contain any machine code like a SID file. An YM file is simply created by sampling the YM registers in, for example, an Atari ST. You can read more about the YM file format on Arnaud's web page at leonard.oxg.free.fr where he also have utilities and source code for download. There are quite a lot of music available in YM format. Mostly from the Atari ST but music from other systems containing YM compatible sound chips are also quite common. An YM file have the registers saved in a de-interleaved manner to make it possible to efficiently compress the file. I created a small C program to convert an YM file to an interleaved raw dump of the 14 YM registers. The 14 registers are written 14 bytes at a time to the new file. Each group of registers are called a frame and each frame is updated usually at a rate of 50 Hz, thus 1 second of music corresponds to 14*50=700 bytes of data. Source code for my conversion program: ymextract.c (on request, here are the binaries: ymextract ymextract_x64) My ymextract program does not contain an LHA/LZH extractor so the YM files need to be unpacked before conversion (lha -x myfile.ym). Playing back the generated chunk of data is actually simple. Just read the data 14 bytes at a time and write the 14 bytes to the respective YM registers, then repeat the process at 50 Hz interval until end of data. The envelope register is special since it, when written, resets the current active envelope. Therefore the YM file format specifies a special case for that register. When the stored value is $FF the register should not be written to the YM chip. This requires just a simple compare instruction during playback. One hardware change I had to do compared to my original design was to change the clock frequency from 2.000 MHz to 4.000 Mhz since the YM2149 in the Atari ST has a different clock divider than my YMZ284. Good thing I used a configurable oscillator. The EXO3 I'm using can provide both 2.000 MHz and 4.000 Mhz and I added a jumper for easy frequency selection. Update 2014-06-12 After some careful listening and comparisons I noticed that the increase from 2 MHz to 4 MHz clock on the YMZ284 also increased the distortion on the output signal. This may or may not be suitable in all cases. If you want a chip with some attitude then run it at 4 MHz, but if clean audio is important then keep the frequency at 2 MHz. For playback of Atari ST YM files at 2 MHz simply right shift all frequency dependent registers one step and you are back in tune! Below are some samples from my YMZ284 board playing back converted YM files on my MC3 system. I have published all the steps in the file conversion from the original YM file to an audio recording of the end result. - Cybernoid - Original YM > Unpacked YM > Register dump > Audio recording - Cybernoid II - Original YM > Unpacked YM > Register dump > Audio recording - Stormlord - Original YM > Unpacked YM > Register dump > Audio recording - Delta - Original YM > Unpacked YM > Register dump > Audio recording - Warhawk - Original YM > Unpacked YM > Register dump > Audio recording - Sidewinder - Original YM > Unpacked YM > Register dump > Audio recording - Outrun - Original YM > Unpacked YM > Register dump > Audio recording Original YM files were downloaded from the Modland archive. I think it sounds pretty good. This technique is simple but requires a lot of memory. This is fine for browsing through chiptunes but for a real game or demo I definitely think native non-sampled music should be used if possible.
by dk 2014-11-15 08:19 UTC
please, share compiled ymextract.


by daniel 2014-11-20 10:45 UTC
Hi dk! Binaries added. Keep in mind that I run only Linux. I'm sorry to say that I currently have no way of providing Windows binaries.


by dk 2014-12-02 09:49 UTC
hi, daniel! thank you for reply. unfortunately, I am not Linux user ;(


by Elfantau 2017-08-13 16:13 UTC
Hello, I have a very simple question for you : where is the player for your MC3 ? I have only found your Linux tool to convert YM (BIN after the LHA uncompress) to REG, but no tool to play the REG file with your MC3. In advance, many thanks for your answer. Best regards, El Fantau


Write a comment

Name or handle

E-mail (optional and not visible to others)

Comment


Code from above