Welcome! Log In Create A New Profile

Advanced

Playing Sounds

Posted by profetylen 
Re: Playing Sounds
June 15, 2009 06:49PM
The bg_music_ogg.length idea came from a misreading. In the libwiigui example length is a parameter and i thought it was a function to check how long an array is. (I think you always can do that in Java).

At first I couln't compile it but adding a few libs to the bakefile solved that.
These are my current makefile libs:
LIBS	:=	 -lpng -ljpeg -lz -lfat -lwiiuse -lbte -lfat -logc -lm -lasnd -ltremor

Now I can compile it, but still I don't get any sound when calling PlayOgg(...), so I tried adding SetVolumeOgg(255) right after PlayOgg(...). This didn't give me a different result.

I figured I had to init the audio so I added the following code (copied from the libwiigui example):

// Initiate audio
AUDIO_Init(NULL);
ASND_Init();
ASND_Pause(0);

I also included a couple of files:

#include "ogcsys.h"
#include "asndlib.h"


That gave me an error which I don't know how to resolve:

> "make"
linking ... akruve.elf
c:/devkitPro/libogc/lib/wii\libasnd.a(asndlib.o): In function `__dsp_initcallback':
asndlib.c:(.text.__dsp_initcallback+0x10): undefined reference to `DSP_SendMailTo'
asndlib.c:(.text.__dsp_initcallback+0x14): undefined reference to `DSP_CheckMailTo'
asndlib.c:(.text.__dsp_initcallback+0x2c): undefined reference to `DSP_SendMailTo'
asndlib.c:(.text.__dsp_initcallback+0x30): undefined reference to `DSP_CheckMailTo'
c:/devkitPro/libogc/lib/wii\libasnd.a(asndlib.o): In function `__dsp_requestcallback':
asndlib.c:(.text.__dsp_requestcallback+0x218): undefined reference to `DSP_SendMailTo'
asndlib.c:(.text.__dsp_requestcallback+0x21c): undefined reference to `DSP_CheckMailTo'
asndlib.c:(.text.__dsp_requestcallback+0x468): undefined reference to `DSP_SendMailTo'
asndlib.c:(.text.__dsp_requestcallback+0x46c): undefined reference to `DSP_CheckMailTo'
c:/devkitPro/libogc/lib/wii\libasnd.a(asndlib.o): In function `audio_dma_callback':
asndlib.c:(.text.audio_dma_callback+0x27c): undefined reference to `DSP_SendMailTo'
asndlib.c:(.text.audio_dma_callback+0x280): undefined reference to `DSP_CheckMailTo'
c:/devkitPro/libogc/lib/wii\libasnd.a(asndlib.o): In function `ASND_Init':
asndlib.c:(.text.ASND_Init+0x1c): undefined reference to `DSP_Init'
asndlib.c:(.text.ASND_Init+0x18c): undefined reference to `DSP_AddTask'
collect2: ld returned 1 exit status
make[1]: *** [/c/Projects/wii/akruve/akruve.elf] Error 1
"make": *** [build] Error 2

> Process Exit Code: 2
> Time Taken: 00:00

What do I have to do to add references to those functions?
Re: Playing Sounds
June 15, 2009 07:57PM
@speewave: Yes I have considered to do it that way, but I'd like to keep things "clean" if you know what I mean. Thanks for the tip though and thanks for telling me about the multiple occurances!



Edited 2 time(s). Last edit at 06/15/2009 07:58PM by profetylen.
Re: Playing Sounds
June 16, 2009 06:41AM
I believe putting -lasnd before -logc will fix your compilation error.
Re: Playing Sounds
June 16, 2009 11:59AM
That would be a linking error.
You should generally keep the platform runtime library and libmath at the end of the linking list, since they are most likely to be used by other libraries.
Re: Playing Sounds
June 16, 2009 02:50PM
That fixed the problem!
Thanks alot everyone!

The problem is now, I can't play multiple sounds at a time.
Is it even possilbe to do that with oggplayer?
Re: Playing Sounds
June 17, 2009 08:33AM
oggplayer is set to use voice channel 0 always, if you want multiple ones you would have to recode the oggplayer. Basically it was intended for background music, if you want short sound effects you should be using something like pcm.

You can have ogg for the music and pcm for sound effects, that's what libwiigui is doing.
Re: Playing Sounds
June 17, 2009 12:03PM
Yes, I noticed libwiigui doing that.
Yes, I will also try doing that.

Thanks for all the help, everyone! :D
Re: Playing Sounds
June 17, 2009 03:30PM
Anyone know of any good wav to pcm converters?
Re: Playing Sounds
June 17, 2009 06:54PM
I use GoldWave. You want 16 bit big endian stereo (I believe GoldWave calls it RAW)
Re: Playing Sounds
June 17, 2009 11:55PM
Wav can store that exact format btw. Or it might contain mp3 audio, it's just a container!
Re: Playing Sounds
June 18, 2009 03:24PM
Thanks! That worked well!

