Welcome! Log In Create A New Profile

Advanced

Playing sounds with ASND and AESND

Posted by the_marioga 
Playing sounds with ASND and AESND
October 18, 2010 03:49PM
Hi, i'm trying to play wav files, I have managed to decode a wav file and stored in a buffer with this lib
[pastebin.com]
[pastebin.com]

But when I try to play with

ASND_SetVoice(voice, VOICE_STEREO_16BIT, pFmt.sample_rate,0, buf, sizeof(buf), 255, 255, NULL);
ASND_PauseVoice(voice, 0);

It doesnt return me any error, but i dont hear nothing. What am I doing wrong?

It would be better to try to use AESND?

AESND_PlayVoice(AESNDPB *pb,u32 format,const void *buffer,u32 len,u32 freq,u32 delay,bool looped);

Thanks



Edited 1 time(s). Last edit at 10/18/2010 10:56PM by the_marioga.
Re: Playing sounds with ASND and AESND
October 18, 2010 03:59PM
You made sure to ASND_Init() right?
Re: Playing sounds with ASND and AESND
October 18, 2010 06:04PM
Yes i do after WPAD_Init();
Re: Playing sounds with ASND and AESND
October 18, 2010 06:59PM
"buf" is a pointer, this means "sizeof(buf)" will return the size of the pointer, which is usually 4 bytes (size of a memory address), not the size of the buffer in memory .

This also means only one 16-bit stereo sample would be played, and you would definitively not hear anything.

try using

pFmt.sample_channel * pFmt.sample_count * pFmt.sample_byte

as the size parameter



Edited 1 time(s). Last edit at 10/18/2010 07:04PM by ekeeke.
Re: Playing sounds with ASND and AESND
October 18, 2010 10:18PM
Hi, i do this but it doesnt hear, the wav file is PCM 16bit stereo
Re: Playing sounds with ASND and AESND
October 18, 2010 10:37PM
Is it in Big Endian?
Re: Playing sounds with ASND and AESND
October 18, 2010 10:40PM
mm, no but the wavplayer librery convert it, or not?

inline u32 le32(u32 i) {
        return ((i & 0xFF) << 24) | ((i & 0xFF00) << 8) | ((i & 0xFF0000) >> 8) | ((i & 0xFF000000) >> 24);
}
 
inline u16 le16(u16 i) {
        return ((i & 0xFF) << 8) | ((i & 0xFF00) >> 8);
}
Re: Playing sounds with ASND and AESND
October 18, 2010 10:41PM
Quote
the_marioga
Hi, i do this but it doesnt hear, the wav file is PCM 16bit stereo

Didn't you ask the exact same question here: [devkitpro.org]

As EkE said on devkitPro:

At a first glance, that seems normal, pFmt.start and pFmt.end are never initialized and they would hold zero by default, hence the result is 0.
You probably need to initialize these fields to -1 before calling LoadPCMWav, in order to get the whole sound length.

I'd advise you to first learn how to use the functions you are calling, seems like you copy-pasted some code from another application but without really understanding what it does and how it works.
Re: Playing sounds with ASND and AESND
October 18, 2010 10:43PM
but i fix it irrlich

int wavPlayer(const char* file) {	
	pFmt.start=-1;
	pFmt.end=-1;
   void *buf = LoadPCMWav(file, &pFmt);
   s32 voice = ASND_GetFirstUnusedVoice();
   if (buf) {
      if (ASND_SetVoice(voice, VOICE_STEREO_16BIT, pFmt.sample_rate,0, buf, pFmt.sample_channel * pFmt.sample_count * pFmt.sample_byte, 255, 255, NULL) == SND_OK) {
		ASND_PauseVoice(voice, 0);
	  } else {
		return 0;
	  }
   } else {
      return 0;
   }
   return 1;
}

But it doesnt hear



Edited 1 time(s). Last edit at 10/18/2010 11:17PM by the_marioga.
Re: Playing sounds with ASND and AESND
October 23, 2010 04:39PM
See if they help you here, and you can post the luafwii 1.0
Re: Playing sounds with ASND and AESND
October 23, 2010 08:25PM
i might be able to help with ASND... i've gotten that to work for me easy.

Haven't messed with AESND yet... (just finally got around to updating libogc last night)

You have IRC :D?
Re: Playing sounds with ASND and AESND
October 23, 2010 09:03PM
Thanks mdbrid, yes i have an IRC, I send you a MP with the URL

Adrian6184 if i solved Wav problem and a little problem with usbkeyboard i release inmediatly XD
Re: Playing sounds with ASND and AESND
October 23, 2010 10:48PM
i'm on #wiihelp on efnet... should be on in a few hours.
Re: Playing sounds with ASND and AESND
October 25, 2010 11:04AM
Thanks mdbrim, i fixed and released a new version, thanks
Re: Playing sounds with ASND and AESND
October 25, 2010 05:24PM
no problem man, my pleasure!
Sorry, only registered users may post in this forum.

Click here to login