Tursi Posted June 2, 2022 Share Posted June 2, 2022 The good Captain also wrote me several private messages, so let me repeat what I wrote there about VGM: [I wrote VGM export] Because my toolchain inputs VGM. I don't use other players. https://harmlesslion.com/cgi-bin/showprog.cgi?search=vgm The VGM structure is very basic. You can find the documentation here: https://www.smspower.org/uploads/Music/vgmspec170.txt To convert, open the file. If you don't see the Vgm identifier in the first four bytes, then it is probably compressed with gzip. Use the data at offset 0x34 to find the start of data. You can go ahead and skip the rest of the header if you know it's an SN-based VGM (they support many other chips). Then once in the data stream, just look for 0x50 bytes. This command means "send the next byte to the SN". In the case of my SFX port, it will only output 0x50 command bytes for commands to the sound chip, 0x62 command bytes for end of frame, and a 0x66 command byte to mark the end of the file. 1 Quote Link to comment Share on other sites More sharing options...
Captain Cozmos Posted June 2, 2022 Share Posted June 2, 2022 (edited) Hopefully he will find time to add this. I have been toying around with this editor and have been able to make some headway. You have to adjust for fire because this is a multi system editor. Colecovision...NES... I really wish I had the brains to make a dedicated music editor that outputs ASM Data for the Colecovision. I have Video Tunes for the ADAM but there seems no way to convert the songs into raw data but even that would exclude sound effects. We will just have to wait for Tony Cruise or this fine gentleman to up the fill in the gaps because I am just not a sound guy. I deal with graphics and mediocre assembly language programing. Thanks Tursi Edited June 2, 2022 by Captain Cozmos Quote Link to comment Share on other sites More sharing options...
parkfun101 Posted June 2, 2022 Author Share Posted June 2, 2022 (edited) I found another program that converts vgm files to a txt file. It's called vgm2txt. This seems to get the data. That's half the battle right there. Since the conversion doesn't look as straightforward as I was hoping, I may have to wait on this one and focus on the game maker for Colecovision for now. Edited June 2, 2022 by parkfun101 Quote Link to comment Share on other sites More sharing options...
Tursi Posted June 3, 2022 Share Posted June 3, 2022 I have provided an entire toolchain for processing and converting VGM files... it's true that my player is specific to one purpose, but if you really don't want packed audio, or your needs are simpler, you can still start with the processing tools. Here's a sample sequence: 1) Start with vgm_psg2psg - this will take an SN-centric VGM file, and output four text files - one for each channel, containing one line of text for every frame of audio. It's written that way to be the simplest and easiest to parse format possible. 2) Once you have that, the simplest output format that I support is probably the sound list. So use "psg2soundlist" to convert the files you just created into a binary sound list. The sound list format is literally just a count byte followed by that many bytes of data for the sound chip, followed by a count of how many frames to wait till the next update. 3) Now, the output of that is a binary file, and you want something you can import into your source code. I recommend my own bin2inc tool: http://harmlesslion.com/software/bin2inc - this will read in any binary file and output an include file in C or assembly syntax. That's all preexisting. But you need a player for the soundlist, since it's not in the BIOS already. Here's some sample C code that should be easy to port to asm: // direct sound chip access, SDCC syntax for out volatile __sfr __at 0xff SOUND; // load the address of the song to play here. Set to NULL to stop. unsigned char *pSong = NULL; // after setting pSong, set this to '1' to start playback. It will // be 0 when the song stops. unsigned char songCount = 0; // call playSong once every frame void playSong() { unsigned char cnt; // if no count, then we are not playing if (!songCount) { return; } // count down frame delay --songCount; // if we didn't reach zero yet, wait till next frame if (songCount) { return; } // sanity check, make sure the song wasn't turned off if (pSong == NULL) { return; } // else it's time - read the byte count cnt = *(pSong++); // and load that many bytes while (cnt--) { SOUND = *(pSong++); } // read the new delay, if it's zero we're done automatically songCount = *(pSong++); } This has the advantage of no dependencies on BIOS prerequisites like fixed RAM addresses, uses just 3 bytes of RAM and only a handful of actual instructions. (Disclaimer, haven't tested.) Here's a sample conversion sequence from the sfxr download to soundlist, which the above code can play: D:\new>dir random.* 2022-06-02 07:34 PM 214 random.vgm D:\new>vgm_psg2psg.exe random.vgm Import VGM PSG - v20201001 Reading random.vgm - 214 bytes Reading version 0x110 Refresh rate 60 Hz (735 samples per tick) File 1 parsed! Processed 21 ticks (0.350000 seconds) -Writing channel 1 as random.vgm_ton00.60hz... Skipping channel 2 - no data Skipping channel 3 - no data Skipping channel 4 - no data Skipping channel 5 - no data Skipping channel 6 - no data Skipping channel 7 - no data Skipping channel 8 - no data done vgm_psg2psg. D:\new>psg2soundlist.exe random.vgm random.sndlist VGMComp VGM Test Output - v20220602 Working with prefix 'random.vgm'... Found extension 60hz Reading TONE channel 0 from random.vgm_ton00.60hz... read 21 lines 0 custom noises (non-lossy) 0 tones moved (non-lossy) 0 mutes mapped (non-lossy) 0 tones clipped (lossy) 0 noises mapped (lossy) Going to write TI Sound List format binary file 'random.sndlist' - Wrote 66 bytes ** DONE ** D:\new>bin2inc random.sndlist random.inc random Z80 bin2inc by Tursi - http://harmlesslion.com Converted 66 bytes for Z80. ** Done ** D:\new>type random.inc ; ; Data file random.sndlist - Jun 02, 2022 ; random: .db #0x03,#0x9E,#0x84,#0x08,#0x01,#0x01,#0x9D,#0x01 ; 00000000 ........ // .db #0x01,#0x9C,#0x01,#0x01,#0x9B,#0x01,#0x02,#0x82 ; 00000008 ........ // .db #0x05,#0x01,#0x01,#0x9A,#0x01,#0x01,#0x99,#0x01 ; 00000010 ........ // .db #0x01,#0x98,#0x01,#0x01,#0x97,#0x02,#0x01,#0x96 ; 00000018 ........ // .db #0x01,#0x01,#0x95,#0x01,#0x01,#0x94,#0x01,#0x01 ; 00000020 ........ // .db #0x93,#0x02,#0x01,#0x92,#0x01,#0x01,#0x91,#0x01 ; 00000028 ........ // .db #0x02,#0x8C,#0x05,#0x01,#0x03,#0x94,#0x82,#0x05 ; 00000030 ........ // .db #0x01,#0x01,#0x9D,#0x01,#0x04,#0x9F,#0xBF,#0xDF ; 00000038 ........ // .db #0xFF,#0x00 ; 00000040 .. // ; Size of data in above array SIZE_OF_RANDOM = 66 VGM to raw playable data in four steps. The toolchain includes tools to import VGMs and some other sound files for other sound chips as well, but for anything complex the packed music format is going to be far smaller than the playlist format. For my own packed player, there are sample videos here: https://odysee.com/$/search?q=vgmcomp2 And I posted some demos here on AtariAge. Most are for the TI, but all except Thunder Force are written in C and port to the Coleco - in fact the Quickplayer which is included with the toolchain can output all the visualizers for Coleco or TI. https://atariage.com/forums/topic/225463-vgm-compression-tool/page/5 <-- TI version and main thread https://atariage.com/forums/topic/226125-vgm-compression-tool/page/4/ <-- Coleco version https://atariage.com/forums/topic/322747-thunder-force-iii-tribute/ <-- sample of conversion from Megadrive/Genesis music 1 Quote Link to comment Share on other sites More sharing options...
logixworx Posted August 28 Share Posted August 28 Nice - just stumbled up on this. Could I use this to create melodies that sound exactly like it could be in Colecovision Jumpman Junior (the definitive version IMO) ? How would I do/tune this? Quote Link to comment Share on other sites More sharing options...
Tursi Posted September 25 Share Posted September 25 (edited) On 8/28/2023 at 1:40 PM, logixworx said: Nice - just stumbled up on this. Could I use this to create melodies that sound exactly like it could be in Colecovision Jumpman Junior (the definitive version IMO) ? How would I do/tune this? My VGM toolchain is for conversion and playback, so you'd have to compose the music in a compatible format first. I don't know anything about Jumpman. Also not sure if you might be asking about another tool in this thread Edited September 25 by Tursi Quote Link to comment Share on other sites More sharing options...
Captain Cozmos Posted September 25 Share Posted September 25 One of these days one of you awesome programmers that understand the SN76489AN will actually make a sound and music editor that outputs usable data for the Colecovision to compile. The only tool that comes close is very old and requires JAVA. Graphics are easy but music... Where is Amy Purple in times of need. Quote Link to comment Share on other sites More sharing options...
Tursi Posted September 26 Share Posted September 26 (edited) Rather than focus on the editor, which already has quality solutions like https://www.smspower.org/Music/Mod2PSG2 or https://www.deflemask.com/, I focused on the back end. Use a high quality editor to compose your music, then type a couple of commands to prepare it for playback on the Coleco. Or convert existing tunes from a dozen potential sources. Not sure what you're missing, besides a simple one-click solution? I'm sure that'll come along as AI gets integrated to write the music too. Edited September 26 by Tursi Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.