AXGetAdpcmData

Syntax

#include <revolution/ax.h>

s32 AXGetAdpcmData(s16*      input,
                   s32       samples,
                   s32       rate,
                   s32       loop_start,
                   s32       loop_end,
                   u8*       output,
                   DSPADPCM* info,
                   void*     work);

Arguments

input Pointer to 16-bit PCM data to encode in DSP-ADPCM format.
samples Number of 16-bit PCM data samples to encode.
rate Sampling frequency of the 16-bit PCM data to encode.
loop_start Specifies the loop's starting sample (0 is the origin).
loop_end Specifies the loop's ending sample (0 is the origin).
output Pointer to the location to output the DSP-ADPCM data.
info Pointer to the location where information is stored for the DSP-ADPCM data.
work Pointer to the work region to use while encoding.

Return Values

Returns the number of samples that were actually encoded (not including padding).

Description

This function encodes monaural 16-bit (big-endian) PCM data in DSP-ADPCM format so that it can be handled by an audio DSP.

The second argument, samples, specifies the number of samples to encode. This function outputs DSP-ADPCM data in frames of 8 bytes for every 14 samples. If samples is not a multiple of 14, the final frame is padded with zeros equivalent in amount to the number of missing samples. Note, however, that the return value (number of samples encoded) does not include this padding.

The third argument, rate, specifies the sampling frequency of the PCM data. This function does not perform any sort of resampling, so the DSP-ADPCM data will be output with the same sampling frequency.

The fourth and fifth arguments, loop_start and loop_end, specify the starting and ending loop positions. Specify each value relative to 0 as the origin. Leave one sample or more between the start of the loop and the end, and always set the end of the loop to a larger value than the start of the loop. If loop_start or loop_end are specified using negative numbers, or the loop positions are otherwise set inappropriately, the data will be encoded as non-looping.

The sixth argument, output, specifies the location to output DSP-ADPCM data. The AXGetAdpcmOutputSize function can be used to get the size of the region required for the output location. If the region specified here as the output location is accessed directly by AX, its address must be 8-byte aligned.

The seventh argument, info, specifies the location to output information on the DSP-ADPCM data.

The work area that this function uses during encoding is specified in the eighth argument, work. The AXGetAdpcmWorkSize function can be used to get the size of the region required for working memory.

See Also

AXGetAdpcmOutputSize
AXGetAdpcmWorkSize

Revision History

2008/12/19 Revised the description of how padding is handled.
2008/02/26 Initial version.


CONFIDENTIAL