PMICRead

Syntax

#include <revolution/pmic.h>

s32 PMICRead(s16* buffer, s32 samples);

Arguments

buffer Location to store the audio data received from the Wii Speak.
samples Number of samples of audio data to request from the Wii Speak.

Return Values

Returns the number of samples of audio data that were obtained from the Wii Speak. The function returns -1 if the PMIC library is not initialized or if any arguments were specified incorrectly.

Description

Use this function when programs get the audio data collected by the Wii Speak.

Audio data is formatted as 16-bit monaural PCM (big-endian). The sampling frequency for audio data is set to be either 16,000 Hz; 11,025 Hz; or 8000 Hz by the PMICSetFreq(Async) function. The default sampling frequency when the Wii Speak starts is 16,000 Hz.

The PMIC library periodically gets audio data from the Wii Speak and stores it in a buffer inside the library. This function moves the audio data from this buffer inside the library to the region specified in the first argument. Calling this function is a separate process from accessing the Wii Speak through the USB, so you do not need to consider synchrony/asynchrony when calling this function.

The size of the audio data buffer in the PMIC library differs depending on the way in which the library is initialized. If the library was initialized using the PMICInit function, the size of the audio data buffer is 48 ms for a sampling rate of 16 kHz (or approximately 70 ms for 11 kHz, or 96 ms for 8 kHz). When the library is initialized using the PMICInitEx function, the buffer size is specified by an argument.

In either case, programs must call this function at the appropriate frequency to get the audio data from the internal buffer. If for some reason a call to this function is delayed, the internal buffer is overwritten, and audio data continuity is lost.

This function can be called regardless of the state of the Wii Speak (such as before it is open or while it is stopped or operating).

See Also

PMICSetFreqAsync
PMICSetFreq
PMICInit
PMICInitEx

Revision History

2008/10/21 Revised Description.
2008/09/26 Revised Description.
2008/06/13 Added mention of the frequency.
2008/03/04 Changed the function reference format.
2008/01/25 Initial version.


CONFIDENTIAL