I need to play multiple audio track at a time from sd card. I was trying to play with SoundPool. But it does not support larger files.
I tried with AudioTrack but it needs pure PCM code. PCM code generation bit of complex from mp3 or 3gp file, as android do not have anything build in to that.
I've look OpenSL Engine, But did not find any good example or tutorial to work with it.
How can I play multiple audio at a time in loopy style? any idea, suggestion would be great a help.
Related
In the application, songs will have been split into multiple tracks, one track per instrument.
I need to be able to play all the tracks simultaneously.
I have seen that MediaPlayer is not able to do this, indeed having 5 to 10 separate tracks would cause too much latency.
SoundPool states that it is specifically for short sounds and so is inappropriate for this.
It would appear that AudioTrack would be the answer, but that requires decoding each mp3 into pcm data before playing it.
So, here are my questions -
Even though I have not found any, do any tutorials exist demonstrating how to achieve this ?
Can anyone advise on how to play multiple audiotracks simultaneously ?
Are there any existing examples on how to decode mp3 files using the NDK ?
I have a lot of small .ogg sound files (average size of ~35-50KB) that I need to have played from my AWS S3, and then once played, they need to be cached on the device. There are approximately 200 sounds, and that is 1/10th of what the finished application will use.
I'm not sure the Stagefright library is my best bet, or if an entirely different approach is needed. Should I use Stagefright, or go with another option???
From your query, I feel that you could use SoundPool for your application. Please refer to this link SoundPool for more information.
A couple of examples can be found in MediaActionSound.java, SoundPoolTest.java and Soundclips.java.
Is there an alternative way of playing audio data other than using MediaPlayer. The audio comes from a resource and not a file. I also want it played from a service and not from an activity or using a built-in music player app. What alternative APIs exist? I am coming to the conclusion after much testing that MediaPlayer in Android 4.1 is buggy and fails much more than under previous versions, so I am looking for an alternative means of playing audio.
I think the AudioTrack is the best thing to use here. as you are looking to play from resource then you can use raw pcm audio data as resource.
I'm trying to play a couple of short audio files (ca. 2sec) in an Android App with the Media Player. They do play, but for some of them I get a click sound at the end (which differs from file to file).
There are no click-sounds when I play it on the PC, also I tried to convert it from .mp3 in .ogg and modified the soundfiles themselves, nothing helps, I think the problem is probably the Media PLayer.
For short audio files, like sound effects, I would use a SoundPool
Also see this question and answer here: The correct way to play short sounds Android?
I am doing a cards game for android and I want that everytime a card is thrown, to play throwing sound. It is the same file. I will have also other sounds playing like background music , and certain clicks.
What do you recommend to use, sound pool or create MediaPlayback and play it? What would be the advantage/disdvantage to each one? should I use ogg or mp3/wave file?
Any help in this is appreciated.
Thank you
I would use the sound pool for short clips. I might be wrong but the sound pool has a smaller overhead plus it's the correct way to play short clips, it also allows you to specify how many times per second said sound clip can play which helps slower phones.
With regards to the mp3 vs ogg I use mp3. I don't believe there is any performance issues. Ogg is licence free but that doesn't really matter with regards to your app. Plus it might help if you plan on using these clips on another platform that doesn't play ogg files. No names mentioned :P