18
Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon http://home.comcast.net/ ~mjmahon

Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Embed Size (px)

Citation preview

Page 1: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Beyond the BeepSequencer-Controlled Music Synthesis

for 8-bit Apple II’s

Michael Mahon

http://home.comcast.net/~mjmahon

Page 2: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

The Apple II speaker(and cassette output)

Can only toggle “1-bit output” Can’t choose “polarity”

Page 3: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Simple 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.)

Page 4: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

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

Page 5: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

DAC 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 = width / period 32/46 = 70% of squarewave volume

Page 6: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

DAC522 Pulse Generators

46 cycles

46 cycles

937 37 9

379 9 37

388 8 38

397 7 39

406 6 40

31

03

02

01

00

Sample value

Page 7: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

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

DAC522Two 46-cycle pulse periods, 5-bit precision

Pulse frequency of 22kHz is (almost) inaudible

Page 8: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Other 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

Page 9: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Voice Envelope (Banjo)

Wave shape and amplitude change with time Changes diminish with time Wave can usually be compressed significantly

Page 10: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Voice Compression

Just 10 wave pages can represent a banjo

1 2 3 4 5 6 7 8 9

0 .1 .2 seconds .3 .4 .5

Envelope page:

Page 11: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Actual Voice Wave Pages

Negative envelope has been subtracted Samples have been rounded to 5 bits (32 levels)

1 2 3

1

2

3

Page 12: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

DAC522 Generator CodeGenerate pulse

Generate pulse 2

Advance envelope

Compute next sample

Compute next sample

Test for end of note

0840: 8D 30 C0 >41 rgen0 sta spkr ; <=== start time: 00843: EA >42 nop ; Kill 2 cycles0844: 8D 30 C0 >43 sta spkr ; <==== stop time: 60847: EA >44 nop ; Kill 2 cycles0848: EA >45 nop ; Kill 2 cycles0849: EA >46 nop ; Kill 2 cycles084A: EA >47 nop ; Kill 2 cycles084B: 08 >48 php ; Kill 7 cycles084C: 28 >49 plp 084D: E6 ED >50 inc scount ; Compute envelope084F: F0 01 >51 beq *+3 ; If =, branch to iny0851: A5 >51 dfb $A5 ; "lda $C8" to skip iny0852: C8 >51 iny 0853: 18 >52 clc 0854: A5 EC >53 lda frac ; Compute next sample0856: 65 FE >54 adc freq 0858: 85 EC >55 sta frac 085A: 8D 30 C0 >56 sta spkr ; <=== start time: 46085D: 8A >57 txa 085E: 8D 30 C0 >58 sta spkr ; <==== stop time: 520861: 6D FF 00 >59 adca freq+1 0864: AA >60 tax 0865: B1 06 >61 lda (env),y ; Next sample page0867: 8D 6C 08 >62 sta :ptr+2 086A: BD 00 00 >63 :ptr ldaa 0*0,x ; Fetch sample.086D: 8D 7C 08 >64 sta :sw0+2 0870: AD 10 C0 >65 lda AKD 0873: C5 EF >66 cmp key ; Key changed?0875: F0 03 >67 beq :sw0 ; -No, keep playing.0877: 4C 77 10 >68 jmp newkey ; -Yes, handle it.087A: 4C 40 08 >69 :sw0 jmp rgen0 ; Switch to rgen, T = 89

Page 13: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

A2 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

Page 14: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

A2 DMS II Help Screen

Page 15: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

DMS Drummer II Sequencer

Page 16: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

DMS Drummer II Performance

Page 17: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Controlling 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

Page 18: Beyond the Beep Sequencer-Controlled Music Synthesis for 8-bit Apple II’s Michael Mahon mjmahon

Questions and discussion...