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 > Altering the pitch of a sound

#114175 - NeX - Thu Jan 04, 2007 11:33 pm

If I'm looping an engine noise, using a PlaySound command, is there anyway to alter the pitch/speed, so the engine sounds like it is speeding up? Or do I have to use PSG or something to make a sound as dynamic as required?

#114182 - tepples - Fri Jan 05, 2007 12:14 am

Use the ARM7 to alter the sample period while the channel is running. You may have to write your own ARM7 code to do this.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#114295 - Quirky - Sat Jan 06, 2007 11:11 am

It's already implemented in the latest libnds examples - check out the SimpleSound demo, the "blaster" sounds is defined and used as follows:
Code:

        TransferSoundData blaster = {
                blaster_raw,            /* Sample address */
                blaster_raw_size,     /* Sample length */
                11025,                    /* Sample rate */
                127,                       /* Volume */
                64,                         /* panning */
                1                            /* format */
        };

if ( keys & KEY_R) playSound(&blaster);

You can change the sample rate to whatever you like.

#114394 - NeX - Sun Jan 07, 2007 1:33 pm

Thank you for your fast responses. I will attempt to implement the appropiate code as soon as possible.