Sound Library Utility

Create a reference library of your favourite sounds. We give you 26 to get you started.

Volume 2

Number 2

April 1984

Sound Library

JOHN TISSANDIER'S filing system allows you to pick sounds for your programs off the shelf

THE aim of this program is to create a store of interesting sounds that can be sampled and the parameters noted for use in one's own programs.

It is not meant to be an ENVELOPE designer, but depends on already having sounds worth saving. These can be taken from the Sounds Exciting pages of Electron User, or from games.

Running the program will display the menu:

LOAD FILE: This will prompt the user for the name of a file already saved.

INPUT NEW SOUNDS: Twenty six sounds can be saved on one file and are labelled A to Z. The user will be prompted to press a letter.

On the right of the display he will be reminded of the first free letter. On first running this will of course be A.

Then he will be asked to supply a descriptive name for the sound, such as "Crash!". This can be up to 24 characters long.

Next he will be asked to input the parameters for the ENVELOPE and SOUND statements. The labels are the same as the ones used in the User Guide.

Finally, the user is asked if he is happy with the numbers input. If the answer is N then the initial values can be overwritten. Pressing Y will send the program back to the menu. LISTEN TO SOUNDS: This displays the names of all the sounds entered, labelled from A to Z. Pressing any letter will cause that sound to be played, and the ENVELOPE and SOUND statements to be displayed at the bottom.

If you wish to stop the sound before its natural completion then press a key (the space bar is the most convenient). Another letter can now be pressed and another sound heard.

To return to the menu press Return. SAVE SOUNDS: This will save the names and parameters of the sounds input on a file. The user is asked for a filename. After saving the program returns to the menu.

There are a few important points to note when using the program.

If a section of the program is entered by error, pressing Return by itself will always return the user to the menu.

This is also the way to return to the menu from the LISTEN TO SOUNDS section.

It is important to fill up the available spaces (labelled A to Z) alphabetically. This is because the savefile procedure will check for the first empty element in the name array and only save up to that point.

Anything beyond a blank name will be ignored. This is so as not to waste time saving empty sections of the arrays on file.

The program is written in Mode 3, which gives 80 characters to a line. It was developed using a monitor.

If there is too much flickering when used with a TV set try *TVO,1 and remove the background effect by deleting line 200. '

Although the program displays the letter label of the next available space, the user could accidently overwrite data.

Line 690 could be altered to include an "Are you sure?" function if it detects data already present in the element of the name array chosen by the user.

Each of the parameters of the ENVELOPE and SOUND statements has its own specific upper and lower limits.

Line 900 in PROCparameters merely performs a universal crude check of seeing that the number input is no greater than 255 and not less than -128.

A function could be inserted here to provide a more precise individual check on each parameter.

The procedures are self-explanatory. FNmax checks how many sounds have been input. PROCstatement prints out the ENVELOPE and SOUND statements for the sound being heard.

Arrays

name$(26) Name of sound.
e%(13,26) Envelope statement parameters.
s%(3,26) Sound statement parameters.

Global variables

az% A number from 0 to 25 (corresponding to a letter of the alphabet) which selects the sound to be input or heard.
e$ ENVELOPE
s$ SOUND

Formal parameters

s$ Pass on to PROCparameters whether envelope or sound statement.
y% Pass on y-coordinate of TAB.
n% Size of loop.
a$ "e" or "s".

Local parameters

o% Menu option.
k%,l% FOR ... NEXT loops.
para% Input parameters for envelope and sound statements.
fname$ Filename.
rf%,sf% File channels.
max% Number of sounds input (this controls loop in PROC-savefile, etc.).
wait% Delay.
nameS Input name of sound.
g$ GETS
X% x-coordinate of TAB.
c% Counter in REPEAT.. UNTIL loop in FNmax.

Special points

(refers to line number of program)

40 Lower display by one line to centre background effect.
180 Disable escape key.
190 Change field width to five characters.
200 Change logical colour 0 (black) to actual colour 4 (blue).
220-240 Set string array to maximum length and then return to null string.
460,700,1380 Pressing Return returns to menu.
670 Checks for next empty element in name array and prints its label.
1040, 1110 Turns flashing cursor off/on to improve display.
1090 This line delays program while sound is heard. The delay is proportional to the duration of the note, given by s%(3,az%). Using INKEY means that pressing a key before the end of the delay causes *FX 15,0 to flush the sound buffer and the sound stops.
1280 Using EVAL and passing on "e" and "s" allows the envelope and sound parameter arrays to be read by the same loop.
1610 Data statement for built-in sound heard when returning to menu from LISTEN TO SOUNDS option. This is stored in the 26th elements of the arrays and is read in at lines 250,260 (Note that Sound A starts at 0 and Z at 25.)

