AudioScience HPI Version_4.24.1
|
Perform audio I/O and format conversion. More...
Modules | |
Output Stream | |
The following section describes the states a stream uses. | |
Input Stream | |
The following figure describes the states an InStream uses. | |
Enumerations | |
enum | HPI_FORMATS { HPI_FORMAT_MIXER_NATIVE = 0, HPI_FORMAT_PCM8_UNSIGNED = 1, HPI_FORMAT_PCM16_SIGNED = 2, HPI_FORMAT_MPEG_L1 = 3, HPI_FORMAT_MPEG_L2 = 4, HPI_FORMAT_MPEG_L3 = 5, HPI_FORMAT_DOLBY_AC2 = 6, HPI_FORMAT_DOLBY_AC3 = 7, HPI_FORMAT_PCM16_BIGENDIAN = 8, HPI_FORMAT_AA_TAGIT1_HITS = 9, HPI_FORMAT_AA_TAGIT1_INSERTS = 10, HPI_FORMAT_PCM32_SIGNED = 11, HPI_FORMAT_RAW_BITSTREAM = 12, HPI_FORMAT_AA_TAGIT1_HITS_EX1 = 13, HPI_FORMAT_PCM32_FLOAT = 14, HPI_FORMAT_PCM24_SIGNED = 15, HPI_FORMAT_OEM1 = 16, HPI_FORMAT_OEM2 = 17, HPI_FORMAT_UNDEFINED = 0xffff } |
Audio format types. More... | |
enum | HPI_STREAM_STATES { HPI_STATE_STOPPED = 1, HPI_STATE_PLAYING = 2, HPI_STATE_RECORDING = 3, HPI_STATE_DRAINED = 4, HPI_STATE_SINEGEN = 5, HPI_STATE_WAIT = 6 } |
Stream States. More... | |
enum | HPI_MPEG_ANC_MODES { HPI_MPEG_ANC_HASENERGY = 0, HPI_MPEG_ANC_RAW = 1 } |
MPEG Ancillary Data modes. More... | |
enum | HPI_MPEG_MODES { HPI_MPEG_MODE_DEFAULT = 0, HPI_MPEG_MODE_STEREO = 1, HPI_MPEG_MODE_JOINTSTEREO = 2, HPI_MPEG_MODE_DUALCHANNEL = 3 } |
MPEG modes MPEG modes - can be used optionally for HPI_FormatCreate() parameter dwAttributes. More... | |
Functions | |
hpi_err_t | HPI_FormatCreate (struct hpi_format *pFormat, uint16_t wChannels, uint16_t wFormat, uint32_t dwSampleRate, uint32_t dwBitRate, uint32_t dwAttributes) |
Initialize an audio format structure, given various defining parameters. | |
hpi_err_t | HPI_StreamEstimateBufferSize (struct hpi_format *pFormat, uint32_t dwHostPollingRateInMilliSeconds, uint32_t *dwRecommendedBufferSize) |
Given a format and rate that the buffer is processed, return the correct buffer size to support ping-pong buffering of audio. |
Perform audio I/O and format conversion.
enum HPI_FORMATS |
Audio format types.
enum HPI_STREAM_STATES |
Stream States.
HPI_STATE_STOPPED |
State stopped - stream is stopped. |
HPI_STATE_PLAYING |
State playing - stream is playing audio. |
HPI_STATE_RECORDING |
State recording - stream is recording. |
HPI_STATE_DRAINED |
State drained - playing stream ran out of data to play. |
HPI_STATE_SINEGEN |
State generate sine - to be implemented. |
HPI_STATE_WAIT |
State wait - used for inter-card sync to mean waiting for all cards to be ready. |
enum HPI_MPEG_ANC_MODES |
MPEG Ancillary Data modes.
The mode for the ancillary data insertion or extraction to operate in.
HPI_MPEG_ANC_HASENERGY |
the MPEG frames have energy information stored in them (5 bytes per stereo frame, 3 per mono) |
HPI_MPEG_ANC_RAW |
the entire ancillary data field is taken up by data from the Anc data buffer On encode, the encoder will insert the energy bytes before filling the remainder of the ancillary data space with data from the ancillary data buffer. |
enum HPI_MPEG_MODES |
MPEG modes MPEG modes - can be used optionally for HPI_FormatCreate() parameter dwAttributes.
Using any mode setting other than HPI_MPEG_MODE_DEFAULT with single channel format will return an error.
HPI_MPEG_MODE_DEFAULT |
Causes the MPEG-1 Layer II bitstream to be recorded in single_channel mode when the number of channels is 1 and in stereo when the number of channels is 2. |
HPI_MPEG_MODE_STEREO |
Standard stereo without joint-stereo compression. |
HPI_MPEG_MODE_JOINTSTEREO |
Joint stereo. |
HPI_MPEG_MODE_DUALCHANNEL |
Left and Right channels are completely independent. |
hpi_err_t HPI_FormatCreate | ( | struct hpi_format * | pFormat, |
uint16_t | wChannels, | ||
uint16_t | wFormat, | ||
uint32_t | dwSampleRate, | ||
uint32_t | dwBitRate, | ||
uint32_t | dwAttributes | ||
) |
Initialize an audio format structure, given various defining parameters.
Used in HPI_InStreamSetFormat() and HPI_OutStreamSetFormat()
pFormat | Pointer to the format structure to be initialized. |
wChannels | From 1 to 8. |
wFormat | One of the HPI_FORMATS. |
dwSampleRate | Sample rate in Hz. Samplerate must be between 8000 and 200000. |
dwBitRate | Bits per second, must be supplied for MPEG formats, it is calculated for PCM formats. |
dwAttributes | Format dependent attributes. E.g. HPI_MPEG_MODES |
References HPI_ERROR_INCOMPATIBLE_SAMPLERATE, HPI_ERROR_INVALID_CHANNELS, HPI_ERROR_INVALID_FORMAT, HPI_FORMAT_AA_TAGIT1_HITS, HPI_FORMAT_AA_TAGIT1_HITS_EX1, HPI_FORMAT_AA_TAGIT1_INSERTS, HPI_FORMAT_DOLBY_AC2, HPI_FORMAT_MPEG_L1, HPI_FORMAT_MPEG_L2, HPI_FORMAT_MPEG_L3, HPI_FORMAT_OEM1, HPI_FORMAT_OEM2, HPI_FORMAT_PCM16_BIGENDIAN, HPI_FORMAT_PCM16_SIGNED, HPI_FORMAT_PCM24_SIGNED, HPI_FORMAT_PCM32_FLOAT, HPI_FORMAT_PCM32_SIGNED, HPI_FORMAT_PCM8_UNSIGNED, HPI_FORMAT_RAW_BITSTREAM, HPI_MPEG_MODE_DEFAULT, and HPI_MPEG_MODE_DUALCHANNEL.
hpi_err_t HPI_StreamEstimateBufferSize | ( | struct hpi_format * | pFormat, |
uint32_t | dwHostPollingRateInMilliSeconds, | ||
uint32_t * | dwRecommendedBufferSize | ||
) |
Given a format and rate that the buffer is processed, return the correct buffer size to support ping-pong buffering of audio.
dwRecommendedBufferSize = RoundUpToPowerOf2((bytes per polling period) * 2)
Calculate the minimum buffer size for a stream given the audio format that the stream will be set to use and the rate at which the host polls the stream state and reads or writes data. The buffer size returned by this function should be used as the minimum value passed to HPI_OutStreamHostBufferAllocate() or HPI_InStreamHostBufferAllocate(). If different formats and samplerates will be used on the stream, buffer size should be calculated for the highest datarate format, or the buffer should be freed and allocated again for each format change. The size calculated is rounded up to the nearest power of two which is a requirement of background bus mastering (BBM) buffers.
For some adapters the physical buffers are preallocated during system initialization. The preallocation is based on the maximum format bandwidth supported and assumes a 10 millisecond polling rate. If a slower polling rate is used this calculation may return a value that exceeds the available preallocated physical buffers. In which case it is recommended to poll more frequently.
pFormat | The format of the stream. |
dwHostPollingRateInMilliSeconds | The polling rate of the host thread that fills or empties the buffer. |
dwRecommendedBufferSize | The recommended buffer size in milliseconds. |
References hpi_format::dwBitRate, hpi_format::dwSampleRate, HPI_ERROR_INVALID_FORMAT, HPI_FORMAT_DOLBY_AC2, HPI_FORMAT_MPEG_L1, HPI_FORMAT_MPEG_L2, HPI_FORMAT_MPEG_L3, HPI_FORMAT_PCM16_BIGENDIAN, HPI_FORMAT_PCM16_SIGNED, HPI_FORMAT_PCM24_SIGNED, HPI_FORMAT_PCM32_FLOAT, HPI_FORMAT_PCM32_SIGNED, HPI_FORMAT_PCM8_UNSIGNED, hpi_format::wChannels, and hpi_format::wFormat.