Go to the first, previous, next, last section, table of contents.


Obtaining The Hardware

If you wish to call any other function than

...you have to allocate the actual sound hardware. This is done with AHI_AllocAudioA(). AHI_AllocAudioA() returns an AHIAudioCtrl structure, or NULL if the hardware could not be allocated. The AHIAudioCtrl structure has only one public field, ahiac_UserData. This is unused by AHI and you may store anything you like here.

If AHI_AllocAudioA() fails it is important that you handle the situation gracefully.

When you are finished playing or recording, call AHI_FreeAudio() to deallocate the hardware and other resources allocated by AHI_AllocAudioA(). AHI_FreeAudio() also deallocates all loaded sounds (see section Declaring Sounds).

AHI_AllocAudioA() Tags

AHI_AllocAudioA() takes several tags as input.

AHIA_AudioID
This is the audio mode to be used. You must not use any hardcoded values other than AHI_DEFAULT_ID, which is the user's default fallback ID. In most cases you should ask the user for an ID code (with AHI_AudioRequestA()) and then store the value in your settings file.
AHIA_MixFreq
This is the mixing frequency to be used. The actual frequency will be rounded to the nearest frequency supported by the sound hardware. To find the actual frequency, use AHI_GetAudioAttrsA(). If omitted or AHI_DEFAULT_FREQ, the user's preferred fallback frequency will be used. In most cases you should ask the user for a frequency (with AHI_AudioRequestA()) and then store the value in your settings file.
AHIA_Channels
All sounds are played on a channel, and this tag selects how many you wish to use. In general it takes more CPU power the more channels you use and the volume gets lower and lower.
AHIA_Sounds
You must tell AHI how many different sounds you are going to play. See section Declaring Sounds for more information.
AHIA_SoundFunc
With this tag you tell AHI to call a hook when a sound has been started. It works just like Paula's audio interrupts. The hook receives an AHISoundMessage structure as message. AHISoundMessage->ahism_Channel indicates which channel the sound that caused the hook to be called is played on.
AHIA_PlayerFunc
If you are going to play a musical score, you should use this "interrupt" source instead of VBLANK or CIA timers in order to get the best result with all audio drivers. If you cannot use this, you must not use any "non-realtime" modes (see AHI_GetAudioAttrsA() in the autodocs, the AHIDB_Realtime tag).
AHIA_PlayerFreq
If non-zero, it enables timing and specifies how many times per second PlayerFunc will be called. This must be specified if AHIA_PlayerFunc is! It is suggested that you keep the frequency below 100-200 Hz. Since the frequency is a fixpoint number AHIA_PlayerFreq should be less than 13107200 (that's 200 Hz).
AHIA_MinPlayerFreq
The minimum frequency (AHIA_PlayerFreq) you will use. You should always supply this if you are using the device's interrupt feature!
AHIA_MaxPlayerFreq
The maximum frequency (AHIA_PlayerFreq) you will use. You should always supply this if you are using the device's interrupt feature!
AHIA_RecordFunc
This hook will be called regularly when sampling is turned on (see AHI_ControlAudioA()). It is important that you always check the format of the sampled data, and ignore it if you can't parse it. Since this hook may be called from an interrupt, it is not legal to directly Write() the buffer to disk. To record directly to harddisk you have to copy the samples to another buffer and signal a process to save it. To find out the required size of the buffer, see AHI_GetAudioAttrsA() in the autodocs, the AHIDB_MaxRecordSamples tag.
AHIA_UserData
Can be used to initialize the ahiac_UserData field. You do not have to use this tag to change ahiac_UserData, you may write to it directly.


Go to the first, previous, next, last section, table of contents.