It seemed a shame to present you with such a useful Sound Library program without any sounds to put in it, so we prevailed upon the Editor of Electron User to give us some of his from Sounds Exciting collection. I think someone out there ought to write a roar of approval for him . . .

SOUND AN ALARM ENVELOPE 1,5,1,2,80,15,0,0, 126,0,0,-126,126,126 SOUND 1,1,25,254
SOUND B ALARM CLOCK ENVELOPE 6,1,70,16,2,2,0,0, 126,0,0,-126,126,126 SOUND 1,6,100,254
SOUND C WARSHIP'S SIREN ENVELOPE 2,1,5,0,0,25,0,0, 126,0,0,-126,126,126 SOUND 1,2,40,254
SOUND D ROAD WORKS ENVELOPE 5,1,70,16,0,31,0,0, 126,0,0,-126,126,126 SOUND 0,5,80,254
SOUND E THE MARTIAN'S APPROACH ENVELOPE 4,12,10,8,6,4,0,0, 126,0,0,-126,126,126 SOUND 0,4,4,254
SOUND F SWALLOWED IN ONE GULP ENVELOPE 1,1,43,0,0,100,0,0, 126,0,0,-126,126,126 SOUND 1,1,17,18
SOUND GHAR HAR ENVELOPE 1,6,126,0,0,206,0,0,126,0,0,-126,126,126 SOUND 1,1,100,200
SOUND H CAR STARTING ENVELOPE 1,1,3,0,0,7,7,0, 126,0,0,-126,126,126 SOUND 0,1,63,84
SOUND I GOING UP ENVELOPE 4,16,16,1,1,200,0,0, 126,0,0,-126,126,126 SOUND 1,4,30,36
SOUND J FANFARE ENVELOPE 2,2,6,0,0,255,0,0, 126,0,0,-126,126,126 SOUND 1,2,4,50
SOUND K MACHINE GUN ENVELOPE 3,3,6,4,6,2,0,0, 126,0,0,-126,126,126 BOUND 1,3,4,48
SOUND L WAILING BUGS ENVELOPE 4,4,-l,1,0,20,20,0, 126,0,0,-126,126,126 BOUND 1,4,200,254
SOUND M IN THE FACTORY ENVELOPE 1,5,1,20,8,200,0,0, 126,0,0,-126,126,126 SOUND 0,1,1,200
SOUND N ELECTRIC SPARK ENVELOPE 0,0,0,0,0,0, 0,0,0,0,0,0,0,0 SOUND 0,-15,7,254
SOUND OPOLICE SIREN ENVELOPE 1,1,-7,7,0,10,10,0, 126,0,0,-126,126,126 SOUND 1,1,136,254
SOUND P UP AND ANAY ENVELOPE 2,1,1,0,0,200,0,0, 126,0,0,-126,126,126 SOUND 1,2,0,40
SOUND Q CRAZY MACHINERY ENVELOPE 5,1,70,6,0,31,10,0, 126,0,0,-126,126,126 SOUND 1,5,100,254
SOUND R ATTACK BY MUTANT FLIES ENVELOPE 6,1,36,-36,0,20,20,0, 126,0,0,-126,126,126 SOUND 1,6,160,254
SOUND S BUBBLES ENVELOPE 1,1,25,25,25,8,8,8, 127, 127,127,127,127,127 SOUND 1,1,200,20
SOUND T TUNE ENVELOPE 2,28,-108,-17,-19,61, 76, 193,-63,-117,-l,-50,107,74 SOUND 1,2,100,150
SOUND U REVERBERATION ENVELOPE 2,8,1,-1,1,1,1,1, 121,-10,-5,-2,120,120 SOUND 0,2,0,40
SOUND V STATIC ENVELOPE 0,0,0,0,0,0, 0,0,0,0,0,0,0,0 SOUND 4,-15,100,254
SOUND W SPLASH ENVELOPE 1,129,0,-10,-1,1,0, 2,6,-l,0,-l,126,74 SOUND 0,1,7,14
SOUND X CHIME PART1 ENVELOPE 1,1,0,0,0,50,25,25, 127,-1,-1,-1,126,90 SOUND 1,1,150,8
SOUND Y CHIME PART2 ENVELOPE 1,1,0,0,0,50,25,25, 127,-1,-1,-1,126,90 SOUND 1,1,140,5
SOUND Z GUN ENVELOPE 1,1,0,0,0,0,0,0,126,-1,0,-3,126,126 SOUND 0,1,6,4