Phaser2 beeper music engine by Shiru (shiru@mail.ru) 03'11


Features

The engine is follow-up for Phaser1 engine. It was improved in a few ways:

- Two equal channels of phase synth
- 63 instruments, 8 drums
- Semitone offset instead of Multiple for the phase synth
- XOR/OR/AND modes for the phase synth
- Much better tempo control
- User customizeable synth drums
- Patterns-based format, patterns of arbitrary length

Few features were removed, though - no digital drums, no per-row tempo.


How to make music

Currently there is no other way than manual encoding of the data. Converters aren't usable for this engine because it requires an instrument/drum editor.


Data formats:

The player code, the note table, and music data should be aligned to 256 bytes.

Instrument format:

Up to 63 instruments could be defined.

+0 (byte) Frequency offset for second generator of a channel in semitones*2 (should be and #fe!). I.e. 24 is octave higher. It is possible to go above notes range that available from a pattern data, there are 10 octaves defined, but 192 and higher values are for lowest possible octaves.

+1 (byte) Phase offset for second generator of a channel. Should be 64 by default, it is 50% duty cycle when +0 and +2 bytes are 0.

+2 (byte) Fine detune for second generator of a channel, increases the frequency a bit.

+3 (byte) Channel mixing operation, should be #ac (XOR), #b4 (OR), or #a4 (AND).


Drums format:

Up to 8 drums could be defined.

+0 (word) Length in tone generator samples. It is precalculated value of the following word*195/160, not editable by user.
+2 (word) Length in drum generator samples.
+4 (word) Starting frequency of tone generator, higher values for higher frequency. Value 0 disables tone generation.
+6 (byte) Speed of frequency slide, 1 is fastest.
+7 (byte) Frequency slide direction, should be #1d (down), #13 (up), or #2b (none).
+8 (byte) Noise frequency, 1 is highest.
+9 (byte) Noise enable, 0 or 16.


Module format:

+0 (word) Absolute address of the order list.
+2 (word) Absolute address of drums data.
+4        Instruments data.
+?        Drums data.
+?        Order list, absolute addresses of the patterns, then two zero bytes, then absolute address of the loop position in the order list.
+?        Patterns data.


Pattern format:

+0 (word) Speed in tone generator samples. It is 3500000/160 for one second per row.
+2        Other data.

One row could contain 2-5 bytes.

If the first byte of a row is >=246, it is a drum (246-254) or end of the pattern (255). Then follows 2-4 bytes of note data for the row.

If bit 7 of a byte is set, it is an instrument change. bit 0 should be zero, instrument numbers are *2 and starts from 1, i.e. it is 2, 4, 6. Instrument byte should be followed by a note byte, and the note should not be empty (not 0).

If bit 7 of a byte is reset, it is a note. If bit 6 is set, it is the phase reset. Note value 0 means no change of the frequency (bit 7 and 6 are reset), value 1 means stop, values 2 and above are notes, starting from C of lowest octave.