WPADControlSpeaker

Syntax

#include <cafe/pads/wpad/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
#define WPAD_SPEAKER_RESET       5

typedef void (*WPADCallback) ( s32 chan, s32 result );

s32 WPADControlSpeaker( s32 chan, u32 command, WPADCallback callback );

Parameters

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
  • WPAD_SPEAKER_PLAY
  • WPAD_SPEAKER_RESET
callback Callback function to report on the result. When NULL is specified, notification processing is omitted.

Return Values

WPAD_ERR_NONEThe WPAD library received a command.
WPAD_ERR_NO_CONTROLLERThe connection was broken.
WPAD_ERR_BUSYThe WPAD library was unable to receive a command.

Description

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 to achieve correct audio playback.

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 U 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.

Commands

The different commands are defined as follows.

WPAD_SPEAKER_OFFTurns off the Wii remote speaker.
WPAD_SPEAKER_ONTurns on the Wii remote speaker.
WPAD_SPEAKER_MUTEMutes the Wii remote speaker.
WPAD_SPEAKER_MUTE_OFFUnmutes the Wii remote speaker.
WPAD_SPEAKER_PLAYAllows audio data to be output from the Wii remote speaker.
WPAD_SPEAKER_RESETSame as WPAD_SPEAKER_ON.

Callbacks

When a callback function has been set, the callback function is called together with the processing result. When the return value is WPAD_ERR_NONE, the callback function is called when the process is completed. Otherwise, it is called before the function escapes. The following error codes are passed to the callback function.

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.

Do Not Call From

Background Do not call this function from the background.
Interrupt handler Do not call this function from any interrupt handler.
Exception handler Do not call this function from any exception handler.
Multiple Cores Do not call this function from more than one Core.

See Also

WPADIsSpeakerEnabled
WPADSendStreamData
WPADCanSendStreamData

Revision History

2014/03/05 Include WPAD_SPEAKER_RESET definition.
2013/05/08 Automated cleanup pass.
2009/09/24 Explained the timing of the call to the callback function.
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