PMICChangeRate

Syntax

#include <revolution/pmic.h>
#include <revolution/ai.h>

#define AI_SAMPLERATE_48KHZ  0x00000001
#define AI_SAMPLERATE_32KHZ  0x00000000

s32 PMICChangeRate(s16*       input,
                   s32        samples,
                   u32        rate,
                   s16*       output,
                   BOOL       init);

Arguments

input Pointer to the data to convert, which was output from the audio library.
samples Number of samples of data to convert.
rate Sampling frequency of the data to convert.
output Location to output the data after its sampling frequency has been converted.
init Whether this is the first conversion (TRUE) or a second or subsequent conversion (FALSE).

Return Values

The number of samples in the output data. The function returns -1 if the PMIC library is not initialized or if any arguments were specified incorrectly.

Description

The program must send the audio data to be output from the speaker to the microphone to properly use Wii Speak functionality (the echo canceller). This data is called the reference data, and its format is 16-kHz 16-bit stereo PCM. The format of the audio data that the Wii console outputs from the speakers is either 32-kHz or 48-kHz 16-bit stereo PCM. For the Wii Speak to operate properly, the program must use this function to convert the sampling frequency of the speaker data into the frequency required for reference data.

The first argument, input, passes a pointer to the data output from the audio library. However, Revolution SDK's standard AX library (for example) directly passes the output data to the AI (Audio Interface) library, the component that controls data output to the speakers. For this reason, the program must implement some mechanism to pass AX output data to this function. For details, see the PMIC library sample program pmic_simple.

The second argument, samples, specifies (in samples) the amount of audio library output data that this function will convert. When making this specification, consider the left channel and the right channel as separate samples rather than two halves of one sample. The range of specifiable values is 0-4608 (48 milliseconds' worth of data at 48 kHz).

The third argument, rate, specifies the sampling frequency of the audio data that will be converted. If the sampling rate of the audio data is 32 kHz, specify AI_SAMPLERATE_32KHZ. For 48 kHz, specify AI_SAMPLERATE_48KHZ.

Note: The current version does not support a rate of 48 kHz.

The fourth argument, output, specifies where to output the reference data after its sampling rate has been converted. The size required of this output destination is calculated as follows.

Note: The current version does not support a rate of 48 kHz.

The fifth argument, init, specifies whether this is the first time that this function has been called. If it is the first time (TRUE), this function initializes the state used to convert the sampling frequency. If there has been an interruption in calls to this function or in the data specified as input to this function, you should once again specify TRUE for the init argument.

Note: This function is not optimized, so it has a heavy processing load.

See Also

Revision History

2009/06/11 Revised Description.
2008/12/22 Standardized terminology.
2008/10/22 Added argument descriptions.
2008/04/16 Updated the arguments relating to the sampling frequency.
2008/03/04 Changed the function reference format.
2008/01/25 Initial version.


CONFIDENTIAL