Welcome! Log In Create A New Profile


Wiimote speaker

Posted by oibaf 
Wiimote speaker
May 04, 2011 11:01AM
I can not get the wiimote speaker to properly work.

I used these instructions:

WPAD_ControlSpeaker(pad, 1);
WPAD_SendStreamData(pad, buffer, size);

The speaker seems to work only if you send 20 bytes each 2*6,666 ms but only noise comes out. The noise seems to be the same not depending on the data patterns.

The WPAD_Controlspeaker instruction should set a 3 khz sound (YAMAHA 4 bit raw PCM) so you should send the data each 2*6,666 ms . It is possible to calculate this value from the formula:

time= 1/freq*20*2

since there are 40 samples in 20 bytes.

The WPAD_SendStreamData instruction actives a call back each 6,666 ms that sends 20 bytes from the buffer and this is very strange because it should be 2*6,666 ms unless the sound is 6 khz.

I tried to modify the library removing the call back. Sending the bytes at lower intervals than 6,666 ms the wiimote plays but only noise.

Is there anyone who succeeded in getting the speaker to work?
Re: Wiimote speaker
May 04, 2011 09:43PM
The default ADPCM sound rate (used by games and hardcoded into libogc) is 6 khz, hence the 6.666ms callback period. The state of the ADPCM encoder should only be reset when the speaker is turned on. There's also a bug in libogc's implementation, the ADPCM step value should be clipped to 24576 (0x6000) instead of 24567.
However even after making these changes, it still won't work properly. Something in the wiiuse library just isn't right.
Re: Wiimote speaker
May 05, 2011 10:00AM

I agree with you it is not an encoder problem. I did not use the libogc's encoder but directly a raw PCM Yamaha encoded file and I got only noise.

Could be a reverse engineering problem? Maybe a different configuration should be made.

In any case the Wiimote page of the Wiibrew website should be changed since it says that the standard configuration is 3000Hz whilst it is 6000Hz:

The standard value is 0x7d0, for 3000Hz 4-bit PCM
FF configures the data format. Setting it to 0x40 configures the speaker to use signed 8-bit PCM, while setting it to 0x00 configures it to use 4-bit Yamaha ADPCM. VV specifies the volume, which has a range of 0x00-0xFF for 8-bit mode, and 0x00-0x40 for 4-bit mode.
This configuration can be used to play 4-bit ADPCM sound at 3000Hz:
00 00 D0 07 40 00 00
Re: Wiimote speaker
May 06, 2011 05:23PM
If you read WPAD_SendStreamData in the WPAD source, you can see this function divide the buffer in blocks of 20 bytes and send them to the wiimote at intervals of 6,666ms. I think, It is not necesary to do it by your self.

In the other hand, I think you can use WPAD_EncodeData to encode your samples from 8bits to 4bits.

I'm not sure about that, because I can't get a correct sound yet, but I think this is the way to follow.

Somebody got good results on this matter?
Re: Wiimote speaker
May 07, 2011 09:22AM
This is right.
Since it did not work I modififed the WPAD_SendStreamData library and I removed the function which divides the buffer in blocks of 20 bytes just to do some attempts and I did not use WPAD_EncodeData but directly a 4 bit RAW PCM file but I got only noise. I think that it would be necessary to deepen the reverse engineering of the spekear wiimote.

Edited 2 time(s). Last edit at 05/07/2011 10:30AM by oibaf.
Re: Wiimote speaker
May 07, 2011 11:52AM
In the version note of "speaker.c" you can find " added basic wiimote speaker support. playback doesn't work though - added batt".
Definitely is a bug in libogc.

Re: Wiimote speaker
May 19, 2011 11:22PM
This code is unfinished. As you've found out you'd have to do some further digging to get it working.
Re: Wiimote speaker
May 20, 2011 11:20PM
The problem seems to be in the configuration of wiimote, the configuration command seems not to be correct for PCM 4 bits 3000Hz samples.
I can't managed it yet but I still trying.
Sorry, only registered users may post in this forum.

Click here to login