Now I want to make use off the wiimote speakers! I searched the wiki and all i found was this:

Quote

Speaker

The Wii Remote has a small low-quality 21mm piezo-electric speaker, used for short sound effects during gameplay. The sound is streamed directly from the host, and the speaker has some adjustable parameters.
The speaker is controlled by using three output reports, together with a section of the register address space of the Wii Remote.
Report 0x14 is used to enable or disable the speaker. Setting bit 2 will enable the speaker, and clearing it will disable it. For example, to enable the speaker, send:
(52) 14 04
Report 0x19 is used to mute or unmute the speaker, and works identically to report 0x14. 0x04 will mute the speaker, and 0x00 will unmute it.
Report 0x18 is used to send speaker data. 1-20 bytes may be sent at once:
(52) 18 LL DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD
LL specifies the data length, shifted left by three bits. The DD bytes are the speaker data. To fullfill the report length requirements, the data must be padded if it is less than 20 bytes long. Sound data must be sent at the proper rate.
Initialization Sequence
Reminder
Remember to set bit 2 (0x04) on the first byte of the Output Reports to write to registers!
The following sequence will initialize the speaker:
Enable speaker (Send 0x04 to Output Report 0x14)
Mute speaker (Send 0x04 to Output Report 0x19)
Write 0x01 to register 0xa20009
Write 0x08 to register 0xa20001
Write 7-byte configuration to registers 0xa20001-0xa20008
Write 0x01 to register 0xa20008
Unmute speaker (Send 0x00 to Output Report 0x19)
Speaker Configuration
7 bytes control the speaker settings, including volume. The full purpose of these bytes is not known, but the following values seem to produce some sound:
00 FF RR RR VV 00 00
RR RR specify the sample rate (little-endian format), using the following formulae:
pcm_sample_rate = 12000000 / rate_value adpcm_sample_rate = 6000000 / rate_value
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
This configuration can be used to play 8-bit PCM sound at 1500Hz sample rate:
00 40 40 1f 40 00 00

at this page: [www.wiibrew.org]

Since I don't quite understand the inforemation I found, I wonder if there already is a lib for playing sounds through the wiimote speaker?
Re: Playing Sounds
June 18, 2009 03:56PM
Re: Playing Sounds
June 18, 2009 04:04PM
Ok!

Do you know of any app, that I can look at, that uses the wiimote speakers?
Re: Playing Sounds
June 18, 2009 05:46PM
Quote
henke37
Wav can store that exact format btw. Or it might contain mp3 audio, it's just a container!

But a .wav file typically has a header - the raw sample data required here ("PCM") does not. So no, a typical wave file will not work here - you need it converted, probably not just the header stripped but also converted to 48khz or 32khz (forgot to mention that part!)
Re: Playing Sounds
June 18, 2009 10:21PM
I thought that libasnd could do realtime pcm to pcm conversation for you? Maybe I was wrong in thinking that, I haven't tried to use it yet.



Edited 1 time(s). Last edit at 06/27/2009 01:20AM by henke37.
Re: Playing Sounds
June 26, 2009 06:58PM
Quote
profetylen
Ok!

Do you know of any app, that I can look at, that uses the wiimote speakers?

There are absolutely no apps usig the wiimote speaker yet. shagkur has recently added some basic speaker functionality to libogc svn, but...I can't guarantee you what state it's in.
Re: Playing Sounds
June 27, 2009 06:50PM
Okay! Thanks for all the help!
Re: Playing Sounds
June 29, 2009 09:02AM
I'm at the exact same stage as profetylen right now; I just set up the ogg player successfully (Ran into the same linking errors too, but found the fix after a bit of googling. Wish I had stumbled upon this thread sooner.) Anyway, I'm also working on sound effects now, and I was just wondering if anyone has had any luck in using Audacity to convert sound effects. I'm pretty sure I'm saving using the right parameters (Raw PCM, 16-bit, 48khz), but it always comes out all distorted and staticy. I could always try GoldWave, but I'd rather not install anything I don't have to.
Re: Playing Sounds
June 29, 2009 10:58AM
as Tantric said, the sample format supported by the Wii is litterally "16 bit big endian stereo". Raw could mean anything and do not give an idea about the used endiannes but since the default format on PC platform is little endian, you probably end up with "inverted samples", meaning that something that sould be output at +2 (0x0002) is output at +512 (0x0200)
Re: Playing Sounds
June 29, 2009 12:31PM
But is it signed or not? I think that it's not.
Sorry, only registered users may post in this forum.

Click here to login