#include <revolution/wpad.h> #define WPAD_CHAN0 0 #define WPAD_CHAN1 1 #define WPAD_CHAN2 2 #define WPAD_CHAN3 3 #define WPAD_SPEAKER_OFF 0 #define WPAD_SPEAKER_ON 1 #define WPAD_SPEAKER_MUTE 2 #define WPAD_SPEAKER_MUTE_OFF 3 #define WPAD_SPEAKER_PLAY 4 typedef void (*WPADCallback) ( s32 chan, s32 result ); s32 WPADControlSpeaker( s32 chan, u32 command, WPADCallback callback );
| chan | One of the WPAD_CHANn values. |
|---|---|
| command | Set to one of the following: WPAD_SPEAKER_OFF, WPAD_SPEAKER_ON, WPAD_SPEAKER_MUTE, WPAD_SPEAKER_MUTE_OFF, or WPAD_SPEAKER_PLAY. |
| callback | Callback function to report on the result. When NULL is specified, notification processing is omitted. |
Returns one of the following codes:
WPAD_ERR_NONE
WPAD_ERR_NO_CONTROLLER
WPAD_ERR_BUSY
Controls the speaker of the Wii Remote Control on the specified channel. This function registers the speaker control command in the library. The WPAD library processes registered commands when other commands are not running.
To output audio from the speaker on the Wii Remote, first start the speaker using the WPAD_SPEAKER_ON command. Next, audio can be output from the speaker using the WPAD_SPEAKER_PLAY command. Sending audio data using the WPADSendStreamData at this time will cause audio to be output from the speaker of the Wii Remote. Due to the audio specifications of the audio processor of the Wii Remote, 20 bytes of audio data must be sent three times every 20 ms in order to achieve correct audio playback.
In order to avoid wearing down the batteries in scenes where no sound is output through the Wii Remote speaker for a period of time, use the WPADControlSpeaker function to send the WPAD_SPEAKER_OFF command whenever possible to stop the speaker. However, starting or stopping the speaker will prevent you from being able to obtain several input samples from the Motion Sensor, Pointer, and external extension controller of the Wii Remote. Accordingly, in scenes in which sound is output frequently, there is no need to start and stop the speaker often. In such scenes, keep the speaker ON the whole time, and instead of starting and stopping the speaker, use the WPADControlSpeaker function to send a WPAD_SPEAKER_MUTE or WPAD_SPEAKER_MUTE_OFF commands to turn muting ON/OFF.
Due to the audio processor and wireless communication specifications of the Wii console and the Wii Remote, there are times when the sound will break or jump. Audio may break or jump if it is played back continuously for eight minutes or longer from the Wii Remote's speaker. To avoid this, either restart the speaker before 8 minutes have passed or refrain from sending audio for more than one second. Audio will also break up when there is external noise, an external extension controller is inserted, a command is sent to the Wii Remote, and in other cases. Consequently, confirm that audio can be sent without breaking up by calling the WPADCanSendStreamData function when sending audio.
The different commands are defined as follows.
| WPAD_SPEAKER_OFF | Turns off the Wii Remote speaker. |
|---|---|
| WPAD_SPEAKER_ON | Turns on the Wii Remote speaker. |
| WPAD_SPEAKER_MUTE | Mutes the Wii Remote speaker. |
| WPAD_SPEAKER_MUTE_OFF | Unmutes the Wii Remote speaker. |
| WPAD_SPEAKER_PLAY | Allows audio data to be output from the Wii Remote speaker. |
The return values have the following meanings:
| WPAD_ERR_NONE | The WPAD library received a command. |
|---|---|
| WPAD_ERR_BUSY | The WPAD library was unable to receive a command. |
| WPAD_ERR_NO_CONTROLLER | The connection was broken. |
In addition, if a callback function is set, the callback function returns the following error codes when the processing is complete. Their meanings are as follows:
| WPAD_ERR_NONE | The command was processed normally. |
|---|---|
| WPAD_ERR_BUSY | The WPAD library was unable to receive a command. Call it again later. |
| WPAD_ERR_TRANSFER | A communications error prevented normal processing of the command. |
| WPAD_ERR_NO_CONTROLLER | The connection was broken. |
WPADIsSpeakerEnabled,
WPADSendStreamData,
WPADCanSendStreamData
2007/10/11 Added explanations concerning audio volume and broken sounds, and the WPADCanSendStreamData function to See Also.
2007/09/18 Corrected a name mismatch between the argument list and the Syntax.
2006/11/29 Added WPAD_ERR_BUSY, which had been left out of the error codes passed by the callback.
2006/08/15 Initial version.
CONFIDENTIAL