Difference between revisions of "SOUND"
m (→Defined channel numbers) |
(→Description) |
||
Line 19: | Line 19: | ||
== Description == | == Description == | ||
<code>SOUND</code> calls [[OSWORD &07]] to generate sounds. It is most | <code>SOUND</code> calls [[OSWORD &07]] to generate sounds. It is most | ||
− | commonly used to generate sounds with the internal | + | 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 | can also be used to create speech or MIDI sounds, as specified by the | ||
channel parameter. | channel parameter. |
Revision as of 01:00, 2 February 2019
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. |
Contents
Description
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] |
Implementation
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 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.
Uncertain if b0-b7 of the channel number is ignore or if the channel is checked for being equal to &2000.
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 -258,Command,Note,Velocity - (channel=&FEFE) Send raw MIDI command
- SOUND -257,Command,Note,Velocity - (channel=&FEFF) Send to current channel
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 will send to MIDI channel 3.
Note and Velocity should be supplied as with bit 7 clear (ie, &00-&7F), though bit 8 and higher are ignored.
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.
Trivia
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 etc.
References
Jgharston 00:30, 2 January 2008 (UTC)