Difference between revisions of "Echo"

From Sega Retro

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.
  
== Event list ==
+
Its current version number is ''' 0.8 beta '''
  
=== '''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
 +
*Project MD (homebrew Jump'n'run game for the [[Sega Mega Drive]])
 +
**Currently using Echo v0.8 beta
  
{| 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 ''':
+
== Specifications and features ==
  
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:
+
*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.624 KHz'''
 +
**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.
  
''32 * octave + 2 * semitone + 1''
+
== Echo Formats ==
  
''' For $08 to $0A ''':
+
=== 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 an own article describing it.
  
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 Waveform Format (EWF) ===
 +
The Echo Waveform Format (EWF) is the format used by PCM samples. There isn't much to it. PCM data is stored as unsigned 8-bit, at 10625Hz mono. The bytes specifying the waveform data contain values ranging from $00 to $FE. When a byte with value $FF is found, this is the end of the waveform.
  
''24 * octave + 2 * semitone''
+
=== 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):
 +
   
 +
$B4                    -- 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
  
''' $0Bnn: Note on PSG channel #4 ''':
+
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.
  
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:
+
=== 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.  
  
        $00 ... Periodic noise, high pitch
+
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). 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.
        $01 ... Periodic noise, medium pitch
 
        $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).
+
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):
 +
   
 +
$FE,$00,$FF
  
''' $0Cnn: Note on PCM channel ''':
+
== 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 Echo's GitHub repository linked at the bottom of the page.
  
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).
+
=== 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 Echo's GitHub repository linked at the bottom of the page.
  
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).
+
=== 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:
  
=== '''Note off''' ===
+
* 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)
  
{| class="prettytable"
+
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.
! Event||Description
 
|-
 
| $10
 
| Note off FM channel #1
 
|-
 
| $11
 
| Note off FM channel #2
 
|-
 
| $12
 
| 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.
+
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.  
  
''' $1C: Note off PCM channel ''':
+
For now, this program runs on Microsoft Windows (or Linux and MacOS with WINE et al) only, however, it is currently being ported to C++. When this is done, native Windows, Linux and OSX binaries will be available.
  
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.
+
Xm2esf is currently in beta stage at version '''0.99.x''', and is available from [http://github.net/oerg866/xm2esf GitHub].
 
 
=== '''Set Volume''' ===
 
 
 
{| class="prettytable"
 
! 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 ''':
 
 
 
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.
 
 
 
''' For $28 - $2B ''':
 
 
 
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://github.net/sikthehedgehog/echo GitHub repository for Echo], including docs, source, binaries, etc.
 +
[http://github.net/oerg866/xm2esf GitHub repository for xm2esf], including necessary files and tools.
  
 
[[Category:Technical Information]]
 
[[Category:Technical Information]]

Revision as of 20:55, 17 November 2011

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.

Its current version number is 0.8 beta

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
  • Project MD (homebrew Jump'n'run game for the Sega Mega Drive)
    • Currently using Echo v0.8 beta


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.624 KHz
    • 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 an 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. PCM data is stored as unsigned 8-bit, at 10625Hz mono. The bytes specifying the waveform data contain values ranging from $00 to $FE. When a byte with value $FF is found, this is the end of the waveform.

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):

$B4                     -- 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). 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):

$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 Echo's GitHub repository linked at the bottom of the page.

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 Echo's GitHub repository linked at the bottom of the page.

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)

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 (or Linux and MacOS with WINE et al) only, however, it is currently being ported to C++. When this is done, native Windows, Linux and OSX binaries will be available.

Xm2esf is currently in beta stage at version 0.99.x, and is available from GitHub.

Links / Download

GitHub repository for Echo, including docs, source, binaries, etc. GitHub repository for xm2esf, including necessary files and tools.