CMD SND
This page was last modified 09:40, 17 May 2020 by Mars2000you.

Contents

Effect

Controls the two stereo Philips SAA1099 sound generators, considered as one processor with 64 registers.

Syntax

CMD SND <Register>, <Value>

Parameters

<Register> is a number between 0 and 63. Numbers 0 to 31 correspond to the first sound generator, numbers 32 to 63 correspond to the second sound generator. Some registers don't have a specific function.

<Value> can be a number between 0 and 255.

Registers Description

Generator 1 Generator 2 Function Generator 1 Generator 2 Function
0 32 Volume channel 0
Bits 0 to 3:Right
Bits 4 to 7:Left
16 48 Bits 0 to 2: Octave channel 0
Bits 4 to 6: Octave channel 1
1 33 Volume channel 1
Bits 0 to 3:Right
Bits 4 to 7:Left
17 49 Bits 0 to 2: Octave channel 2
Bits 4 to 6: Octave channel 3
2 34 Volume channel 2
Bits 0 to 3:Right
Bits 4 to 7:Left
18 50 Bits 0 to 2: Octave channel 4
Bits 4 to 6: Octave channel 5
3 35 Volume channel 3
Bits 0 to 3:Right
Bits 4 to 7:Left
19 51 Not used
4 36 Volume channel 4
Bits 0 to 3:Right
Bits 4 to 7:Left
20 52 Sound On (bits 0 to 6)
5 37 Volume channel 5
Bits 0 to 3:Right
Bits 4 to 7:Left
21 53 Noise On (bits 0 to 6)
6 38 Not used 22 54 Bits 0 and 1: Noise Generator 0
Bits 4 and 5: Noise Generator 1
7 39 Not used 23 55 Not used
8 40 Note channel 0 24 56 Envelope channel 2
9 41 Note channel 1 25 57 Envelope channel 5
10 42 Note channel 2 26 58 Not used
11 43 Note channel 3 27 59 Not used
12 44 Note channel 4 28 60 Chip ON/OFF (bit 0)
13 45 Note channel 5 29 61 Not used
14 46 Not used 30 62 Not used
15 47 Not used 31 63 Not used


About registers 0 to 5 / 32 to 37:

The volume of a channel is set separately for left and right, the following formula can be used:

VOLUME = 16 x LEFT VOLUME + RIGHT VOLUME 

For mono use, this formula is also useful:

VOLUME = 17 x VOLUME

VOLUME can be adjusted from 0 to 15, where 0 turns off the channel and 15 is the loudest.


About registers 8 to 13 and 16 to 18 / 40 to 45 and 48 to 50:

For each channel, the processor can produce 8 (octaves) x 256 ('notes') = 2048 different tones. Per octave there are, of course, only twelve actual notes (standard note system). Here are the corresponding 'note' value for all notes:

Note Value Note Value
C 25 F# 152
C# 46 G 17
D# 89 A 216
E 110 A# 237
F 131 B 4 (*)

(*) For a B in octave n , the octave register must be filled with the value n + 1 and the note register with the value 4.

Note: The value for D is omitted in transcription.

The correspondance between the octaves and the frequency generator output is as follows:

Bit 2 (or 6) Bit 1 (or 5) Bit 0 (or 4) Frequency
0 0 0 31Hz to 61Hz
0 0 1 61Hz to 122Hz
0 1 0 122Hz to 244Hz
0 1 1 244Hz to 488Hz
1 0 0 489Hz to 977Hz
1 0 1 978Hz to 1.95kHz
1 1 0 1.96kHz to 3.91kHz
1 1 1 3.91kHz to 7.81kHz


About register 20 / 52:

The channel is switched on and off by means of the bits in register 20.

A 1 in this register means that the channel is passed on at the output (in order to get sound, the volume must of course be open, and the chip 'on').

To turn all channels on CMD SND 20,31 is used, but (for convenience) CMD SND 20,255 can also be used. The upper two bits have no meaning.


About register 21 / 53:

Noise can be turned on using register 21. The chip has 2 noise generators: noise of generator 0 can be mixed with channels 0 to 2, noise of generator 1 can be mixed with channels 3 to 5, only with pre-defined noises based on a fixed clock (see register 22 / 54).


About register 22 / 54:

The 'shape' of the noise is determined with the values ​​in register 22. This is done with two bits (0 and 1 for noise generator 1, 4 and 5 for noise generator 2):

Bit 1 (or 5) Bit 0 (or 4) Noise clock
0 0 31.3 kHz
0 1 15.6 kHz
1 0 7.6 kHz
1 1 61 Hz to 15.6 kHz(*)

(*) based on double the frequency generator output of generator (channel) 0 or 3


About registers 24 and 25 / 56 and 57

These registers control the envelope, respectively for channel 2 and for channel 5. The meaning of the bits is as follows:

Bits Values
7 0 = reset (no envelope control)
1 = envelope control enabled
6 Must always be 0
5 0 = internal envelope clock (frequency generator 1 or 4)
1 = external envelope clock (address write pulse)
Value 1 not possible in Tyzack 64-M system
4 0 = 4 bits for envelope control (maximum frequency = 977Hz)
1 = 3 bits for envelope control (maximum frequency = 1.95kHz)
3 to 1 0 0 0 = zero amplitude
0 0 1 = maximum amplitude
0 1 0 = single decay
0 1 1 = repetitive decay
1 0 0 = single triangular
1 0 1 = repetitive triangular
1 1 0 = single attack
1 1 1 = repetitive attack
0 0 = same envelope for left and right channels
1 = right channel has inverse of the envelope for left channel


For the frequencies of the generators there is a formula that can sometimes be useful:

frequency = 8000000 / 2^(17 - octave + (1 - note/255))

From this frequency the speed of the envelope can be calculated when it is clocked from generator (channel) 1 or 4:

8/frequency for a 4 bits envelope
4/frequency for a 3 bits envelope

Related to

CMD ALF, CMD ALN

Compatibility

Tyzack64M BASIC