Commodore 128 Programmer's Reference Manual page 376

Hide thumbs Also See for 128:
Table of Contents

Advertisement

366
COMMODORE 128
EQUAL-TEMPERED
MUSICAL SCALE VALUES
n
The table in Figure 11-15 lists the numerical values which must be stored in the SID
Oscillator frequency control registers to produce the notes of the equal-tempered musical
] j
scale. The equal-tempered scale consists of an octave containing twelve semitones
LJ
(notes): C,D,E,F,G,A,B and C#,D#,F#,G#,A#. The frequency of each semitone is
exactly the 12th root of 2 (X^T) times the frequency of the previous semitone. The
i
table is based on a 02 clock of 1.02 MHz. Refer to the equation given in the Register
|
Description for use of other master clock frequencies. The scale selected is concert
pitch, in which A-4 = 440 Hz. Transpositions of this scale and scales other than the
equal-tempered scale are also possible.
j j
Although the table in Figure 11-15 provides a simple and quick method for
LJ
generating the equal-tempered scale, it is very memory inefficient as it requires 192
bytes for the table alone. Memory efficiency can be improved by determining the note
i (
value algorithmically. Using the fact that each note in an octave is exactly half the
LJ
frequency of that note in the next octave, the note look-up table can be reduced from
ninety-six entries to twelve entries, as there are twelve notes per octave. If the twelve
, ,
entries (24 bytes) consist of the 16-bit values for the eighth octave (C-7 through B-7),
then notes in lower octaves can be derived by choosing the appropriate note in the eighth
octave and dividing the 16-bit value by two for each octave of difference. As division by
two is nothing more than a right-shift of the value, the calculation can easily be
j j
accomplished by a simple software routine. Although note B-7 is beyond the range of
LJ
the oscillators, this value should still be included in the table for calculation purposes (the
MSB of B-7 would require a special software case, such as generating this bit in the
j" i
CARRY before shifting). Each note must be specified in a form which indicates which
|J
of the twelve semitones is desired, and which of the eight octaves the semitone is in.
Since 4 bits are necessary to select one of twelve semitones and 3 bits are necessary to
select one of eight octaves, the information can fit in one byte, with the lower nybble
selecting the semitone (by addressing the look-up table) and the upper nybble being
u
used by the division routine to determine how many times the table value must be
right-shifted.
j j
MUSIC NOTE VALUES
Figure 11-15 contains a complete list of Note#, actual note, and the values to be stored
into the HI FREQ and LOW FREQ registers of the sound chip to produce the indicated
note.
u
u
u

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents