-
Notifications
You must be signed in to change notification settings - Fork 1
Home
This page is a write-up of the notes I made when trying to understand the operation of the original Music 5000 hardware, with a view to re-implementing a compatible version of the design in a modern FPGA.
The registers in the Music 5000 hardware are implemented as a 2048 byte block of memory, called the Wave RAM. All functionality of the Music 5000 is controlled by writing to locations in the Wave RAM.
The Wave RAM serves two purposes:
-
It stores the Wave Definitions for 14 distinct waveforms. Each waveform is represented as 128 8-bit logarithmic samples (logarithmic because the Music 5000 uses a Companding DAC).
-
It stores the Channel Registers for each of the 16 channels. Each channel has two sets of registers, normal and alternative, each comprising six registers (frequency lo, frequency mid, frequency hi, amplitude, waveform and control).
The reason for the two sets of registers is to support modulation of any controllable parameter, inc. frequency, amplitude, phase (for synchronisation) etc. For example, it is possible to program different characteristics in each set in one channel (e.g. different frequencies), and then use the channel two positions earlier in the table of sixteen channels to switch between them at audio frequency.
The Wave RAM interfaces to the BBC using the 1MHz Bus and appears as eight 256 byte pages of memory that can be individually paged in to &FD00-&FDFF.
The Wave RAM is "addressed" by writing the value "0011BBBx" to the paging register at &FCFF.
| Bit | Description |
|---|---|
| Bit 7-4 | Write gate - must be 0011 for the Wave RAM to be paged in |
| Bit 3-1 | Selects one of eight pages of the Wave RAM |
| Bit 0 | Unused |
If the top nibble is not "0011", writes to &FDxx will be ignored. This allows multiple Hybrid devices (e.g. the Music 3000 Expander) to be connected in parallel.
In the original hardware, addresses &FD00-&FDFF are write only. In this FPGA version, they can also be read back, because the FPGA uses a true dual-port RAM.
| Bank | &FCFF | &FDxx Address | Function |
|---|---|---|---|
| 0 | &30 | &00-&7F | Wave 0 Definition |
| 0 | &30 | &80-&FF | Wave 1 Definition |
| 1 | &32 | &00-&7F | Wave 2 Definition |
| 1 | &32 | &80-&FF | Wave 3 Definition |
| 2 | &34 | &00-&7F | Wave 4 Definition |
| 2 | &34 | &80-&FF | Wave 5 Definition |
| 3 | &36 | &00-&7F | Wave 6 Definition |
| 3 | &36 | &80-&FF | Wave 7 Definition |
| 4 | &38 | &00-&7F | Wave 8 Definition |
| 4 | &38 | &80-&FF | Wave 9 Definition |
| 5 | &3A | &00-&7F | Wave 10 Definition |
| 5 | &3A | &80-&FF | Wave 11 Definition |
| 6 | &3C | &00-&7F | Wave 12 Definition |
| 6 | &3C | &80-&FF | Wave 13 Definition |
| 7 | &3E | &00-&0F | Channel 0-15 Frequency Lo Registers |
| 7 | &3E | &10-&1F | Channel 0-15 Frequency Mid Registers |
| 7 | &3E | &20-&2F | Channel 0-15 Frequency Hi Registers |
| 7 | &3E | &30-&4F | Unused |
| 7 | &3E | &50-&5F | Channel 0-15 Waveform Registers |
| 7 | &3E | &60-&6F | Channel 0-15 Amplitude Registers |
| 7 | &3E | &70-&7F | Channel 0-15 Control Registers |
| 7 | &3E | &80-&8F | Channel 0-15 Frequency Lo Registers (Alt) |
| 7 | &3E | &90-&9F | Channel 0-15 Frequency Mid Registers (Alt) |
| 7 | &3E | &A0-&AF | Channel 0-15 Frequency Hi Registers (Alt) |
| 7 | &3E | &B0-&CF | Unused |
| 7 | &3E | &D0-&DF | Channel 0-15 Waveform Registers (Alt) |
| 7 | &3E | &E0-&EF | Channel 0-15 Amplitude Registers (Alt) |
| 7 | &3E | &F0-&FF | Channel 0-15 Control Registers (Alt) |
The format of each Wave Definition is 128 consecutive 8-bit samples.
| Bit | Description |
|---|---|
| Bit 7 | Sign bit (0 for positive, 1 for negative) |
| Bit 6-0 | Wave value |
The Music 5000 uses an AM6070 companding DAC. This means that the values stored in the Wave Definition need to be carefully encoded to match the transfer characteristic of the DAC.
This uses the Bell System μ-255 logarithmic law which can be written as:
- Y = 0.18 ln (1 + u |X|) sgn(X) where:
- X = the encoder input (normalized to the range -1.0 to +1.0)
- Y = the encoder output (normalized to the range -1.0 to +1.0)
- u = 255
To calculate the 7-bit values to write into the Music 5000 wave table, use:
- Y = 22.903 ln (1 + 255 |X|) where:
- X = the waveform input (normalized to the range -1.0 to +1.0, e.g. a sine wave)
- e.g. when X=0.0, Y=0
- e.g. when X=1.0, Y=127
This value goes in bits 6 to 0 of the sample, and bit 7 is the sign bit (i.e. sign-and-mangnitude representation, not two's compliment).
These are some example Wave Definitions used by AMPLE:

A program to display these wave definitions is shown below:
10 FOR A=0 TO 13
20 MODE 4
30 PRINT '"WAVEFORM ";A
40 ?&FCFF=A
50 B=128*(A MOD 2)
60 MOVE 0,512
70 PLOT 21,1270,512
80 FOR X=0 TO 127
90 Y=?(&FD00+B+X)
100 S=-8
110 IF Y>127 THEN S=-S:Y=Y-128
120 Y=512+S*EXP(Y/32)
130 IF X=0 MOVE X*10,Y
140 IF X<>0 DRAW X*10,Y
150 NEXT
160 N$=STR$(A)
170 IF A<10 N$="0"+N$
180 OSCLI("SAVE WAVE"+N$+" 5800 +2800")
190 NEXT
The registers for a channel are organized as follows:
| Register Offset | Name |
|---|---|
| &00 | Frequency Lo |
| &10 | Frequency Med |
| &20 | Frequency Hi |
| &30 | unused - wave access timeslot |
| &40 | unused - host bus access timeslot |
| &50 | Waveform |
| &60 | Amplitude |
| &70 | Control |
- Lo byte: Register Address: Channel Base + &00
| Bit | Description |
|---|---|
| Bits 7-1 | Bits 7-1 of 24-bit Frequency |
| Bit 0 | Phase set (*) |
(*) The Phase set bit sets the phase to the current frequency value, and is used to implement a) oscillator sync (by hardware modulation) and b) gate sync, for sharp attacks (by software in the ON GATE code of the M5 module).
- Mid Byte: Register Address: Channel Base + &10
| Bit | Description |
|---|---|
| Bits 7-0 | Bits 15-8 of 24-bit Frequency |
- Hi Byte: Register Address: Channel Base + &20
| Bit | Description |
|---|---|
| Bits 7-0 | Bits 23-16 of 24-bit Frequency |
These three 8-bit registers combine to give a 24-bit frequency register.
Note that the 24-bit frequency value is signed. In principle this allows modulation to deliver a kind of wave-shaping, but this is not implemented in the current AMPLE drivers reference
The Music 5000 runs off a 6MHz clock and takes 128 clock cycles to update all channels. This means each channel is updated at 46.875kHz. Every time the channel is updated, the 24-bit frequency value is added to a phase accumulator. The top 7 bits of the phase accumulate (which look like a ramp) are then used as in index into the 128-byte Wave Definition.
Here's an example.
Assume the Wave Definition contains a single cycle of a sine wave, and you want to generate a 1.0 kHz tone.
The frequency register needs to be set to:
- 2^24 * 1.0 / 46.875
- = 343267
- = &053CE3
So:
- Frequency Lo = &E2
- Frequency Mid = &3C
- Frequency Hi = &05
Bit 0 of Frequency Lo must be zero, or the channel is effectively disabled (this bit is used to set the phase to the current frequency value).
- Register Address: Channel Base + &30
| Bit | Description |
|---|---|
| Bits 7-0 | Unused |
The register is unused because at this time the Wave RAM is performing waveform lookup cycle.
- Register Address: Channel Base + &40
| Bit | Description |
|---|---|
| Bits 7-0 | Unused |
The register is unused because at this time the Wave RAM is performing processor access cycle.
- Register Address: Channel Base + &50
| Bit | Description |
|---|---|
| Bits 7-4 | Waveform Number |
| Bits 3-0 | Unused |
- Register Address: Channel Base + &60
| Bit | Description |
|---|---|
| Bits 7-0 | Log Amplitude for the Channel |
The minimum amplitude is &00.
The maximum amplitude is &80.
Values below &40 are inaudible.
Values above &80 seem to cause distortion.
- Register Address: Channel Base + &70
| Bit | Description |
|---|---|
| Bits 7-6 | Unused |
| Bit 5 | Modulate next channel, modulo 8 (*) |
| Bit 4 | Invert waveform |
| Bits 3-0 | Stereo position |
(*) where next is in register address order not the channel processing order.
The stereo position allows 3-bit stereo position control (7 possible positions) as follows:
| Value | Left | Right |
|---|---|---|
| 1000 | 0% | 100% |
| 1001 | 0% | 100% |
| 1010 | 0% | 100% |
| 1011 | 17% | 83% |
| 1100 | 33% | 66% |
| 1101 | 50% | 50% |
| 1110 | 67% | 33% |
| 1111 | 83% | 17% |
| 0000 | 100% | 0% |
| 0001 | 100% | 0% |
| 0010 | 100% | 0% |
| 0011 | 100% | 0% |
| 0100 | 100% | 0% |
| 0101 | 100% | 0% |
| 0110 | 100% | 0% |
| 0111 | 100% | 0% |
Typically you will see &D (1101) used, which centres the channel
The below table illustrates the initial values of the channel registers when AMPLE has initialized.
Channel: 0 2 4 6 8 10 12 14 1 3 5 7 9 11 13 15
Address: x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF
0x: BE BE BE BE BE BE BE BE BE BE BE BE BE BE BE BE (Freq Lo)
1x: 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D 6D (Freq Mid)
2x: 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 01 (Freq Hi)
3x: (Unused)
4x: (Unused)
5x: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (Waveform)
6x: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (Amplitude)
7x: 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D (Control)
8x: BE BE BE BE BE BE BE BE (Freq Lo)
9x: 6D 6D 6D 6D 6D 6D 6D 6D (Freq Mid)
Ax: 01 01 01 01 01 01 01 01 (Freq Hi)
Bx: (Unused)
Cx: (Unused)
Dx: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (Waveform)
Ex: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 (Amplitude)
Fx: 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D 2D 0D (Control)
The blank entries indicate locations that appear not be be written by the AMPLE initialization code.
The initial frequency value of &16DBE (93630) corresponds to a frequency of:
- (6MHz / 128) / (2^24 / 93630)
- = 261.5992 Hz
Middle C happens to be 261.625565 Hz (which would correspond to 93639). I'm not sure why the numbers don't quite match up.
A program to generate this table is shown below:
10 MODE 0:@%=3
20 ?&FCFF=&3E
30 FOR A=0 TO 15
40 PRINT~A;
50 FOR B=0 TO 15
60 PRINT~?(&FD00+A*16+B);
70 NEXT
80 PRINT
90 NEXT
In this example we will configure channel 0 to cause channel 1 to modulate between two different frequencies.
First, load some Wave Definitions by running AMPLE and playing some music (e.g. concert) then hit break followed by control break to get back to BASIC.
Next, select the Music 5000 device on the 1MHz bus:
?&FCFF=&3E
Next, set channel 0 to a very low frequency (a couple of Hz):
?&FD00=&00
?&FD10=&05
?&FD20=&00
?&FD50=&00 :REM Waveform 0 is a square wave
?&FD60=&00 :REM Min amplitude
?&FD70=&2D :REM Set bit 5 to modulate next channel
Next, set channel 1 "normal" registers to (approx middle C):
?&FD01=&BE
?&FD11=&6D
?&FD21=&01
?&FD51=&C0 :REM Waveform 12 is a sin wave
?&FD61=&70 :REM Normal volume
?&FD71=&0D :REM Clear bit 5 not modulate next channel
Finally, set channel 1 "alternative" registers to a higher frequency:
?&FD81=&BE
?&FD91=&6D
?&FDA1=&02
?&FDD1=&C0 :REM Waveform 12 is a sin wave
?&FDE1=&70 :REM Normal volume
?&FDF1=&0D :REM Clear bit 5 not modulate next channel
You should now hear a sound like a old two-tone police car siren.
The modulation frequency can be adjusted by writing different values to ?&FD10.
Also for interest, I believe the Music 500 can play software PWM audio, though I never got around to trying it. Set all channels to phase 0, freq 0, and waveform 0, then feed anti-logged audio into waveform point 0.
Another option as yet unused is modulating modulation, i.e. channel 1 A+B modulation ON, channel 2 A modulation ON, B OFF, channel 3. With sync this should again provide new wave-shaping - for harmonic timbral control. reference
The original Music 5000 schematic.
A description of How Music 5000 Works from ETI (Electronics Today International).
The datasheet for the AM6070 Companding DAC.
A 6502.org thread with contributions from Chris Jordan.
Chris Jordan, the original hardware designer, for a very clever design and for being supportive of my efforts to reverse engineer it.