Commodore 128 Programmer's Reference Manual page 364

Hide thumbs Also See for 128:
Table of Contents

Advertisement

354
COMMODORE 128
Here's the general algorithm to output sound from the SID chip in voice 1.
1.
Clear the sound chip (For $D400-$D41C)
0
u
2.
Select ATTACK and DECAY for each voice ($D405)vl
(J
3.
Select SUSTAIN and release for each voice ($D406) vl
4.
Select a waveform ($D404 for vl)
5.
Set the volume ($D418)
I j
6.
Set the frequency of the note with a low byte ($D400) and high byte
^
($D401) from the Musical Note Table in Figure 11-15 at the end of this chapter.
If you want to output a certain frequency level, use this equation:
j
Fn = F out/.06097
°
Round off the (Fn) frequency with the integer function and divide the result into the
, ,
low byte and high byte.
| J
In decimal:
<-*
Fhi = Fn/256 is the high byte
and:
\ i
Flow = Fn -(256 * Fhi) is the low byte
To get a feel for the ranges of notes, experiment with the SOUND command in
H
BASIC.
U
7.
Place the high byte in Frequency Control Register (in $D401) for the
appropriate voice.
\
8. Place the low byte in the (low byte) frequency control register for the
^
appropriate voice ($D400).
9.
Initiate (GATE) the note or tone. Gating means to start the ATTACK,
) j
DECAY and SUSTAIN cycle of the tone. Set bit 0 of $D404 (VI), $D40B(V2)
(J
and $D412(V3), respectively.
10.
Leave bit 0 set for the duration you wish to play the note or tone.
11. Clear the GATE bit.
j J
Lj
The durations of the standard musical notes are as follows:
NOTE TYPE
DOTTED
Va +
DOTTED
Vi +
Vi +
DOTTED
WHOLE
!/l6
Vs
Vs
Va
V\6
Va
Vi
V\6
Vs
Vi
DURATION
128
256
384
512
640
768
1024
1152
1280
1536
2048

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents