Skip to navigation

Aviator on the BBC Micro

Sound: soundData

Name: soundData [Show more] Type: Variable Category: Sound Summary: OSWORD blocks for making the various game sounds
Context: See this variable in context in the source code References: This variable is used as follows: * MakeEngineSound calls soundData * MakeSound calls soundData * ProcessVolumeKeys calls soundData * ResetEngineSound calls soundData

Sound data. To make a sound, the MakeSound passes the bytes in this table to OSWORD 7. These bytes are the OSWORD equivalents of the parameters passed to the SOUND keyword in BASIC. The parameters have these meanings: channel/flush, amplitude (or envelope number if 1-4), pitch, duration where each value consists of two bytes, with the low byte first and the high byte second. For the channel/flush parameter, the top nibble of the low byte is the flush control (where a flush control of 0 queues the sound, and a flush control of 1 makes the sound instantly), while the bottom nibble of the low byte is the channel number . When written in hexadecimal, the first figure gives the flush control, while the second is the channel (so &13 indicates flush control = 1 and channel = 3). So when we call MakeSound with A = 5 to make sound #5, this is what the routine effectively does: SOUND &10, -13, 4, 12 which makes a sound with flush control 1 on channel 0, and with amplitude -13, pitch 4 and duration 12. Meanwhile, sound #2 is like this: SOUND &13, 2, 220, 2 which makes a sound with flush control 1 on channel 3, using envelope 2, and with pitch 220 and duration 2. The two sound envelopes (1 and 2) are set up by the DefineEnvelope routine.
.soundData EQUB &10, &00 \ Sound #0: Stop engine sound (SOUND &10, 0, 0, 0) EQUB &00, &00 EQUB &00, &00 EQUB &00, &00 EQUB &10, &00 \ Sound #1: Engine amplitude (SOUND &10, -5, 3, 255) EQUB &FB, &FF \ EQUB &03, &00 \ Second parameter (soundData+10) gets changed in the EQUB &FF, &00 \ ProcessVolumeKeys routine to alter the volume EQUB &13, &00 \ Sound #2: Alien destroyed (SOUND &13, 2, 220, 2) EQUB &02, &00 \ EQUB &DC, &00 \ Uses sound envelope 2 EQUB &02, &00 EQUB &13, &00 \ Sound #3: High g-forces (SOUND &13, -15, 120, 7) EQUB &F1, &FF EQUB &78, &00 \ This sound is a long, medium beep that indicates the EQUB &07, &00 \ plane's wings are coming off EQUB &13, &00 \ Sound #4: Plane is stalling (SOUND &13, -12, 0, 1) EQUB &F4, &FF \ EQUB &00, &00 \ This sound is a short, low beep EQUB &01, &00 EQUB &10, &00 \ Sound #5: Crash (SOUND &10, -13, 4, 12) EQUB &F3, &FF EQUB &04, &00 EQUB &0C, &00 EQUB &13, &00 \ Sound #6: Our gunfire (SOUND &13, 2, 60, 2) EQUB &02, &00 EQUB &3C, &00 EQUB &02, &00 EQUB &11, &00 \ Sound #7: Engine pitch (SOUND &11, 1, 255, 255) EQUB &01, &00 \ EQUB &FF, &00 \ Uses sound envelope 1 EQUB &FF, &00 \ \ The fifth byte (soundData+60) is the low byte of the \ sound's pitch and gets changed in various places \ to change the pitch of the engine sound