Page 1 of 3

Programming a native Sega Genesis tracker.

Posted: Sat Nov 17, 2012 4:06 am
by Count SymphoniC
Hey all.

I'm starting a project for the Sega Genesis. It's currently unnamed. But it's a native music tracker/sequencer for the YM2612. For those who aren't sure exactly what I'm talking about... google "LSDJ", it's a native gameboy tracker designed to be ran on actual hardware, basically to write gameboy music using a gameboy.

I have experience with several different programming languages. But this is the first time I've delved into the world of coding for the Genesis. So that's why I'm here.

My first question, which language is best suited for this type of program? I understand that Genesis homebrew can be done in C or Assembly. Are these my only two options? Which one is the best? I'm also looking for technically accurate YM2612 docs... I understand that there are some out there with incorrectly labeled algorithms.

EDIT : I'm finding information about Genesis sound drivers/sound engines. Would it really be necessary to write the sound engine from scratch if something like this has already been done?

Thanks! :)

Posted: Sat Nov 17, 2012 4:40 am
by Chilly Willy
Echo is a complete sound/music driver for the Genesis. You might use that in the search field and check it out.

You really want your music driver to run on the Z80 as much as you can to leave the 68000 for playing the game. That normally means using Z80 assembly language, but like a recent VGM player showed, you can use C as well with a compiler like sdcc. Check out the VGM player thread for details.

Posted: Sat Nov 17, 2012 5:26 am
by Count SymphoniC
Chilly Willy wrote:Echo is a complete sound/music driver for the Genesis. You might use that in the search field and check it out.

You really want your music driver to run on the Z80 as much as you can to leave the 68000 for playing the game. That normally means using Z80 assembly language, but like a recent VGM player showed, you can use C as well with a compiler like sdcc. Check out the VGM player thread for details.
You're awesome. So when I'm developing this tracker, I should probably provide the option of using two modes. One mode for video game music composition, the other mode allowing more features... music composition for non-game music.

It's nice to know that I'll be able to integrate a sound engine that's already made, rather than design my own from scratch... I was concerned about that.

Posted: Sat Nov 17, 2012 5:48 am
by Chilly Willy
There are plenty of options... you can also use DefleMask. That's a tracker that can make Genesis compatible VGMs. There's older music drivers like Shiru's. You can even convert tracker files to the official player from Sega used in the Sonic games.

Posted: Sat Nov 17, 2012 6:54 am
by Count SymphoniC
Chilly Willy wrote:There are plenty of options... you can also use DefleMask. That's a tracker that can make Genesis compatible VGMs. There's older music drivers like Shiru's. You can even convert tracker files to the official player from Sega used in the Sonic games.
I'm fully aware of of Delek's DefleMask... Delek actually offered to add support for file outputs in this tracker when complete. I also know about Shiru's trackers.

The one I'm coding is different from Delek's and Shiru's in the fact that it isn't intended to be run on a pc... rather it's meant to be run on a Sega Genesis. It's a music sequencer for the Genesis, on the Genesis.

I did notice some confusion as to the definition of a "tracker" throughout these forums, in this case, I'm referring to "music sequencer", not necessarily "music player". Just to eliminate confusion in this thread.

So, basically I can use Echo to handle the YM2612 and PSG soundchips, leaving me free to program the rest of the interface, and how the interface interacts with Echo, right? I hope I'm reading all of this correctly.

Posted: Sat Nov 17, 2012 5:20 pm
by Chilly Willy
Count SymphoniC wrote:I did notice some confusion as to the definition of a "tracker" throughout these forums, in this case, I'm referring to "music sequencer", not necessarily "music player". Just to eliminate confusion in this thread.
Ah, so you're looking at doing something like MilkyTracker, but aimed at the Genesis?
So, basically I can use Echo to handle the YM2612 and PSG soundchips, leaving me free to program the rest of the interface, and how the interface interacts with Echo, right? I hope I'm reading all of this correctly.
Actually, for Echo you're expected to make an XM file, then use a tool that comes with Echo to convert it to Echo's format. If you plan on making sequences that have more or different commands from "regular" tracker files, you may wish to do your own player and use the existing ones as examples of how you do that.

