risoundlib2
This library is the successor of the first sound library
(risoundlib).
It has the same CludgeSound, which makes a sound object of
audiolib from an
IFF 8SVX sample in memory. It adds commands for AHI, the retargetable
audio system for the Amiga (ahi.device, version 4 or newer): opening
the device, playing sound objects and raw samples through it, and
AHI’s requester for choosing an audio mode.
OpenAHI opens the device and must come before the other AHI
commands; CloseAHI closes it again, and the end of the program does
too. PlaySoundAHI plays a sound object, such as one made with
CludgeSound or LoadSound, and returns while it plays; the next
PlaySoundAHI or PlayRawAHI stops it. AHIOutputRequest shows the
requester, and AHIRequestedID and AHIRequestedFreq return what the
user chose. A sound made with CludgeSound can also be played with
Sound of audiolib.
AHI needs Kickstart 2.04 or newer. On Kickstart 1.x programs with the
library run, but OpenAHI returns 0. The AHI commands of the BB2 C
port are tested with a test device that answers as the documentation
of ahi.device describes, not with an installed AHI.
The library has the same number and the same CludgeSound as the first
sound library, so only one of the two can be installed. It belongs to
the library variant rwe-1999-ahi, which has it instead of the first one
(The RWE userlibs).
LoadSound 0,"sound.8svx"
If OpenAHI(0)
PlaySoundAHI 0
MouseWait
CloseAHI
EndIfLibrary number 45.
Commands
AHIOutputRequest
Shows AHI’s requester for choosing an audio mode. Returns nonzero if the user chose a mode, and 0 if the user cancelled, the requester could not be made or OpenAHI was not called.
Function, result .l. Help text: [x,y,width,height[,modeid,[frequency]]]
6 forms:
- no arguments
.l.l, .l.l, .l, .l, .l.l, .l, .l, .l, .l.l, .l, .l, .l, .l, .l
Amiga mode only. The arguments are the requester’s position and size,
and the audio mode and mixing frequency it starts with. The form with
1 argument takes the mode, the one with 2 the mode and the frequency,
the one with 4 the position and size; the values left out are -1 for
the position and size and 0 for the mode and frequency. The requester
opens on the screen the program uses. AHIRequestedID and
AHIRequestedFreq return the choice.
AHIRequestedFreq
The mixing frequency the user chose in the last AHIOutputRequest that was confirmed. It is 0 before a choice, and if OpenAHI was not called.
Function, result .l. No help text.
No arguments.
AHIRequestedID
The audio mode the user chose in the last AHIOutputRequest that was confirmed. It is -1 before a choice, and 0 if OpenAHI was not called.
Function, result .l. No help text.
No arguments.
CloseAHI
Stops a sound that PlaySoundAHI still plays and closes ahi.device. The library does the same when the program ends.
Statement. No help text.
No arguments.
Amiga mode only. The library’s I/O request and message port stay for
the next OpenAHI; they are freed when the program ends.
CludgeSound
Makes sound object sound# from the IFF 8SVX file at address in memory, copying its sample into chip memory. As a function it returns -1 on success, and 0 if the file cannot be used; without enough chip memory the program stops with the runtime error “Out of Memory!”.
Statement or function, result .l. Help text: sound#,address
Arguments: .l, .l
The same command as in the first sound library (see there for the files it refuses): a call that fails leaves the sound as it was, the rate comes from the file’s header, and the search for the sample data expects the pad byte behind a chunk of odd length.
PlaySoundAHI plays a sound made with it, like any other sound
object, at the pitch of its period.
OpenAHI
Opens unit unit of ahi.device, version 4 or newer. As a function it returns -1 on success, and 0 if the device cannot be opened or is already open.
Statement or function, result .l. Help text: unit,[deviceID]
2 forms:
.l.l, .l
Amiga mode only. deviceID is stored but not used. After CloseAHI
the device can be opened again. On Kickstart 1.x, where AHI does not
run, the result is always 0.
PlayRawAHI
Plays length bytes of an 8 bit mono sample at address through AHI at frequency Hz, with volume (default 1, full) and balance (default 0.5, the middle).
Statement. Help text: address,length,frequency,[volume,[balance]]
3 forms:
.l, .l, .l.l, .l, .l, .q.l, .l, .l, .q, .q
The command returns when the sample has been played, so the data may
be freed or changed afterwards. A sound that still plays from
PlaySoundAHI is stopped first. Nothing happens before OpenAHI.
PlaySoundAHI
Plays sound object sound through AHI, at volume (default 1, full) and balance (default 0.5, the middle), and returns at once while it plays.
Statement. Help text: sound,[volume,[balance]]
3 forms:
.l.l, .q.l, .q, .q
The sound plays at the pitch of its period, the pitch Sound plays
it at, and with its whole sample. A sound that still plays from the
last PlaySoundAHI is stopped first. Nothing happens before
OpenAHI.