From BeebWiki
Jump to: navigation, search

SOUND is a BASIC command to make sounds.

Availability Present in all original versions of BBC BASIC.
Syntax SOUND <numeric>,<numeric>,<numeric>,<numeric>
Token (hex) D4 (command)
Description Generates sounds.



SOUND calls OSWORD &07 to generate sounds. It is most commonly used to generate sounds with the internal sound generator, but it can also be used to create speech or MIDI sounds, as specified by the channel parameter.

Defined channel numbers

&0xxx Sound generator
&1xxx Sound generator
&20xx Watford Electronics Speech system[1]
&FExx MIDI control [2]
&FFxx Speech system [3]


Internal sound system

SOUND &0xxx,volume,pitch,duration

SOUND &1xxx,volume,pitch,duration

The channel number encodes &HSFC where:

  • H: Hold 0 or 1
  • S: Sync 0 to 15, 0 to 3 usually implemented
  • F: Flush 0 or non-0 (usually 0 or 1)
  • C: Channel 0 to 15, 0 to 3 usually implemented

The internal sound system implements 4 channels (1 on the Electron), but extensions can increase the number of supported channels. For example, the Electron Sound Expansion supports four channels, and MIDI redirection can support 16 channels treating each channel as a polyphonic note. Channel 0 is conventionally a 'noise' channel.

The volume, pitch and duration are 8-bit numbers with bit 8 and higher ignored.

Watford Speech

SOUND &20xx,word,library,0

Watford speach commands can be sent with SOUND &2000, which is usually coded as SOUND 8192.

Bit 0-7 of the channel number is ignored.

MIDI control

SOUND &FExx,command,note,velocity

MIDI commands can be sent with SOUND &FEFF and SOUND &FEFE which are usually coded as SOUND -257 and SOUND -258.

  • SOUND -257,Command,Note,Velocity - Send to current channel (channel=&FEFF)
  • SOUND -258,Command,Note,Velocity - Send raw MIDI command (channel=&FEFE)
  • SOUND -257 or -258,Control<0,num,num - MIDI system control

If Command is &0000-&007F it is a MIDI data byte and sent stright to the MIDI system unchanged. This allows extended sequences to be sent, such as MIDI System Exclusives.

If Command is &0080-&00FF it is a MIDI command byte. Command bytes &80-&EF are channel-specific commands. SOUND -258 uses them as supplied, SOUND -257 sends them to the current MIDI channel by adding the current channel to the bottom nybble. So, if the current MIDI channel is 4, SOUND -257,&80... will send to MIDI channel 4, and SOUND -257,&8F should send to MIDI channel 3. Some implementations do not correctly round the channel number within the nybble in the second example.

Note and Velocity are 7-bit numbers with bit 7 and higher ignored, other than MIDI command &Ex which can specify a 14-bit Note number.

Speech system

SOUND &FFxx,command,0,0 The channel number indicates what to do with the command, the command is an 8-bit number with bit 8 and higher ignored.

  • SOUND &FFFx,number,0,0 - speak from PHROM 15-x with word number. From a coding view this is usually written as SOUND -1,n,0,0 to SOUND -16,n,0,0.
  • SOUND &FFBx,address,0,0 - speak from PHROM 15-x from the absolute address.
  • SOUND &FF60,command,0,0 - start sending speech using phoneme 'command.
  • SOUND &FF00,command,0,0 - continue sending speech using phoneme 'command.

SOUND &FF01-&FF7F actually send the bottom byte as the Speech command to use.


SOUND Channels
%000H SSSS FFFF CCCC  Internal sound system
%0010 0000 xxxx xxxx  Watford Electronics Speech
%1111 1110 1111 111x  MIDI control
%1111 1111 xxxx xxxx  Speech

Sound system
SOUND %000hssss:xxxfcccc, %xxxxxxxx:xxxvvvvv, %xxxxxxxx:pppppppp, %xxxxxxxx:dddddddd - Make sound

Watford Speech
SOUND %00100000:xxxxxxxx, %xxxxxxxx:wwwwwwww, %xxxxxxxx:llllllll, %xxxxxxxx:xxxxxxxx - Speak word

SOUND %11111110:xxxxcccc, %0xxxxxxx:0ddddddd, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - MIDI data
SOUND %11111110:xxxxcccc, %0xxxxxxx:10dddddd, %xxxxxxxx:xnnnnnnn, %xxxxxxxx:xvvvvvvv - MIDI note
SOUND %11111110:xxxxcccc, %0xxxxxxx:110ddddd, %xxxxxxxx:xnnnnnnn, %xxxxxxxx:xxxxxxxx - MIDI change
SOUND %11111110:xxxxcccc, %0xxxxxxx:1110dddd, %xxvvvvvv:vvvvvvvv, %xxxxxxxx:x0000000 - MIDI bend
SOUND %11111110:xxxxcccc, %0xxxxxxx:1110dddd, %xx000000:0vvvvvvv, %xxxxxxxx:xvvvvvvv - MIDI bend
SOUND %11111110:xxxxcccc, %0xxxxxxx:1111dddd, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - MIDI system
SOUND %11111110:1111111c, %1xxxxxxx:1111dddd, %xxxxxxxx:nnnnnnnn, %xxxxxxxx:xxxxxxxx - MIDI control
                                  MIDI command if b15=0 and b7=0
SOUND %11111111:11xxrrrr, %xxxaaaaa:aaaaaaaa, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - Speak word
SOUND %11111111:10xxrrrr, %xxaaaaaa:aaaaaaaa, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - Speak from address
SOUND %11111111:0cccxxxx, %dddddddd:dddddddd, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - Speak data word
SOUND %11111111:00000000, %dddddddd:dddddddd, %xxxxxxxx:xxxxxxxx, %xxxxxxxx:xxxxxxxx - Speak data word
                   if b7=0, if<>0, sent to Speech as command, normally use &FF60 for Speak External


In the original development of BBC BASIC, the sound command was BEEP which can be seen from the token position for SOUND, alphabetically with other keywords starting with 'B'[4]:

 Originally:   Became:
 D4: BEEP      D4: SOUND
 D5: BPUT      D5: BPUT
 D6: CALL      D6: CALL
 D7: CHAIN     D7: CHAIN


  1. Watford Speech Synthesizer Manual
  2. *MIDI command
  3. Speech System User Guide
  4. Outline specification of the BASIC language interpreter, 1981

Jgharston 00:30, 2 January 2008 (UTC)