YM File format ~~~~~~~~~~~~~~ LEGAL NOTES: The YM file format was created for ST-Sound by Arnaud Carré. The file format is freeware, so everybody can use, read or produce YM files. YM files are specific files to be used with ST-Sound or any ST-Sound based player. You can find some ".ym" files for the Amiga but both formats are really different. If you are looking for a great collection of real ST-Sound YM file, visit the biggest YM database on the internet. The YM file format is a "multi format". Basically YM files are made to create classic ATARI chip tunes, but YM can produce strange and custom music too. ________________________________________________________________________________ YM Header type Music type ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ YM3 to YM6 Classic YM-2149 chip tunes. Different formats are made to support some "extended" chip tune effects like Digidrum, SID-Voice, etc. -------------------------------------------------------------------------------- MIX Sample remix. Many ATARI demos feature music wich is just sample remix. (e.g. Union Demo "1 Mb Beat Dis Screen" by The Carebears) -------------------------------------------------------------------------------- YMT Universal YM Tracker. This is a universal tracker format were the instruments use real samples, no YM-2149 tone synthesis. Use it to replay all custom soundtracker music from ATARI, AMIGA etc. ________________________________________________________________________________ YM6 Chiptune format ~~~~~~~~~~~~~~~~~~~ As you probably know, YM is only a YM2149 Chip emulator, not a true MC68000 emula- tor. YM-Files do not contain any 68000 code routine. A music-file is composed of YM2149 register dumps generated by the original play-routine (from ATARI, AMSTRAD, SPECTRUM and all kind of machines with an Yamaha YM2149 sound chip). IMPORTANT: YM3 through YM5 are now considered old formats. If you want information about them just write me. Following information is YM6 specific only! YM6 is just a register dump file. In chip music, the sound registers are usually updated once per frame. A frame is generally updated at 50Hz. A YM6 file frame is a 16 bytes long frame. Imagine you have a 6 minutes song, in wich registers are updated at 50Hz (let's call this the "frame rate" now), you need 288000 bytes (282Kb) to store all YM registers. Quite big for a soundchip format, don't you agree? Yes, but data is stored "interleaved" in the file, then compressed with a good packer. If you look at all the YM files on the internet, you'll notice that the filesize ranges generally from 1 to 10Kb. ABOUT THE PACKER: YM files can be stored in two ways, compressed or uncompressed. To compress an YM file you just have to use the freeware packer "LHA" by Haruyazu Yoshizaki. Almost all YM files spreaded around the web are compressed. If you want to look inside a compressed YM file, just use the command: "lha e .ym" WARNING: The ST-Sound player only supports LZH files with header 0, so don't forget to use the "-h0" flag when compressing a YM file you just have created! ABOUT THE YM DATA FRAME: A YM data frame is composed of 16 bytes. 14 first bytes contain YM2149 data registers, the two last ones contain extended information. To improve compression ratio, a YM data frame can be interleaved. Let's call the 16 bytes of a frame r0,r1,r2,...,r15. A non-interleaved YM file contains r0,r1,r2....,r15 of frame 0, then r0,r1,r2...,r15 of frame 1 and so on. This is quite easy to understand but not easy to compress. :-) That's why there is an interleaved format which contains all r0 for all frames, then all r1 for all frame on so on. Almost all YM files spreaded on the web are interleaved files. ____________________________________________________________ Type used in YM File ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ BYTE unsigned 8 bits integer ------------------------------------------------------------ WORD unsigned 16 bits integer (Big Endian format) ------------------------------------------------------------ LWORD unsigned 32 bits integer (Big Endian format) ------------------------------------------------------------ STRING[n] Ascci text string of n characters ------------------------------------------------------------ NT-String Null terminated string ____________________________________________________________ _________________________________________________________________________________________ YM6 File header structure ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ Offset Type Size Description ----------------------------------------------------------------------------------------- 0 LWORD 4 File ID "YM6!" 4 STRING[8] 8 Check string "LeOnArD!" 12 LWORD 4 Nb of frame in the file 16 LWORD 4 Song attributes 20 WORD 2 Nb of digidrum samples in file (can be 0) 22 LWORD 4 YM master clock implementation in Hz. (ex:2000000 for ATARI-ST version, 1773400 for ZX-SPECTRUM) 26 WORD 2 Original player frame in Hz (traditionnaly 50) 28 LWORD 4 Loop frame (traditionnaly 0 to loop at the beginning) 32 WORD 2 Size, in bytes, of future additionnal data. You have to skip these bytes. (always 0 for the moment) _________________________________________________________________________________________ Then for each digidrum (nothing if no digidrum) ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ 34 LWORD 4 Sample size 38 BYTES n Sample data (8 bits sample) _________________________________________________________________________________________ Then some additional information ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ ? NT-String ? Song name ? NT-String ? Author name ? NT-String ? Song comment ? BYTES ? YM register data bytes (r0,r1,r2....,r15 for each frame). Order depends on "interleaved" bit, takes 16*nbFrame bytes. ? LWORD 4 End ID marker, must be "End!" _________________________________________________________________________________________ _________________________________________________ Frame register detail ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ b7 b6 b5 b4 b3 b2 b1 b0 r0 x x x x x x x x Period voice A r1 x x x x Fine period voice A r2 x x x x x x x x Period voice B r3 x x x x Fine period voice B r4 x x x x x x x x Period voice C r5 x x x x Fine Period voice C r6 x x x x x Noise period r7 x x x x x x Mixer control r8 x x x x x Volume control A r9 x x x x x Volume control B r10 x x x x x Volume control C r11 x x x x x x x x Envelope high period r12 x x x x x x x x Envelope low period r13 x x x x Envelope shape r14 Extended data r15 Extended data _________________________________________________ Almost all ATARI game tunes are very classic chip-tune music, using only the original YM2149 features. These music sounds quite poor but is very simple to generate. For that kind of tune you only have to fill the "x" bits with the original chip value and set all other bits to 0. Extended YM effects ~~~~~~~~~~~~~~~~~~~ The YM6 format supports some ATARI specific tricks to produce complex sound. These tricks will now be called "special effects". YM6 supports 4 special effects, and can start two of these each frame. All these effects use the ATARI software timer interrupts. The ATARI timer routine can be resumed with only two values: The timer predivisor (TP) and the timer count (TC). The ATARI interrupt system has a master clock of 2457600 Hz. The predivisor is a 3bit value wich divides the master clock. Then period is divided by the timer count. As an example, let's say you write 1 in TP and 28 in TC, you obtain a 21492Hz interrupts routine ((2457600/4)/28). ___________________________________________________________ YM timer period coding table ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ Predivisor register Real predivisor value ----------------------------------------------------------- 000 Timer is stopped 001 4 010 10 011 16 100 50 101 64 110 100 111 200 ___________________________________________________________ __________________________________________________________________________________ YM6 special effects ŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻ Effect Description ---------------------------------------------------------------------------------- Digidrum Digidrum is a very little 4bit sample played on a voice. Traditonaly used to add more realistic drums in music, Musicians called it "Digi(t) Drum". ---------------------------------------------------------------------------------- SID-Voice SID-Voice is a great sound trick on the ATARI, because of low CPU consuming and great sound effects. It sounds a bit like C64, that's why musicians call it "SID-Voice". On a real ATARI, SID-Voice uses a CPU interrupt to produce a square tone wich is mixed to the original YM2149 tone. ---------------------------------------------------------------------------------- Sinus-Sid This is bad name for an effect wich is closer to the Digidrum technic than the SID-Voice. Only used by the musician TAO, this is only a little 4bit sample producing a sinus wave. ---------------------------------------------------------------------------------- Sync-Buzzer I think this is one of the coolest special effects, with SID-Voice. It was used first by the musician TAO. Sync-Buzzer uses an external CPU interrupt to write values in the Envelope shape register (YM2149 register 13). As you probably know, writing in r13 sets the new shape waveform AND resets the envelope! So you can produce some very nice sound effects. __________________________________________________________________________________