AXDecodeAdpcmData

Syntax

#include <cafe/ax.h>

s32 AXDecodeAdpcmData(const u8 *input, DSPADPCM *info,
		      s32 samples, s16 *output);

Parameters

input Specifies the DSP-ADPCM data to be decoded into 16-bit PCM data.
info Specifies where to store information about the DSP-ADPCM data that is specified the input argument.
samples Specifies the number of samples to decode. If the number of samples inside the DSP-ADPCM data is less than samples, this function terminates when it finishes decoding all of the DSP-ADPCM data. However, if the DSP-ADPCM data includes a loop, this function continues the loop until the number of samples decoded reaches the value given by samples.
output Specifies the location where the 16-bit PCM data is output. Memory of size samples x sizeof(s16) for samples argument must be preallocated for the region to use for outputting converted data. If the region specified as the output location is accessed directly by AX, its address must be 4-byte aligned.

Return Values

Returns the number of samples that were actually decoded.

Description

Decodes DSP-ADPCM format data into monaural 16-bit PCM data (big-endian). The CPU performs the decoding. This function is primarily used to decode DSP-ADPCM data that has been encoded by the AXGetAdpcmData function.

Using AXDecodeAdpcmData

This function is intended for use with AXGetAdpcmData, which encodes 16-bit PCM audio data into the DSP ADPCM format. In this scenario, all parameters are recorded into the structure pointed to by the DSPADPCM *info argument. This structure can then be passed to AXGetAdpcmData.

However, if AXDecodeAdpcmData is decoding audio data that was generated with the DSP-ADPCM tool chain, then the calling application must populate the DSPADPCM *info structure appropriately.

The DSPADPCM structure is given below; bolded members must be initialized by the application:


  typedef struct
  {

      u32 num_samples;       // total number of RAW samples
      u32 num_adpcm_nibbles; // number of ADPCM nibbles (including frame headers)
      u32 sample_rate;       // Sample rate, in Hz
      u16 loop_flag;         // 1=LOOPED, 0=NOT LOOPED
      u16 format;            // Always 0x0000, for ADPCM
      u32 sa;                // Start offset address for looped samples (2 for non-looped)
      u32 ea;                // End offset address for looped samples
      u32 ca;                // always 2
      u16 coef[16];          // decode coefficients (eight pairs of 16-bit words)
      u16 gain;              // always zero for ADPCM
      u16 ps;                // predictor/scale
      u16 yn1;               // sample history
      u16 yn2;               // sample history
      u16 lps;               // predictor/scale for loop context
      u16 lyn1;              // sample history (n-1) for loop context
      u16 lyn2;              // sample history (n-2) for loop context
      u16 pad[11];           // reserved

  } DSPADPCM;

If the audio data is a looped sample, the following parameters must also be initialized:

      u16 lps;               // predictor/scale for loop context
      u16 lyn1;              // sample history (n-1) for loop context
      u16 lyn2;              // sample history (n-2) for loop context    

NOTE:
The DSPADPCM data structure is defined in the header file system/src/include/cafe/ax.h.

Availability

Library Version Availability
Sound 2.0 Yes
Sound 1.0 Yes

Do Not Call From

None.

See Also

AXGetAdpcmData
DSPADPCM Tool

Revision History

2013/05/08 Automated cleanup pass.
2012/01/26 Update to Audio API v2.0.
2011/02/21 Initial Version


CONFIDENTIAL