CHAPTER 4
cymbals. Those whose volume is varied according to a small-
period waveform hum like a motor. Both noise and tones
may be enabled in a single channel, which then produces
both types of sound.
Figure 4-3. Waveform Shapes and the Sounds They Create
Register
13
Haveforn Control Bits
Bit 3
Bit 2
Bit 1
Bit 8
Uaveforn
Dec inal
Value
Continue
Attack
Alternate
Hold
0-3 B
B
- -
X
4-7 B 1
- -
A
___________
8 1 B B 8
3 1 B
B
1
IB 1 8 1 8
v v v w w
11 1 8
1 1 >4------------
12 1
1
8
B
/ W V V H / H 4 W
13 1 1 8 1
/
14
1
1
1
B
/ w w w \
IS 1 1
1 1
y|
II
V
Envelope Period
(duration of one cycle!
Program 4-3 demonstrates the use of the XBIOS Giac-
cess() call to produce tones of a constant volume. It turns
the top row of the ST keyboard into a musical keyboard.
Program 4-3. XGIACCES.C
/* XGIACCES.C — Demonstrates use of
/* PSG registers to produce musical
/* tones. The program turns the top
/ * row of the keyboard into a 'piano'.
/* To quit, press "q".
/*
/* ^
/a***************************************
#include <osbind.h> /* For macro definitions */
#define CON 2 /* console keyboard device no. */
unsigned notest 13) = /* the period setting for the notes */
/* of the chromatic scale */
{
478, /* C = 261.6 Hz */
451, / * C# = 277.2 Hz * /
426, /* D = 293.7 Hz * /
402, /* D# = 311.1 Hz * /
379, /* E = 329.6 Hz */
358, /* F = 349.2 Hz */
338, /* F# = 370.0 Hz */
319, / * G = 392.0 HZ * /
***/
*/
*/
*/
*/
*/
*/
*/
“ */
78