gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Sound in homebrew DS software

#153922 - johnnywashngo - Tue Apr 08, 2008 1:36 pm

Hi,

I am going through various tutorials to help me get to grips with DS coding. I am quite out of practice with my C from what I can tell and also am quite new to DS coding in general.

To date I am confident that I can get graphics on screen/s and get some input from the various control methods the DS provides. I have learned a lot of this from the manual here: http://patater.com/manual

However, I am having a problem with the sound section of that manual, in particular getting the sound to play back at the correct sample rate. I have several audio files, each encoded at 22050 Khz and then converted to raw using the sox command from the manual: http://patater.com/files/projects/manual/manual.html#id2537335.

My problem is that when I instruct the DS to play any of the sounds they are played half speed. This can be remedied in code by increasing the sample rate from 22050 to 44100 but this seems very wrong and I am wondering what I am doing wrong?

Has anybody else come across this issue?

Is there a better sound tutorial out there?

Cheers.

#153926 - eKid - Tue Apr 08, 2008 2:33 pm

Does it sound okay at double frequency? Or does it sound a little.. messy? Maybe your samples are stereo and thus causing double the amount of data.

#153932 - silent_code - Tue Apr 08, 2008 3:38 pm

this is a very general hint, as i don't have much time right now:
sound should be 32kHz (or anything you get by power of two integer dividing the sample rate - or shifting) 8bit. that should work out of the box.

happy coding!

#153937 - johnnywashngo - Tue Apr 08, 2008 4:48 pm

@eKid: Yes it did sound ok at double the sample rate, much better that at the actual sample rate.

@silent_code: Cheers for that, I will try to encode the audio at 2^15 later on and see if that yields better results for me.

#153940 - eKid - Tue Apr 08, 2008 5:01 pm

Hmm, I'm looking at the SoX usage. I don't see a -b option (as used in Patater's tutorial to set 8-bit), I see a -1 option that sets sample size to 1 byte (8-bit). Try using options -1 (8-bit) -s (signed) and -c1 or -c 1 (mono).

#153963 - sumiguchi - Tue Apr 08, 2008 6:50 pm

Quote:
Is there a better sound tutorial out there?

I dunno but ASlib is very easy to use ^^ you may want to check it out and save yourself some trouble....http://forum.gbadev.org/viewtopic.php?t=14617&highlight=aslib