Music Box - ZX Spectrum beeper music engine
Original Z80 code by Mark Alexander, 1985
1tracker version by Shiru 03'2018


Music Box is likely the most famous ZX Spectrum beeper music engine, one 
of the earliest multi-channel engines on the platform. It first appeared 
in WHAM The Music Box editor, and as the editor allowed to compile music 
and save it as a code block, was used in numerous games. 

The engine is very simple. It features two channels of square tone with 
completely equal volumes, and percussion than can be played instead of a 
whole note row. Percussion features two kinds of sound: single tone 
slide drum, and a noise drum with some degree of customization. Drums 
affect the tempo a lot. As it used a table of dividers, there is no 
detune support. No per-speed support either. 

One common trick for this engine is to put the same note to both 
channels to increase its volume. Unlike many other engines, it does not 
produce any side effects such as phasing, the note just gets louder. 


The columns are:

T1  T2  Dmask
... ... .....
| | | | |   |
ch1 ch2 +perc

T1,T2 : Note, C-1..E-5
Dmask : Percussion, 1..8 for noise, 9 for slide drum

		Noise percussion has a pitch, 1 highest, 8 lowest, and a mask,
		which is four values that can be empty or 1. They mask out noise,
		turning it off for 1/4 of a whole noise duration.

		Slide drum has a fixed pitch and slide speed. Its duration
		depends from song speed.
