1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<html>
3
4<head>
5<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
6<META name="GENERATOR" content="Microsoft FrontPage 5.0">
7<META http-equiv="Content-Style-Type" content="text/css">
8<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
9<title>WPADControlSpeaker</title>
10</head>
11
12<body>
13
14<h1>WPADControlSpeaker</h1>
15
16<h2>Syntax</h2>
17<dl><dd><pre class="construction">#include &lt;revolution/wpad.h&gt;
18
19#define WPAD_CHAN0               0
20#define WPAD_CHAN1               1
21#define WPAD_CHAN2               2
22#define WPAD_CHAN3               3
23
24#define WPAD_SPEAKER_OFF         0
25#define WPAD_SPEAKER_ON          1
26#define WPAD_SPEAKER_MUTE        2
27#define WPAD_SPEAKER_MUTE_OFF    3
28#define WPAD_SPEAKER_PLAY        4
29
30typedef void (*WPADCallback) ( s32 chan, s32 result );
31
32s32 WPADControlSpeaker( s32 chan, u32 command, WPADCallback callback );
33</pre></dd></dl>
34
35<h2>Arguments</h2>
36<TABLE class="arguments" border="1" >
37  <TBODY>
38    <TR>
39<TH>chan</TH>
40<TD>One of the <code>WPAD_CHAN<i>n</i></code> values.</TD>
41    </TR>
42    <TR>
43<TH>command</TH>
44<TD>Set to one of the following: <CODE>WPAD_SPEAKER_OFF</CODE>, <CODE>WPAD_SPEAKER_ON</CODE>, <CODE>WPAD_SPEAKER_MUTE</CODE>, <CODE>WPAD_SPEAKER_MUTE_OFF</CODE>, or <CODE>WPAD_SPEAKER_PLAY</CODE>.</TD>
45    </TR>
46    <TR>
47<TH>callback</TH>
48<TD>Callback function to report on the result. When <code>NULL</code> is specified, notification processing is omitted.</TD>
49    </TR>
50  </TBODY>
51</TABLE>
52
53<h2>Return Values</h2>
54<p>
55Returns one of the following codes:
56</p>
57<p>
58<code>WPAD_ERR_NONE</code><br> <code>WPAD_ERR_NO_CONTROLLER</code><br> <code>WPAD_ERR_BUSY</code><br>
59</P>
60
61<H2>Description</H2>
62<p>
63Controls 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.
64</p>
65<p>
66To output audio from the speaker on the Wii Remote, first start the speaker using the <code>WPAD_SPEAKER_ON</code> command. Next, audio can be output from the speaker using the <code>WPAD_SPEAKER_PLAY</code> command. Sending audio data using the <a href="./WPADSendStreamData.html"><code>WPADSendStreamData</code></a> 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&nbsp;ms in order to achieve correct audio playback.
67</p>
68<p>
69In 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 <a href="./WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function to send the <code>WPAD_SPEAKER_OFF</code> 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 <a href="WPADControlSpeaker.html"><code>WPADControlSpeaker</code></a> function to send a <code>WPAD_SPEAKER_MUTE</code> or <code>WPAD_SPEAKER_MUTE_OFF</code> commands to turn muting ON/OFF.
70</p>
71<p>
72Due 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 <a href="./WPADCanSendStreamData.html"><code>WPADCanSendStreamData</code></a> function when sending audio.
73</p>
74
75<ul>
76<li>Commands</li>
77</ul>
78<p>
79The different commands are defined as follows.
80</p>
81
82<TABLE class="arguments" border="1" >
83<tr><th>WPAD_SPEAKER_OFF</th><td>Turns off the Wii Remote speaker.</td>
84<tr><th>WPAD_SPEAKER_ON</th><td>Turns on the Wii Remote speaker.</td>
85<tr><th>WPAD_SPEAKER_MUTE</th><td>Mutes the Wii Remote speaker.</td>
86<tr><th>WPAD_SPEAKER_MUTE_OFF</th><td>Unmutes the Wii Remote speaker.</td>
87<tr><th>WPAD_SPEAKER_PLAY</th><td>Allows audio data to be output from the Wii Remote speaker.</td>
88</table>
89
90<ul>
91<li>Error Codes</li>
92</ul>
93<p>
94The return values have the following meanings:
95</p>
96<TABLE class="arguments" border="1" >
97<tr><th>WPAD_ERR_NONE</th><td>The WPAD library received a command.</td>
98<tr><th>WPAD_ERR_BUSY</th><td>The WPAD library was unable to receive a command.</td>
99<tr><th>WPAD_ERR_NO_CONTROLLER</th><td>The connection was broken.</td>
100</table>
101
102<ul>
103<li>Callbacks</li>
104</ul>
105<p>
106In 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:
107</p>
108<TABLE class="arguments" border="1" >
109<tr>
110<th>WPAD_ERR_NONE</th>
111<td>The command was processed normally.</td>
112</tr>
113<tr>
114<th>WPAD_ERR_BUSY</th>
115<td>The WPAD library was unable to receive a command. Call it again later.</td>
116</tr>
117<tr>
118<th>WPAD_ERR_TRANSFER</th>
119<td>A communications error prevented normal processing of the command.</td>
120</tr>
121<tr>
122<th>WPAD_ERR_NO_CONTROLLER</th>
123<td>The connection was broken.</td>
124</tr>
125</table>
126
127<h2>See Also</h2>
128<p class="reference">
129<A href="./WPADIsSpeakerEnabled.html">WPADIsSpeakerEnabled</A>,
130<A href="./WPADSendStreamData.html">WPADSendStreamData</A>,
131<A href="./WPADCanSendStreamData.html"><code>WPADCanSendStreamData</code></a><br>
132</p>
133
134<H2>Revision History</H2>
135<p>
1362007/10/11 Added explanations concerning audio volume and broken sounds, and the <a href="./WPADCanSendStreamData.html"><code>WPADCanSendStreamData</code></a> function to See Also.<br> 2007/09/18 Corrected a name mismatch between the argument list and the Syntax.<BR>2006/11/29 Added <CODE>WPAD_ERR_BUSY</CODE>, which had been left out of the error codes passed by the callback.<br>2006/08/15 Initial version.<br>
137</P>
138
139<hr><p>CONFIDENTIAL</p></body>
140</html>