Search Unity

can't make audio.pitch to work...

Discussion in 'iOS and tvOS' started by Chien, Aug 27, 2010.

  1. Chien

    Chien

    Joined:
    May 1, 2009
    Posts:
    42
    Hi
    I try to use the pitch parameter in unity iPhone 1.7 with the following code:

    Code (csharp):
    1.  
    2. function Update () {
    3.     Debug.Log(audio.pitch);
    4.     audio.pitch+=0.01;
    5. }
    I attached it to an audiosoruce object, the sound is a stereo wave file, uncompressed, 44.1kHz, 16 bit. But the sound is not shifted in pitch. What do I do wrong? Thanks for the help!

    hsin-chien
     
  2. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    have you tried it with a mono wav file?
     
  3. Moonjump

    Moonjump

    Joined:
    Apr 15, 2010
    Posts:
    2,572
    I would never change a value in Update without multiplying it by Time.deltaTime to make it frame rate independent. But I doubt that would lead to your problem.
     
  4. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    generally, yes. Though you might use something like for certain effects:

    Code (csharp):
    1. audio.pitch = transform.position.y*0.1
    Regarding the problem, please try a MONO wav file and see if the problem persists. I know MP3 pitching is not possible, but not sure about stereo wavs - have a feeling it may only work in mono, but cannot check right now.
     
  5. Chien

    Chien

    Joined:
    May 1, 2009
    Posts:
    42
    I found out that it doesn't work on the emulator. i.e., when using Unity Remote, the sound pitch doesn't change. But it works fine on the built. I think it is a bug. Thanks for your help!
     

    Attached Files:

  6. Recluse

    Recluse

    Joined:
    May 16, 2010
    Posts:
    485
    [quoteI found out that it doesn't work on the emulator. i.e., when using Unity Remote[/quote]

    Ah, ok. I never use Remote (I add an extra keyboard+mouse control script to all my iPhone projects so I can just play the build by running it in the editor - great for quick testing).