Amiga Basic Tutorial

Sound

The Amiga comes with its own sound chip called Paula and it is programmed via the audio.device. You can create sound on this by opening the device, setting the appropiate parameters and sending the raw sound data to the device to be played. If sound is in a particular format, such as 8SVX, MUS, WAV etc then the sound data must be extracted from the files and then sent to the audio.device. This can be a complex process, although datatypes can help a lot to reduce the amount of code required to produce sound. The sound data has to be stored in chip memory to be played and this can limit the size of the sound file to be played unless various buffering techniques are used.

Playing sound

BEEP
SOUND freqency, duration [, [volume] [,voice]]
SOUND WAIT
SOUND RESUME
WAVE voice, wave-definition

The Beep statement makes a simple beep sound, useful for alerts.

The Sound Statement is used to created sound or a queue of sounds (using the WAIT option) through the speaker. If sound is queued by using the WAIT option at the start, the RESUME option will start playing the sound.

Frequency is an integer and is measured in Hertz (Hz) and can be from 20 Hz to 15000 Hz e.g. C = 130.81 Hz, D = 146.83 Hz, E = 164.81 Hz, F =174.Hz. Doubling the frequency will produce a notice one octave higher.
The Duration is an integer from 0 to 77. Once second equals a duration of 18.2, duration of 77 equals 4.25 seconds.
The Volume is the the loudness from 0 (low) to 255 (high), if not specified, the volume default is 127.
The voice specifies the audio channel 0 and 3 is left channel, 1 and 2 is the right channel. Default is 0.

This example, plays an A note at 440 Hz, a for about a second at volume of 20 and on chaneel 0.
e.g. SOUND 440,20,100,0

The WAVE statement can add versilitily to the the Sound statement by using a number array to define the 'shape' of the sound. The voice is the channel number from 0-3 and the wave-definition can be the keyword SIN for a Sine wave or an array of at least 256 values of 128 to 127.
e.g. WAVE 0, SIN

Speech

On the AmigaOS 1.3, it includes a translate library for speech synthesis and can use it to speak to you using a male, female or a robotic type voice.

SAY "string" [,mode-array]
TRANSLATE$("string")

The SAY statement will speak the words in the string value. The string contains phonemes to make is easier for the Amiga to interpret the words into sounds correctly. The mode array describes the characteristics of the voice such as pitch of 65-320, inflection of values 0 or 1, rate from 40 to 400, voice of 0 (male) or 1 (female), Tuning or sample frequency from 5000 to 28000, volume from 0 to 64, channel (0-3), mode which can be synchronous (0) or asynchronous (1), control (0,1,2).
e.g.
SAY TRANSLATE$("The Amiga is the best home computer.")

Next page


 

 

Next Page