If you're working with regular tracker commands, you could make a Genesis version of something like FastTracker or ProTracker and then build that converter into it to get it into Echo format.

Re: Programming a native Sega Genesis tracker.

Posted: Sat Nov 17, 2012 5:59 pm
by sasuke
Count SymphoniC wrote:I'm starting a project for the Sega Genesis. It's currently unnamed. But it's a native music tracker/sequencer for the YM2612. For those who aren't sure exactly what I'm talking about... google "LSDJ", it's a native gameboy tracker designed to be ran on actual hardware, basically to write gameboy music using a gameboy.
Finally! An LSDJ-like tracker for Genesis has been a pipe dream of mine, though I didn't think anyone would be willing to do this.

It's going to be a challenge, though. The tracker playback (from the tracker program itself) would have to be driven by the 68k, since the Z80 cannot read from the 64kb RAM and can only access it's own 8kb RAM. You would also need to make sure all the save data fits in 32kb, which is the maximum SRAM size in most flash carts. Also, I am interested in how you would design the instrument editor, as this would be something different than LSDJ.

Anyway, good luck with your project, I am looking forward to it.

Posted: Sat Nov 17, 2012 6:04 pm
by slobu
My two cents for feature requests:

Some method to export via a Retrode. Someone could plug in their cart and use a utility to save the battery backed RAM as an Echo compatible music file.

Also, a music sheet interface for those who compose visually.

Posted: Sat Nov 17, 2012 6:12 pm
by djcouchycouch
Darn! I was hoping that this was a new Genesis-specific tracker for PC that'll export to Echo formats.

A man can dream, can't he?

Posted: Sat Nov 17, 2012 6:34 pm
by Chilly Willy
slobu wrote:My two cents for feature requests:

Some method to export via a Retrode. Someone could plug in their cart and use a utility to save the battery backed RAM as an Echo compatible music file.
That is an interesting idea... that would allow saving music via flash carts on real hardware, or in emulators. You'd be limited on the size in some cases - for example, the MD-Pro has a 32KB limit on sram, the MD-Myth has a 64KB limit on sram, and the Mega-ED seems to currently have a problem with 32KB of sram (so you'd have to use even less).

Other than the size limit, that's a perfectly good method to get the music exported. I suppose you'd also want the ability to load in the editor from the sram to go with that. You could import music for editing or just playing on real hardware.

Posted: Sat Nov 17, 2012 6:36 pm
by djcouchycouch
Doesn't the SGDK have functions to export to the SD card when running on an Everdrive?

Posted: Sat Nov 17, 2012 11:50 pm
by Chilly Willy
djcouchycouch wrote:Doesn't the SGDK have functions to export to the SD card when running on an Everdrive?
It has fat routines geared towards reading files. It has a write function, but looks like it is designed to just overwrite an existing file without changing the length of the file. It would be better if sgdk incorporated Elm's FatFilesystem instead... that would allow full filesystem operations, like creating new files, or extending existing ones.

Posted: Sun Nov 18, 2012 12:30 am
by powerofrecall
The absolute dream genesis tracker would be something that ran on the hardware, could work with and SD card, read and write, plus maybe some kind of midi adapter (that serial port on the back of the model 1?) for a keyboard or other midi input device.

Posted: Sun Nov 18, 2012 1:17 am
by Chilly Willy
powerofrecall wrote:The absolute dream genesis tracker would be something that ran on the hardware, could work with and SD card, read and write, plus maybe some kind of midi adapter (that serial port on the back of the model 1?) for a keyboard or other midi input device.
The serial port isn't fast enough. Some kind of custom parallel <> serial adapter might be fast enough for MIDI.

Posted: Sun Nov 18, 2012 2:51 am
by powerofrecall
I don't know what the raw bandwidth requirement for midi is in bps--or even if it's constant--but I imagine if the serial port can't meet that demand, it must be a damn slow serial port! I'm just spitballing but since midi itself is just serial I'd have a hard time imagining a one (midi) channel keyboard input having large bandwidth requirements. What if you limited it purely to one channel, receive only, and didn't support any kind of SysEx to or from the genesis? Just a simple way to hook up one midi device, no daisy chaining.

edit: just offhand what kind of bitrate could someone achieve on that serial port?