Search Unity

Android Audio Issues

Discussion in 'Android' started by sonicviz, Mar 8, 2013.

  1. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Hi,
    I have a new Galaxy S3 alpha (NTT Japan, quad core 1.6 ghz).
    I'm working on a prototype of a multi-track music mixer app with mic recording that runs fine on PC/OSX/iOS.
    I have audio compression/decompression using OggVorbis as well.

    But now I'm getting some weird issues with Android when I do a build and run.

    All the audio after recording from microphone is playing back at 1/2 speed - it's all slowed down.
    I have audio project settings at Best Latency. This fixed the issue once when I had it set at Normal, but now I'm getting it even with Best Latency/Stereo output.

    Any clues? The random nature of this is a little weird, not sure what is going on.

    However...I just came across these two articles on low latency audio issues on Android
    http://code.google.com/p/android/issues/detail?id=3434
    http://www.androidpolice.com/2013/0...or-the-low-latency-audio-in-issue-on-android/

    I'm wondering if I'm wasting my time to even bother to do a music based unity app on android, if the latency issues for input and playback are that bad. Recent FAQ on Sonoma's LLA solution is below.

    Anybody know if Unity implements their own LLA for Android?

    ty!

    Edit2:
    Answers to questions we have been receiving about Sonoma's Low Latency Audio (LLA):
    http://www.sonomawireworks.com/forums/viewtopic.php?pid=76554#p76554
    Doesn't Google already provide low latency audio?
    Google has done it to some extent for playback (out), not recording (in). Sonoma's LLA solution is for both recording and playback (in and out). This is required for audio apps that do input monitoring, amps and effects and more.
    This is the paragraph from Google for 4.2: Low-latency audio - Android 4.2 improves support for low-latency audio playback, starting from the improvements made in Android 4.1 release for audio output latency using OpenSL ES, Soundpool and tone generator APIs. These improvements depend on hardware support — devices that offer these low-latency audio features can advertise their support to apps through a hardware feature constant. New AudioManager APIs are provided to query the native audio sample rate and buffer size, for use on devices which claim this feature.
    If Google has already done it for Playback, what's to prevent them from adding low latency for Recording?
    If/ when Google updates Android to have a low latency input, it typically takes device manufacturers six months to a year to ship with the new OS. We will be happy when all the devices have it, no matter who provides it, because then we will be able to sell more products to a larger audience.
     
    Last edited: Apr 24, 2013
  2. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Nobody using audio on android?
     
  3. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Audio on android seems a dead Unity3Duck due to latency;-(
     
  4. MHD-Salka

    MHD-Salka

    Joined:
    Mar 19, 2013
    Posts:
    72
    dude i'm on the same bout also :( even worse, setting DSP buffer size (audio latency) from a script is not supported on android...
     
  5. MHD-Salka

    MHD-Salka

    Joined:
    Mar 19, 2013
    Posts:
    72
    Year 2013 ....still not fixed yet!!!
     
  6. RyanZimmerman87

    RyanZimmerman87

    Joined:
    Dec 4, 2012
    Posts:
    53
    Only thing I can think of is that maybe you didn't record or export your audio file with a sample rate of 44.1 kHZ? That's my only guess to this problem as I haven't had any audio issues except it seems very tricky to get a good audio mix for phones compared to PC since the bass is like non existent so a lot of my tracks you can't even hear it on my phone.

    All the .wav and .mp3 tracks I've tried so far seem to work fine when exporting from Cubase @ 44.1kHZ.

    Anyone know of good guides for mixing audio for mobile devices?
     
  7. MHD-Salka

    MHD-Salka

    Joined:
    Mar 19, 2013
    Posts:
    72
    All the samples are exported @ 44.1kHZ and latency still exists, for games, the latency is not a big deal , but for music apps its still huge ( more than 50ms, compared to something like 15ms on iOS)

    I've noticed that some devices have better latency than the others (Galaxy Nexus have a lot better latency than first gen Nexus 7)...but still....not even close to iOS or other platforms
     
  8. Marrt

    Marrt

    Joined:
    Feb 7, 2012
    Posts:
    613
  9. sonicviz

    sonicviz

    Joined:
    May 19, 2009
    Posts:
    1,051
    Nice, ty!
     
  10. ChristopherCreates

    ChristopherCreates

    Joined:
    Apr 8, 2015
    Posts:
    24
    I've released an asset that can help with this! It provides access to the native Android audio system for low-latency playback. Also includes full PlayMaker support.

    Check it out. :)

    Asset Store: Android Native Audio
     
  11. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    You can use native methods of each platform. I just made Native Audio asset store plugins which can make a native call to both iOS and Android's fastest native way from one central interface. https://www.assetstore.unity3d.com/#!/content/107067

    There are various ways of playing audio at native side, here's my choice :

    - On iOS it uses OpenAL. It is faster than AVAudioPlayer, AudioToolbox, and SystemSound.
    - On Android it uses AudioTrack, I confirmed it to be faster than SoundPool and no meaningful difference from C++ side OpneSL ES of NDK.

    I have compiled all of my findings in here : http://exceed7.com/native-audio
     
    Marrt likes this.