iPhone audio.pitch

Hello,

On the desktop it works:


var gameMusic:AudioSource;
if (totalBalloons % 8 == 0 ) gameMusic.pitch += 0.08;


the pitch factor increases steadily…

but after downloading it to the iphone the pitch seems
to be constantly set to 1.0;

I am using unity 1.03f1 and iphone os 3.01.

Does anyone know how to make the pitch change on the iphone to give my game a little bit of audio “drive”.

Thank you for the great help in advance,

Martin

I don’t think you can alter the pitch of compressed audio (i.e. mp3 or m4a) on the iPhone at runtime, even though it works in the editor.

I change the pitch of uncompressed sounds all the time though and it works fine on the device.

Hello,

Thank you for the fast reply.

This means I cannot speed up my background music.

Is there really no way, because it would help me to create excitement in the game.

Thank you for any ideas.

Regards,

Martin

Thank you.

I tried it out. It really just works for uncompressed audio.

Many greetings,

Martin

Not sure if this works exactly for your situation, but I would use some software for editing sound (such as the freeware app audacity) to make both a normal and sped-up version of your music, and swap between the two mp3’s at runtime by changing the audio source’s file. This uses up more memory of course (because you’d have both songs in memory at once) but it might not be a problem for you if the rest of your game is fairly efficient.

PirateNinja, the main concern there would be latency.

On the older devices (3G iPod Gen 1) the sync times can be crippling. I’ve experienced first-time switches of an mp3 to take upto a second, and even half a second or more on the second go.

Even on the 3gs/ipod gen 2 the first time switch can hit you around 0.2 of a second, but its basically spot on every time afterward.

The biggest concern for timing critical mp3 swaps is if you literally call a Stop(), switch the audio source and go Play() again without a sufficiently long yield in the middle, the second one simply might not play at all.

As I understand it, this is not a unity issue per se, its the mp3 decompression hardware being crap :slight_smile:

If you can wear it (design-wise), a good way to hide the transition would be to have one mp3 end, play a very short one shot sound (uncompressed) so you get that extra 0.3 or so of a second you need to ensure the second mp3 has time to do its thing.

Unfortunatly 1 minute of audio in stereo mp3 vs. 1 minute at quarter quality (defined as 22khz mono here) is still about 3x bigger in memory :confused:

Given the mp3 players works without problems I would be willing to bet that the problem is your app “beeing crap” (or just not keeping enough cpu time and/or memory free to make this anywhere fast)

Actually, there’s a significant pause between mp3s even in the native mp3 player :slight_smile:

Its simply not viable to use the device for timing specific mp3 swappin’ (such as swapping from one mp3 to the other without ‘missing a beat’)

I totally see where you’re coming from though :stuck_out_tongue: But seriously though, I have tested it with both native x-code and basic unity setups.