Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Android sound limit

I am trying to create a piano app for the Android.

I use Titanium.Media.createSound({ url:'sounds/xxx.mp3' }); to create the sound elements, then use .play to play them.

The app only plays the first 7 keys I hit, no matter the order, then silence. I can still hit the ones I hit before, and the sound will play, but no more.

I tried using preload:true and createAudioPlayer too, but no luck. On the iPhone everything works fine. I don't think it's some memory issue since I tested it on the emulator, and actual devices (Nexus One and more).

Update: Also tried using one Sound element and changing its url - no luck either.

I guess it's the Android's prob.

— asked November 4th 2010 by George Marmaridis
  • 7
  • android
  • limit
  • seven
  • sound

3 Answers

  • Please post your code (preferably to git gist).
    Is adb -e logcat displaying any errors or other information?

    — answered November 4th 2010 by Paul Dowsett
  • Answering my own question, it was not the code that there was a problem in, but the sound format.
    It seems Android doesn't really like .mp3, so converting my sound files to .ogg, everything worked fine.
    Tested successfully on the emulator, I guess it will be the same on the device.

    — answered November 5th 2010 by George Marmaridis
  • That's strange - mp3s are playing for me. There are also examples in the KitchenSink in the scripts sound_remote.js and sound_session_mode.js. Does either of these work in your environment?


    — answered November 5th 2010 by Paul Dowsett
    • Yes both of them work. It's not just the mp3s. It's the large number of mp3s trying to be loaded that propably create the problem.

      — commented November 8th 2010 by George Marmaridis
    • What happens when you try to play just one mp3?

      — commented November 8th 2010 by Paul Dowsett
    • It plays just fine. And just today I noticed there's a .ogg "limit" as well at around 30 files. This time solution was easy, since I just had to release the old sound elements (which represented different sound sets for the piano). In the emulator and device log in the Terminal I was getting error: 'E/AudioFlinger(xxxx): not enough memory for AudioTrack size=xxxx' (although my files are barely 10KB each)

      — commented November 9th 2010 by George Marmaridis
    • I'm doing something with sound also - and I had huge problems … switching from mp3 to ogg helped.

      — commented July 25th 2012 by Esben Maaløe
    • I realize that this is two years after!

      — commented July 25th 2012 by Esben Maaløe
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.