Copyright (c) Hyperion Entertainment and contributors.

Difference between revisions of "AHI Device"

From AmigaOS Documentation Wiki
Jump to navigation Jump to search
Line 25: Line 25:
 
=== Playing Sounds ===
 
=== Playing Sounds ===
 
=== Closing the AHI Device ===
 
=== Closing the AHI Device ===
  +
== Examples ==
== Double Buffered Sound Example ==
 
  +
=== Playback Example ===
  +
=== Double Buffered Sound Example ===
  +
=== Recording Example ===

Revision as of 19:55, 16 March 2017

About AHI

AHI is a retargetable audio subsystem which provides standardized operating system support for wide range of audio hardware. AHI offers improved functionality not available through the AmigaOS audio device driver, such as seamless audio playback from a user selected audio device, standardized functionality for audio recording and efficient software mixing routines for combining multiple sound channels.

Definitions

Terms used in the following discussions may be unfamiliar. Some of the more important ones are defined below.

Sample
A sample is one binary number, representing the amplitude at a fixed point in time. A sample is often stored as an 8 bit signed integer, a 16 bit signed integer, a 32 bit floating point number etc. AHI supports only integers.
Sample frame
In mono environment, a sample frame is the same as a sample. In stereo environment, a sample frame is a tuple of two samples. The first member is for the left channel and the second member is for the right channel.
Sound

Many sample frames stored in sequence as an array can be called a sound. A sound is, however, not limited to being formed by samples. It can also be parameters to an analog synth or a MIDI instrument, or be white noise. AHI supports only sounds formed by samples.

AHI Device

AHI device has two APIs: a library-like function interface for low-level access and device interface for high-level access.

AHI Device Commands and Functions

Device Interface

Opening the AHI Device

Reading from the AHI Device

Writing to the AHI Device

Closing the AHI Device

Function Interface

Opening the AHI Device for Low-level Access

Obtaining the Hardware

Declaring Sounds

Playing Sounds

Closing the AHI Device

Examples

Playback Example

Double Buffered Sound Example

Recording Example