Search Unity

A list of audio bugs (iOS mostly)

Discussion in 'Editor & General Support' started by gregzo, Aug 17, 2012.

  1. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    How is clipSong loaded? If it is through WWW, you're out of luck: you can't use GetData on a WWW clip.
     
  2. AngelMixu_

    AngelMixu_

    Joined:
    Jul 12, 2013
    Posts:
    10
    I'm not using WWW (that I know of). I've added an Audio Source to a GameObject (which has an sprite, and some scripts), put the .ogg file from the project files to the box named Aucio Clip, and when running I access it through:

    AudioClip clipSong = cancion.audio.clip;
     
  3. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    Try with a wav file instead.
    And please, can we carry on this conversation in another thead? This is not a bug, and I'd like to keep this thread focused...
    Start a new one in scripting, and pm me with a link.
     
  4. kilik128

    kilik128

    Joined:
    Jul 15, 2013
    Posts:
    909
    anyone know why audiosource with negative pitch don't play on android please
     
  5. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    No idea, have you filed a bug report?

    If you need to play audio in reverse / pitch shifted, or more, have a look at G-Audio( in my signature ). It just came out and gives you a completely new way to play audio( no AudioClips, no AudioSources ). It's lower level, more programmer oriented-maybe it can ssuit your use case?

    Gregzo
     
  6. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    Hi all,

    another issue ( small request)

    It seems that since 4.2 onwards is audio streaming from web ( such as webradios ) broken - 4.1.4 plays mp3 streams on iOS and oggvorbis streams on desktop without any problems (...), but since then, including latest, neither one of them can be played :(

    [ WWW's GetAudioClip returns invalid clip with values such as zero channels which is not playable ]

    It's regression already confirmed (for some time actually) and on the issue tracker http://issuetracker.unity3d.com/issues/getaudioclip-no-longer-gets-streamed-audio


    if you have some spare votes upvote pls

    Thanks!
     
  7. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Yeah, the audio system is a bit deceptive.
    I'm streaming 48,000Hz audio samples to the DSP filter and notice they played at 44,100 Hz (about 2 semitones lower) even though AudioSettings.outputSampleRate says 48,000 Hz.
    I tested this by setting up a counter in OnAudioFilterRead and sure as eggs it returned 44,100 Hz.

    To me this is a bug. There should be a way to read the DSP frequency correctly.

    I also submmitted the "Android close and re-open to set frequency" bug to Unity last year and they confirmed it to be a bug. Don't know what's being done about it though.
     
  8. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    Hi,

    You simply should have guessed that Unity resamples clips that don't match the runtime output sample rate in realtime, and that if no clip is set in the AudioSource component, any audio data injected through OnAudioFilterRead is assumed to be 44.1 kHz.

    You could also have guessed that if you do set a clip, you'll be good to go: just create a dummy 1 sample long clip of the right frequency and set it before calling play.

    Of course, it's easy to foresee how this will change the AudioSource's behavior: it won't be distance attenuated anymore and will bypass AudioReverbZone components. Any fool knows that. As any fool knows that this automatic resampling behavior breaks AudioSettings.dspTime's continuity.

    Sorry for the sarcasm, it's just that Unity's audio API is so undocumented and full of quirks, I'd rather laugh than cry.

    Cheers,

    Gregzo
     
  9. MrMetwurst2

    MrMetwurst2

    Joined:
    Jul 16, 2009
    Posts:
    253
    Lol. Thanks for the tips gregzo :)

    So if I set a 1 sample clip to the AudioSource and then play it, can I still feed audio into the OnAudioFilterRead because I find only the clip plays.
     
  10. gregzo

    gregzo

    Joined:
    Dec 17, 2011
    Posts:
    795
    Yeah, it should work. Use AudioClip.Create to create the lightest possible clip of a single sample, at frequency AudioSettings.ouptutSampleRate, and then Play().

    Doing that in Awake() works for me, but you need to set the AudioSource's PlayOnAwake property to false.

    Good luck!

    Gregzo
     
  11. uniphonic

    uniphonic

    Joined:
    Jun 24, 2012
    Posts:
    130
    I just want to say a big thanks to Gregzo for figuring out a lot of this stuff, and I also want to say that his framework G-Audio rocks! It increases the audio capabilities of Unity by HUGE amounts, and makes things possible that I wished were possible back when I started doing audio in Unity. I highly recommend G-Audio, especially if you're trying to do any kind of dynamic music generation with Unity.

    Cheers!
    Jacob
     
    Last edited: May 1, 2014