Post by Tamkis on May 6, 2015 19:38:28 GMT -5
Long awaited and due to both popular demand
and due to confusion on how to setup the Echo Sound Engine in BEX, Tamkis presents...
and due to confusion on how to setup the Echo Sound Engine in BEX, Tamkis presents...
The BEX Echo Sound Engine Guide!
Table of Contents:
1. Intro
2. Explanation about module formats and Echo formats
3. Setup
4. Walkthough
1. Intro
What is the Echo Sound Engine? ESE is a newer, z80-based sound driver created by Oerg866 for controlling dat magical YM2612 FM sound chip and PSG features from the SN76489 PSG chip on-chip from the VDP on the genesis. Since it is a Zilog z80-based driver, this allows the main Motorola 68k processor to do more important things while the z80 runs the sound code as a co-processor. The ESE be controlled via M68k ASM, via the SGDK, or via BEX. ESE also allows songs to share instruments. After getting the driver setup, usage "codewise" is very easy and flexible.Although there are various other ways, tools, and sound drivers out there for the Genesis (such as Stef's XGM player, Shiru's 4-channel DAC player, the TFC replayer, etc), the Echo Sound engine has the following benefits:
- Runs on the z80-coprocessor instead of hogging M68k resources
- "Performance-optimized" on the z80
- Allows up to 5 or 6 FM channels, with the ability to interrupt channel #6 to play a single DAC sample at a time
- Allows up to 4 PSG channels
- Can simultaneously play music, while interrupting channel(s) to play FM/PSG/DAC sound effects
- The ability to share a common sound bank of instruments between songs
- Total size of files per song may be smaller than VGM equivalent.
It does have a few drawbacks, however:
- Harder learning curve to setup
- More effort to convert songs over
- Only officially converts XM and MIDI files to .esf ATM
(will need to manually convert other sequenced music formats to XM and then to esf)
(I don't know how to convert from MIDI)
Motorola 68K processor Zilog z80 co-processor
YM2612 FM Chip VDP (with PSG on-chip) Standalone SN76489 PSG Chip
2. Explanation about Module formats and Echo formats
2a. Module formats
2a. Module formats
I am going to take some brief time in explaining what module formats are, describe what are the Echo formats, and describe how both relate. It seems that some of the confusion on how to use Echo comes from the lack of awareness and knowledge of what module music formats are. Woolyss's website probably gives everything you will need to know about module music and sequencing; however, I will summarize what everything is. Audio file formats basically come in two different types: streamed and sequence file formats. Streamed audio files are exactly like CD recordings; the combined waveform of all instruments in the song is recorded and played back verbatim. Sequenced formats, however, do not record the combined waveform of the entire song; it contains only the waveform of each instrument, and contains data and information on how to run the song and how to play the instrument. The difference between the two file formats is analogous to the difference between playing back a CD or MP3 file (which can be MBs large) vs. listening to a high school marching band play their music live from instruments while reading sheet music. Sequenced file formats, which are usually only KBs large in comparison to their streamed equivalents of MBs large, contain both the waveform of each instrument (called "samples"), and the commands and properties to play the song (somewhat like sheet music).
Module files are sequenced file formats, and come in various proprietary formats such as .mod, .xm, .it, and .s3m, each with their own commands on how to play the song and own features. Sequenced file formats contain instrument samples (short wave files of the audio), commands (directions on what note and how to play each instrument), channels (parallel threads for playing multiple instruments at once), and patterns (blocks of music, somewhat like different pages on sheet music). Patterns can be sequenced and played in any order you like, in order to reuse patterns and save disk space. Module files can be created using trackers such as OpenMPT, and plenty of module files can be found at websites such as The Mod Archive.
OpenMPT Sequencer
2b. Echo formats
2b. Echo formats
As previously mentioned, the Sega Genesis synthesizes its sound using the YM2612 FM Chip and the on-chip SN76489 PSG chip in the VDP. The Genesis can play up to 5 or 6 FM channels on the YM2612 chip, and up to 4 PSG channels on the on-chip SN76489 PSG from the VDP, resulting in a total of 10 sound channels. A channel can be configured to be interrupted to play digital DAC samples (such as drums or wave samples), but, since it is only one channel, can only play one DAC sample at a time. The ESE utilizes 5 main sound formats:
- Echo Instrument Format (EIF)
Holds data for FM instruments - Echo Waveform Format (EWF)
Holds converted wav data to use as DAC samples - Echo Envelope Format (EEF)
Holds PSG envelope data.
I don't know how to deal with this file format yet - Echo Stream Format (ESF)
Main file, holds the commands to play the appropriate instrument types to make a jingle. By "Jingle", I mean it could either be a full-blown song or sound effect jingle - XIF
A data description format used to correctly parse the xm files and convert them to esf
3. Setup
In order to quickly and easily create the Echo file formats and setup the ESE sound driver, it is highly recommended to use the following tools:
- Echo Sound Engine (BEX Edition)!
- OpenMPT (module file sequencer)
- Your command-prompt
- VGM Music Maker (VGM_MM)
(Appears link in thread is dead; but there is another mirror by user DB-Elec at end of Page #2)
Genesis sequencer to experiment with instrument creation live - RIFFStrip
Tool strips the RIFF header from wav files to make it a "headerless" PCM file - VGI2EIF and PCM2EWF
(Can compile latest C-source from Sik's GitHub from here and here, OR download tools pre-compiled from my mirror)
Tools convert VGM_MM's VGI FM instrument format to EIF format, and RIFF-stripped PCM files to EWF format - RIFFStrip
- Tool strips the RIFF header from wav files to make it a "raw" PCM file
- VGI2EIF and PCM2EWF
(Can compile latest C-source from Sik's GitHub from here and here, OR download tools pre-compiled from my mirror)
Tools convert VGM_MM's VGI FM instrument format to EIF format, and raw PCM files to EWF format - XM2ESF
Click "Download Zip" from the GitHub page
Tools generate an .xif file for the XM file to convert, and can generate the ESF Song file from the .xif - An audio converter (I recommend using XMPlay and its output wav writer functionality)
Get your tools, and let's get started!
In order to setup the ESE, create a new folder called "Echo" at the root of your BEX Project directory, and extract the archive of the BEX edition of the ESE into that folder.
It should look something like this:
Then while in the root of the "Echo" folder, open "echo_includes.asm" with notepad, and change each file path to start with "Echo/". Once complete, the file should look like this:
It should look something like this:
Then while in the root of the "Echo" folder, open "echo_includes.asm" with notepad, and change each file path to start with "Echo/". Once complete, the file should look like this:
Lastly, under the "Echo/data" path, add another folder called "music". You will use this folder to store the converted .esf files, as well as source module files as necessary.
The ESE is now ready for you to insert instruments, create songs, and map instruments!
4. Walkthrough
In order to create instruments, songs, and map instruments, do the following:
4. Walkthrough
In order to create instruments, songs, and map instruments, do the following:
- Get module music format files to convert, preferably those with <10 sound channels and in .xm or .mod formats.
Try The Mod Archive or create your own tunes. - If necessary, manually convert those module music formats to .xm and .mod.
In OpenMPT, click "File>New>" and either XM or MOD.
Setup the tempo and amount of channels to that of the source file.
Manually paste the command data from the source file to the .xm and .mod file, and save.
Commands should automatically convert to their appropriate types.
You could also manually copy over the audio samples for casual playback, but that is not required.
Refer to general sequencer tutorials and the OpenMPT manual for help on how to use a tracker if necessary.
The New File menu option
Selecting command data for copying - Open VGM Music Maker, and import a .mod file over
- In VGM Music Maker, click the "instruments" tab.
Load and tweak FM instrument slots and settings for the song until it sounds right.
Save each FM instrument somewhere as .vgi files.
It is recommended to give them either a good file name description (such as "strings", "Chopper bass", etc for shared instruments)
or some kind of naming convention (such as nn_xx, where n is the song # in decimal, and xx is the instrument ID # in decimal, if using unique instruments per song).
Place these files somewhere (perferably under "Echo/data/fm"). - Convert each .vgi file to .eif by calling the VGI2EIF tool with a command-prompt.
I recommend creating a .bat file to do this, so that you can run it every time you need to
update the files and convert, for build configuration purposes.
(Command-line syntax: vgi2eif.exe «infile.vgi» «outfile.eif»)
Place each .eif file into the "Echo/Data/FM" directory. - If you want to use DAC samples for the song, find wav samples to use for the DAC samples, and store them somewhere (preferably "Echo/data/pcm")
- Using your audio converter of choice, replace the wav files with unsigned 10250 Hz 8-bit mono versions.
Using XMPlay's Wav Writer functionality to convert files to unsigned 10250 Hz 8-bit mono. - Use a command-prompt to call RIFFStrip in order to strip the RIFF headers raw from those aforementioned .wav files.
I recommend creating a .bat file to do this, so that you can run it every time you need to
update the files and convert, for build configuration purposes.
Command-prompt Syntax: RIFFStrip.exe <filename.wav>
The utility will output striped wav files with filenames of [filename.wav.stripped]. - Use a command-prompt to call PCM2EWF in order to convert the raw wav files to .ewf files.
I recommend creating a .bat file to do this, so that you can run it every time you need to
update the files and convert, for build configuration purposes.
Command-prompt Syntax: PCM2EWF <infile> <outfile.ewf>
Place the outputted .ewf files into "Echo/Data/PCM"
Just like with the FM instruments, name the files as you see fit. - Repeat steps #2-9 for each song to either get instruments to share between songs (efficient) or unique instruments per song (inefficient)
- After creating all of your instruments, goto the "Echo\src-68k\sound" directory
Open "list.68k" with Notepad.
Observe the structure of the file that came with Echo.
Under the line labeled "Echo_ListEnd", add labels with "incbin" commands and filepaths pointing to each file .ewf/.eif file.
Under the line labeled "PointerList", add "Echo_ListEntry" and line labels for each instrument.
Order is important! Each ListEntry will correspond to the Echo instrument ID later in XM2ESF (in hexadecimal).
End the list with "Echo_ListEntry"
Save the file
Sample list.68k file listing - Extract the downloaded XM2ESF archive somewhere.
- Run "XM2ESFgui.exe".
Load your .xm file
Select song properties (bgm/sfx, ticks per row, loop?)
Under Channels, select # of FM and PSG channels, and if you want PCM and Noise PSG channels
Map each FM/PSG/PCM channel to your desired sound channel of the .xm file as seen in OpenMPT
Map each XM instrument ID (decimal) to the Echo ID as assigned in list.68k (in hexadecimal)
Click "Create .xif file", and save it somewhere
XIF2ESFGui application - Repeat step #13 for each song
- Using a command-prompt, call "XM2ESF.exe" in order to convert the .xm files (with the settings from its corresponding .xif file) to .esf
Command-line syntax: xm2esf.exe <infile.xif> <outfile.esf>
Save the .esf files to "Echo/data/music" - Repeat step #15 for each .xif file
- Under "Echo\src-68k\sound", open bgms.68k with notepad.
Add line labels, with "incbin" commands and file paths to each .esf file
Order is unimportant.
Sample bgms.68k file - Under "Echo\src-68k\core", open "songlist.68k"
Under the "SongList:" label, insert "dc.l [Name of line label from bgms.68k]" lines for each song
Order is important! The 1st entry will be song ID #1, the 2nd #2, etc (in hexadecimal IIRC)
End the list with "even".
At the end of the file, add "NumSong equ [# of songs in decimal]"
La
Sample "songlist.68k" file - Follow the sample code of usage of Echo in BEX here.
- Jam some rocking Genesis tunes!
Hopefully this tutorial was not too complex and was relatively straight forward.
Any questions or something I forgot, just ask them here.
Now go enjoy (yet another possible BEX sound engine) for your homebrew game development:)!
Any questions or something I forgot, just ask them here.
Now go enjoy (yet another possible BEX sound engine) for your homebrew game development:)!