Title: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II
1Beyond the BeepSequencer-Controlled Music
Synthesis for 8-bit Apple IIs
- Michael Mahon
- http//home.comcast.net/mjmahon
2The Apple II speaker(and cassette output)
- Can only toggle 1-bit output
- Cant choose polarity
3Simple Sound
- Double-frequency timing loop
- Squarewaves (beep, etc.)
- Actual frequency timing loop
- Non-50 duty cycles, timbre (Red Book)
- Infinitely-clipped 1-bit sound
- Distorted speech and music (Hex Dump Reader,
Audex, etc.)
4Complex Sound
- Ultrasonic timing loop Software DAC
- Variable duty cycle pulses
- Electric Duet (4 duty cycles 2-bit precision)
- Software Automatic Mouth (?)
- DAC522 (32 duty cycles 5-bit precision)
5DAC Timing Constraints
- 11kHz 92 Apple II cycles/sample
- 1/92cy 11.092kHz, 67Hz, 0.6
- Apple II timing resolution 1 cycle
- 4 cycles required to flip speaker
- Requires 8 cycles per pulse
- 4-cycle minimum pulse width
- 6-cycle practical minimum pulse width
- Sound amplitude Dwidth / period
- 32/46 70 of squarewave volume
6DAC522 Pulse Generators
Sample value
46 cycles
46 cycles
40
6
6
40
00
39
7
7
39
01
38
8
8
38
02
37
9
9
37
03
9
37
37
9
31
7DAC522Two 46-cycle pulse periods, 5-bit precision
- 32 separate pulse generators
- Each generator
- Is aligned at a fixed offset on consecutive pages
- Generates two 6..37-cycle pulses in 92 cycles
- Counts samples to advance envelope pointer
- Fetches next sample and sets vector
- Tests for end of note
- Vectors to next generator
- Computation is distributed between pulse edges
Pulse frequency of 22kHz is (almost) inaudible
8Other Issues
- Starting and stopping without pops
- Solution Never stop!
- Ramp waves to start and stop at 0 level
- Only end a note when sample value is 0..3
- Generate continuous 0-level pulses
- 6 cycles every 46 cycles
- Generating many/long sounds at 11kB/second
- Solution Direct Digital Synthesis
- Resample wavetables on-the-fly
- Use envelope table for dynamics
9Voice Envelope (Banjo)
- Wave shape and amplitude change with time
- Changes diminish with time
- Wave can usually be compressed significantly
10Voice Compression
0 .1 .2
seconds .3 .4
.5
1 2 3 4 5 6 7
8 9
Envelope page
- Just 10 wave pages can represent a banjo
11Actual Voice Wave Pages
1 2 3
1
2
3
- Negative envelope has been subtracted
- Samples have been rounded to 5 bits (32 levels)
12DAC522 Generator Code
0840 8D 30 C0 gt41 rgen0 sta spkr
lt start time 0 0843 EA gt42
nop Kill 2 cycles 0844 8D 30 C0
gt43 sta spkr lt stop
time 6 0847 EA gt44 nop
Kill 2 cycles 0848 EA gt45
nop Kill 2 cycles 0849 EA
gt46 nop Kill 2
cycles 084A EA gt47 nop
Kill 2 cycles 084B 08 gt48
php Kill 7 cycles 084C 28
gt49 plp 084D E6 ED
gt50 inc scount Compute
envelope 084F F0 01 gt51 beq 3
If , branch to iny 0851 A5 gt51
dfb A5 "lda C8" to skip
iny 0852 C8 gt51 iny
0853 18 gt52 clc
0854 A5 EC gt53 lda frac
Compute next sample 0856 65 FE gt54
adc freq 0858 85 EC gt55
sta frac 085A 8D 30 C0 gt56
sta spkr lt start time 46 085D 8A
gt57 txa 085E 8D 30
C0 gt58 sta spkr lt stop
time 52 0861 6D FF 00 gt59 adca
freq1 0864 AA gt60 tax
0865 B1 06 gt61 lda
(env),y Next sample page 0867 8D 6C 08 gt62
sta ptr2 086A BD 00 00 gt63
ptr ldaa 00,x Fetch sample. 086D
8D 7C 08 gt64 sta sw02 0870
AD 10 C0 gt65 lda AKD 0873
C5 EF gt66 cmp key Key
changed? 0875 F0 03 gt67 beq sw0
-No, keep playing. 0877 4C 77 10 gt68
jmp newkey -Yes, handle it. 087A
4C 40 08 gt69 sw0 jmp rgen0 Switch
to rgen, T 89
Generate pulse
Advance envelope
Compute next sample
Generate pulse 2
Compute next sample
Test for end of note
13A2 DMS II / DMS Drummer IISingle-voice
multi-timbral real-time wavetable synthesizers
- Support up to 8 different instruments (one at a
time) - Voice is represented as a set of single-cycle
waveshapes selected by a table representing the
envelope of the voice. - Voice waves resampled on-the-fly to desired note
pitch - Frequency Integer.fraction sample index
increment - Wavetable waveforms start and end at zero
amplitude to minimize pops - Resting or idling sound is the zero-level pulse
train
14A2 DMS II Help Screen
15DMS Drummer II Sequencer
16DMS Drummer II Performance
17Controlling the Synthesizers(the end test)
- A2 DMS II
- Keyboard control
- Playback control
- Serial port control
- DMS Drummer II
- Internal sequencer control (drum machine)
- Keyboard control
- Serial port control
Serial port control allows external MIDI control
18Questions and discussion...