Difference between revisions of "Echo"

From Sega Retro

 
(27 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Echo is a new sound-engine for the [[Sega Mega Drive]] created by [[Sik]]. It's Z80-based and allows full control over the sound hardware. Its purpose is to provide a free, open-source possibility to implement music and sound effects in programs, demos or games developed for the system. It is currently in beta state, albeit functional for the most part.
+
'''Echo''' is a new sound-engine for the [[Sega Mega Drive]] created by [[Sik]]. It's [[Z80]]-based and allows full control over the sound hardware. Its purpose is to provide a free, open-source possibility to implement music and sound effects in programs, demos or games developed for the system. It is currently in beta state, albeit functional for the most part. Assembly, C with SGDK, and BasiEgaXorz interfaces are available, so nothing stops you from using this sound engine to its full potential!
  
== Event list ==
+
Its current version number is ''' 1.21 '''
  
=== '''Note on''' ===
+
It was used and tested in a few projects already, such as
  
 +
*MDEM's first ([[Sega Mega Drive]] Demo)
 +
**Used Echo v0.3
 +
*In A Hall (32kb executable music release)
 +
**Used Echo v0.3
 +
*Super Generic Happy Game Intro Song (32kb executable music release)
 +
**Used Echo v0.9
 +
*Project MD (homebrew Jump'n'run game for the [[Sega Mega Drive]])
 +
**Used Echo v0.9
 +
*overdrive ([[Sega Mega Drive]] Demo)
 +
**Used a custom version of Echo (1.3T)
 +
*Muhinae II (32kb executable music release)
 +
**Used Echo v1.2
 +
*Miniplanets (homebrew game involving a 3D world mechanic)
 +
**Currently using Echo v1.21
  
{| class="prettytable"
 
! Event||Description
 
|-
 
| $00nn
 
| Note on FM channel #1
 
|-
 
| $01nn
 
| Note on FM channel #2
 
|-
 
| $02nn
 
| Note on FM channel #3
 
|-
 
| $04nn
 
| Note on FM channel #4
 
|-
 
| $05nn
 
| Note on FM channel #5
 
|-
 
| $06nn
 
| Note on FM channel #6
 
|-
 
| $08nn
 
| Note on PSG channel #1
 
|-
 
| $09nn
 
| Note on PSG channel #2
 
|-
 
| $0Ann
 
| Note on PSG channel #3
 
|-
 
| $0Bnn
 
| Note on PSG channel #4
 
|-
 
| $0Cnn
 
| Note on PCM channel
 
|}
 
  
''' For $00 to $06 ''':
+
Several smaller demos and music players have been created with Echo.
  
These events do a "note on" at the specified FM channel. The event is followed by a byte, which indicates which note to play. The value is as follows, where "octave" ranges from 0 to 7 and "semitone" ranges from 0 to 11:
+
== Specifications and features ==
  
''32 * octave + 2 * semitone + 1''
+
*Supports background music and sound effects at the same time
 +
**Sound effects do channel locking, meaning when they play, SFXs have priority above BGMs (channels unused by the SFX will continue to play normally in the BGM)
 +
*Support for all FM and PSG channels
 +
**All PSG Noise types supported
 +
**PSG volume envelopes supported (similar format to [[SMPS]]'s PSG envelopes, but Echo's support looping)
 +
*PCM support
 +
**PCM playback rate is precisely '''10.650 KHz''' -- The 2Hz difference between PAL and NTSC can be ignored.
 +
**Locking and Unlocking of FM 6 is automatically managed. PCM has priority.
 +
*FM Stereo support
 +
*Supports looping and non-looping BGMs, with a custom loop point
 +
*Variable tempo mid-sfx or mid-bgm, as a delay command can have any amount of tics.
  
''' For $08 to $0A ''':
+
== Echo Formats ==
  
These events do a "note on" at the specified square wave PSG channel. The event is followed by a byte, which indicates which note to play. The value is as follows, where "octave" ranges from 0 to 5 and "semitone" ranges from 0 to 11:
+
=== Echo Stream Format (ESF) ===
 +
The [[Echo Stream Format]] (ESF) ìs a headerless music and sound effect format used by Echo. It contains commands and instructions that are read by Echo and passed onto the sound hardware. It has an extensive amount of commands / instructions, and thereby has its own article describing it.
  
''24 * octave + 2 * semitone''
+
=== Echo Waveform Format (EWF) ===
 +
The Echo Waveform Format (EWF) is the format used by PCM samples. There isn't much to it, as PCM data is stored as unsigned 8-bit, at 10650Hz mono. The bytes specifying the waveform data contain values ranging from $00 to $FE. When a byte with value $FF is found, the end of the waveform is indicated.
  
''' $0Bnn: Note on PSG channel #4 ''':
+
=== Echo Instrument Format (EIF) ===
 +
The Echo Instrument Format is the format used for FM instruments in Echo. EIF instruments are essentially raw dumps of the YM2612 registers. They consist of 29 bytes, where each byte belongs to a different YM2612 register. The registers are stored in the following order (assuming the first FM channel):
 +
   
 +
$B0                    -- Algorithm and feedback
 +
$30, $34, $38, $3C      -- Multiplier and detune
 +
$40, $44, $48, $4C      -- Total level
 +
$50, $54, $58, $5C      -- Attack rate
 +
$60, $64, $68, $6C      -- Decay rate
 +
$70, $74, $78, $7C      -- Sustain rate
 +
$80, $84, $88, $8C      -- Release rate and sustain level
 +
$90, $94, $98, $9C      -- SSG-EG
  
This event does a "note on" at the noise PSG channel. The event is followed by a byte, which indicates what kind of noise to play. The following values are valid:
+
Some bits are unused and ignored by the YM2612. In an EIF instrument, they *must* be 0, since Echo will rely on this for optimization purposes.
  
        $00 ... Periodic noise, high pitch
+
=== Echo Envelope Format (EEF) ===
        $01 ... Periodic noise, medium pitch
+
The Echo Envelope Format (EEF) is the format used to describe volume envelopes for the PSG channels in Echo. This format was kind of an afterthought. Later it may be improved to provide at least some kind of RLE-like compression, but for now, this is it.  
        $02 ... Periodic noise, low pitch
 
        $03 ... Periodic noise, PSG3 frequency
 
        $04 ... White noise, high pitch
 
        $05 ... White noise, medium pitch
 
        $06 ... White noise, low pitch
 
        $07 ... White noise, PSG3 frequency
 
  
When using values $03 and $07, the third square wave PSG channel controls the noise frequency. You can change this frequency using the events to change the frequency of that channel (usually you'd use event type $3A).
+
EEF instruments consist of a list of volume levels. Each byte represents a different volume level, and the value ranges from $00 (loudest) to $0F (quietest). Each byte represents one tick (i.e. 1/60th of a second), and looping is possible. The start of the loop is marked by a byte with value $FE, while the end of the loop is marked by a byte with value $FF. There must be at least one volume byte between them or Echo will hang. To make a non-looping PSG instrument, just put the last volume value inside the loop.
  
''' $0Cnn: Note on PCM channel ''':
+
Also, since PSG instruments are required to use PSG channels and many people do not want to mess with them at all, here's a flat PSG instrument (i.e. no envelope):
 +
<code=asm>   
 +
$FE,$00,$FF
 +
</code>
  
This event does a "note on" at the PCM channel. More specifically, it starts playback of a PCM sample. This event is followed by a byte, that specifies an index in the pointer list indicating where's the sample data. Samples are stored as EWF (Echo Waveform Format).
+
== Tools ==
 +
=== pcm2ewf ===
 +
''' pcm2ewf''' is a program that converts raw 8-bit mono PCM files to the slightly different format used by Echo (EWF, see above). It can be downloaded from Sik's [http://github.net/sikthehedgehog/mdtools Tools repository].
  
NOTE: FM channel #6 will be disabled. That channel will be re-enabled when PCM playback is over (either because the waveform is over or because the channel is stopped explicitly).
+
=== tfi2eif ===
 +
''' tfi2eif ''' is a program that converts files from the TFM Music Maker FM instrument format to the instrument format used by Echo ([[EIF]]). It can be downloaded from Sik's [http://github.net/sikthehedgehog/mdtools Tools repository].
  
=== '''Note off''' ===
+
=== xm2esf ===
 +
''' xm2esf ''' is a program written by Oerg866. At the moment it is the only program available and working that can produce ESF streams. It is, in addition to that, by far the most advanced Mega Drive music tool available today that produces real-time usable output (ESF). To enable the user to enjoy the comfort of any XM tracker he is used to, the program takes [[XM]] files as input, and outputs a stream readable by Echo. The tool is very advanced as it supports all major XM effects, such as:
  
{| class="prettytable"
+
* 0xx (Arpeggio)
! Event||Description
+
* 1xx (Portamento Down)
|-
+
* 2xx (Portamento Up)
| $10
+
* 3xx (Tone Portamento)
| Note off FM channel #1
+
* 4xx (Vibrato)
|-
+
* 8xx (Set Panning, hint: only left, center or right)
| $11
+
* Axx (Volume Slide)
| Note off FM channel #2
+
* Cxx (Set volume, very accurate formulae used to calculate volume for FM and PSG)
|-
+
* Dxx (Pattern break, always interpreted as D00)
| $12
+
* Fxx (Sets amount of delay per row to the amount specified in xx)
| Note off FM channel #3
 
|-
 
| $14
 
| Note off FM channel #4
 
|-
 
| $15
 
| Note off FM channel #5
 
|-
 
| $16
 
| Note off FM channel #6
 
|-
 
| $18
 
| Note off PSG channel #1
 
|-
 
| $19
 
| Note off PSG channel #2
 
|-
 
| $1A
 
| Note off PSG channel #3
 
|-
 
| $1B
 
| Note off PSG channel #4
 
|-
 
| $1C
 
| Note off PCM channel
 
|}
 
  
These events do a "note off" at the specified channel.
+
''Hint: keep in mind that to make the ticks per row ("speed" in some trackers, default is 6) match an Echo tick's length, set "Tempo" to 150! ''
  
''' $1C: Note off PCM channel ''':
+
Xm2esf uses an inputfile called '''xif'''. It is short for ''XM information file''. It contains parameters, channels, instrument assignments, channel transposes, channel volumes, noise type, etc. taken into account when converting. Distributed with xm2esf is a program called xm2eifgui. It is a frontend for creating the necessary XIF files for conversion.
  
This event does a "note off" at the PCM channel. This means that any PCM playback is immediately stopped. FM channel #6 is immediately enabled as well.
+
To compare: xm2smps, xm3smps and xm4smps were not able to use any XM effects other than Dxx. This is why music can be created much faster and easier with echo than it can be done in any other accessible (be it free or reverse engineered) sound engine today.
  
=== '''Set Volume''' ===
+
For now, this program runs on Microsoft Windows, Linux and FreeBSD (some modifications might be necessary, as this has not been tested but theoretically should be completely possible). Binaries are included for Win32 and Linux in the github repository, whereas FreeBSD users have to compile the program first. 
  
{| class="prettytable"
+
Xm2esf is currently in release candidate stage, the latest version being '''v1.00 RC3''' as of October 2, 2012, and is available from [http://github.net/oerg866/xm2esf GitHub].
! Event||Description
 
|-
 
| $20nn
 
| Set volume FM channel #1
 
|-
 
| $21nn
 
| Set volume FM channel #2
 
|-
 
| $22nn
 
| Set volume FM channel #3
 
|-
 
| $24nn
 
| Set volume FM channel #4
 
|-
 
| $25nn
 
| Set volume FM channel #5
 
|-
 
| $26nn
 
| Set volume FM channel #6
 
|-
 
| $28nn
 
| Set volume PSG channel #1
 
|-
 
| $29nn
 
| Set volume PSG channel #2
 
|-
 
| $2Ann
 
| Set volume PSG channel #3
 
|-
 
| $2Bnn
 
| Set volume PSG channel #4
 
|}
 
  
''' For $20 - $26 ''':
+
=== esfopt ===
 +
'''Esfopt''' is a small program written in C++ by Oerg866. It takes an ESF stream as an input file, and outputs an optimized file.
  
These events set the volume of a specific FM channel. The event is followed by a byte, which indicates the new volume. A value of $00 is the loudest, a value of $7F is the quietest.
+
It...
 +
*Removes redundant note-on events
 +
*Fusions multiple delay-events into one
 +
*Removes redundant load-instrument events
 +
*etc.
  
''' For $28 - $2B ''':
+
It can be downloaded from [http://github.com/oerg866/xm2esf/tree/master/esfopt GitHub]
 
 
These events set the volume of a specific PSG channel. The event is followed by a byte, which indicates the new volume. A value of $00 is the loudest, a value of $0F is the quietest.
 
 
 
=== '''Set Frequency''' ===
 
 
 
{| class="prettytable"
 
! Event||Description
 
|-
 
| $30nnnn
 
| Set frequency FM channel #1
 
|-
 
| $31nnnn
 
| Set frequency FM channel #2
 
|-
 
| $32nnnn
 
| Set frequency FM channel #3
 
|-
 
| $34nnnn
 
| Set frequency FM channel #4
 
|-
 
| $35nnnn
 
| Set frequency FM channel #5
 
|-
 
| $36nnnn
 
| Set frequency FM channel #6
 
|-
 
| $38nnnn
 
| Set frequency PSG channel #1
 
|-
 
| $39nnnn
 
| Set frequency PSG channel #2
 
|-
 
| $3Annnn
 
| Set frequency PSG channel #3
 
|-
 
| $3Bnnnn
 
| Set '' ''' Noise Type ''' '' PSG channel #4
 
|}
 
 
 
These events set the raw frequency of a specific FM channel, without triggering a new note. Meant for note slides. The following two bytes specify the new frequency in the same format as the YM2612 expects. The first byte is register +$A4, the second byte is register +$A0.
 
 
 
Echo uses the following frequency values for each semitone:
 
 
 
        C  - 644 | E  - 810 | G# - 1021
 
        C# - 681 | F  - 858 | A  - 1081
 
        D  - 722 | F# - 910 | A# - 1146
 
        D# - 765 | G  - 964 | B  - 1214
 
  
 
== Links / Download ==
 
== Links / Download ==
  
[http://github.net/sikthehedgehog/echo GitHub repository for Echo], including docs, source, binaries, etc.
+
*[http://echo.mdscene.net/ GitHub repository for Echo], including docs, source, binaries, etc.
 +
*[http://github.com/oerg866/xm2esf GitHub repository for xm2esf], including necessary files and tools.
 +
[[Category:Mega Drive sound drivers]]

Latest revision as of 16:01, 4 April 2017

Echo is a new sound-engine for the Sega Mega Drive created by Sik. It's Z80-based and allows full control over the sound hardware. Its purpose is to provide a free, open-source possibility to implement music and sound effects in programs, demos or games developed for the system. It is currently in beta state, albeit functional for the most part. Assembly, C with SGDK, and BasiEgaXorz interfaces are available, so nothing stops you from using this sound engine to its full potential!

Its current version number is 1.21

It was used and tested in a few projects already, such as

  • MDEM's first (Sega Mega Drive Demo)
    • Used Echo v0.3
  • In A Hall (32kb executable music release)
    • Used Echo v0.3
  • Super Generic Happy Game Intro Song (32kb executable music release)
    • Used Echo v0.9
  • Project MD (homebrew Jump'n'run game for the Sega Mega Drive)
    • Used Echo v0.9
  • overdrive (Sega Mega Drive Demo)
    • Used a custom version of Echo (1.3T)
  • Muhinae II (32kb executable music release)
    • Used Echo v1.2
  • Miniplanets (homebrew game involving a 3D world mechanic)
    • Currently using Echo v1.21


Several smaller demos and music players have been created with Echo.

Specifications and features

  • Supports background music and sound effects at the same time
    • Sound effects do channel locking, meaning when they play, SFXs have priority above BGMs (channels unused by the SFX will continue to play normally in the BGM)
  • Support for all FM and PSG channels
    • All PSG Noise types supported
    • PSG volume envelopes supported (similar format to SMPS's PSG envelopes, but Echo's support looping)
  • PCM support
    • PCM playback rate is precisely 10.650 KHz -- The 2Hz difference between PAL and NTSC can be ignored.
    • Locking and Unlocking of FM 6 is automatically managed. PCM has priority.
  • FM Stereo support
  • Supports looping and non-looping BGMs, with a custom loop point
  • Variable tempo mid-sfx or mid-bgm, as a delay command can have any amount of tics.

Echo Formats

Echo Stream Format (ESF)

The Echo Stream Format (ESF) ìs a headerless music and sound effect format used by Echo. It contains commands and instructions that are read by Echo and passed onto the sound hardware. It has an extensive amount of commands / instructions, and thereby has its own article describing it.

Echo Waveform Format (EWF)

The Echo Waveform Format (EWF) is the format used by PCM samples. There isn't much to it, as PCM data is stored as unsigned 8-bit, at 10650Hz mono. The bytes specifying the waveform data contain values ranging from $00 to $FE. When a byte with value $FF is found, the end of the waveform is indicated.

Echo Instrument Format (EIF)

The Echo Instrument Format is the format used for FM instruments in Echo. EIF instruments are essentially raw dumps of the YM2612 registers. They consist of 29 bytes, where each byte belongs to a different YM2612 register. The registers are stored in the following order (assuming the first FM channel):

$B0                     -- Algorithm and feedback
$30, $34, $38, $3C      -- Multiplier and detune
$40, $44, $48, $4C      -- Total level
$50, $54, $58, $5C      -- Attack rate
$60, $64, $68, $6C      -- Decay rate
$70, $74, $78, $7C      -- Sustain rate
$80, $84, $88, $8C      -- Release rate and sustain level
$90, $94, $98, $9C      -- SSG-EG

Some bits are unused and ignored by the YM2612. In an EIF instrument, they *must* be 0, since Echo will rely on this for optimization purposes.

Echo Envelope Format (EEF)

The Echo Envelope Format (EEF) is the format used to describe volume envelopes for the PSG channels in Echo. This format was kind of an afterthought. Later it may be improved to provide at least some kind of RLE-like compression, but for now, this is it.

EEF instruments consist of a list of volume levels. Each byte represents a different volume level, and the value ranges from $00 (loudest) to $0F (quietest). Each byte represents one tick (i.e. 1/60th of a second), and looping is possible. The start of the loop is marked by a byte with value $FE, while the end of the loop is marked by a byte with value $FF. There must be at least one volume byte between them or Echo will hang. To make a non-looping PSG instrument, just put the last volume value inside the loop.

Also, since PSG instruments are required to use PSG channels and many people do not want to mess with them at all, here's a flat PSG instrument (i.e. no envelope): <code=asm>

$FE,$00,$FF

Tools

pcm2ewf

pcm2ewf is a program that converts raw 8-bit mono PCM files to the slightly different format used by Echo (EWF, see above). It can be downloaded from Sik's Tools repository.

tfi2eif

tfi2eif is a program that converts files from the TFM Music Maker FM instrument format to the instrument format used by Echo (EIF). It can be downloaded from Sik's Tools repository.

xm2esf

xm2esf is a program written by Oerg866. At the moment it is the only program available and working that can produce ESF streams. It is, in addition to that, by far the most advanced Mega Drive music tool available today that produces real-time usable output (ESF). To enable the user to enjoy the comfort of any XM tracker he is used to, the program takes XM files as input, and outputs a stream readable by Echo. The tool is very advanced as it supports all major XM effects, such as:

  • 0xx (Arpeggio)
  • 1xx (Portamento Down)
  • 2xx (Portamento Up)
  • 3xx (Tone Portamento)
  • 4xx (Vibrato)
  • 8xx (Set Panning, hint: only left, center or right)
  • Axx (Volume Slide)
  • Cxx (Set volume, very accurate formulae used to calculate volume for FM and PSG)
  • Dxx (Pattern break, always interpreted as D00)
  • Fxx (Sets amount of delay per row to the amount specified in xx)

Hint: keep in mind that to make the ticks per row ("speed" in some trackers, default is 6) match an Echo tick's length, set "Tempo" to 150!

Xm2esf uses an inputfile called xif. It is short for XM information file. It contains parameters, channels, instrument assignments, channel transposes, channel volumes, noise type, etc. taken into account when converting. Distributed with xm2esf is a program called xm2eifgui. It is a frontend for creating the necessary XIF files for conversion.

To compare: xm2smps, xm3smps and xm4smps were not able to use any XM effects other than Dxx. This is why music can be created much faster and easier with echo than it can be done in any other accessible (be it free or reverse engineered) sound engine today.

For now, this program runs on Microsoft Windows, Linux and FreeBSD (some modifications might be necessary, as this has not been tested but theoretically should be completely possible). Binaries are included for Win32 and Linux in the github repository, whereas FreeBSD users have to compile the program first.

Xm2esf is currently in release candidate stage, the latest version being v1.00 RC3 as of October 2, 2012, and is available from GitHub.

esfopt

Esfopt is a small program written in C++ by Oerg866. It takes an ESF stream as an input file, and outputs an optimized file.

It...

  • Removes redundant note-on events
  • Fusions multiple delay-events into one
  • Removes redundant load-instrument events
  • etc.

It can be downloaded from GitHub

Links / Download