[android-developers] Re: Audio Mixing
I found the solution to my problem: Service.startForeground. This call makes sure my background service will keeps its priority when its running in the background. The SDK has a nice example that works across all API levels: http://developer.android.com/intl/de/resources/samples/ApiDemos/src/com/example/android/apis/app/ForegroundService.html Jesper Hansen -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: Audio Mixing
I agree with everyone here that low latency audio is still far-fetched idea for android. For low latency audio we need to have very good designed audio framework which i guess at this point of time is not ready in android. However i have been told in one of the answers from google that they are currently working on android audio to come up with a better design which can really revolutionize the android audio. So that low latency and gaming audio requirements are met. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using remove me as the subject.
[android-developers] Re: Audio Mixing
Kevin- I agree that the basics of audio mixing are pretty simple (adding byte arrays), though its the other things you mentioned that I don't have much experience with and am having trouble finding good resources about (overflow, volume adjustment, etc.). If anyone has any resources or code they would be able to share with me, that would be a great help. I basically need to come up with a toolkit that can accurately combine n sounds. Mario, I had a look at your lib. It looks interesting, but not particularly well suited to handle the latency issues I am having. I will keep it in mind for future apps I work on. Thanks for the heads up. Ani- where were you told that google is working on enhancing audio? Do you have any site you can share with us? Thank you. -Kevin On Apr 13, 2:25 am, ani anish198519851...@gmail.com wrote: I agree with everyone here that low latencyaudiois still far-fetched idea for android. For low latencyaudiowe need to have very good designedaudio framework which i guess at this point of time is not ready in android. However i have been told in one of the answers from google that they are currently working on androidaudio to come up with a better design which can really revolutionize the androidaudio. So that low latency and gamingaudiorequirements are met. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using remove me as the subject.
[android-developers] Re: Audio Mixing
Kevin I don't remember where i saw that reply but someone from android team can very well confirm this i.e. are they working on new audio framework or not?? Sadly, in this area generally android team response is not very enthusiastic. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using remove me as the subject.
[android-developers] Re: Audio Mixing
Kevin I don't remember where i saw that reply but someone from android team can very well confirm this i.e. are they working on new audio framework or not?? Sadly, in this area generally android team response is not very enthusiastic. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en To unsubscribe, reply using remove me as the subject.
[android-developers] Re: Audio Mixing
I did some audio work on Android and have to agree with Kevin's analysis. Writting to the audio device via AudioTrack works and you can also alter the buffer sizes to get to the lowest possible latency but from what i remember the buffer was still pretty big. Also, AudioTrack does not allow passing in direct buffers so you have to do everything with an array backed buffer if you go native which might incurr overhead as the array has to be locked when working with it in native code. And i know it's considered spam and off topic, but Kevin maybe the lib i'm working at the moment is of interest for you. It does have some features of XNA (cross-plattform, meaning Windows/Linux/Mac and Android) and even has more or less ports of some XNA classes like SpriteBatch) and is pretty big already, covering a lot of ground. You can check it out at http://www.badlogicgames.com and http://code.google.com/p/libgdx/. The public API is heavily document and there's a lot of examples in the SVN that should get you started. Alternatively there's a series of articles that serve as a tutorial. This series is not yet finished but gets updated on a constant basis. Sorry for the thread hijack :) On 12 Apr., 22:10, Kevin Duffey andjar...@gmail.com wrote: Mixing audio in itself is not too hard.. you basically add each byte of each sound (that plays at the same exact point in time). You do face the issue of dynamic range.. if you are mixing 16-bit sounds, you don't want to use a 16-bit value to store the mixed sounds.. you'll overflow it. or clip the sound. Usually you'll use a 32-bit integer to add all the sounds, then you'll lower it to 24-bit or 16-bit with some fancy algorithm that won't clip all the mixed sounds.. sort of like lowering their combined volumes so they don't clip. However, you can't keep lowering volumes with more sounds.. it changes the overall mixed volume.. there is some FFT or something like that which properly does this. It's been a long time since I did this stuff, back when SoundBlaster 8-bit sound card was out and mikmod and module players were quite popular. Long before the sound cards mixed audio themselves. ;) I am sure you can find stuff on it. I too wanted to work on a low-latency music app, but until google puts more resources into making the NDK and android platform on par with iPhone, I don't think it's worth the effort. There is just WAY too many problems with the issue of low latency audio right now. Really what you need is to use the NDK, pass the sound buffers of different sounds (or better yet, NDK can directly access the buffers of loaded sounds or SD stored sounds), do the mixing there, and then be able to play to a the sound output in some low latency manner. Unless things have changed, I've been led to believe we're a long ways off before we'll have anything like that. Sadly, it seems google/android team is completely quiet on any details at all with regards to this stuff. I've not been able to find one bit of info whether or not they are hearing us game/audio developers and are working on a better platform for us or not. Given their stagnant market work and lack of any info at all on anything being worked on.. I wouldn't count on anything anytime soon. Let's hope I am very wrong on this, but I fear that the articles that indicate android will surpass iphone by 2012 are grossly misleading if android as a platform can't compete on games and audio with iPhone. :( They still need to fix the multi-touch issue which plagues gamers on several devices but apparently it's in the hardware, not the platform. If I am wrong.. if there is some place google posts what is coming and when.. please correct me. I really love the idea of Android, and still follow along, but I've basically stopped any development primarily because there isn't much money in it, and with no idea if far better game/audio support is coming, I don't want to waste time hoping. There are other avenues of interest in non game/music related things for Android tho, but my heart lies in making a kick ass music app... and possibly a side scroller game at some point. Would be wonderful if Google had something like XNA for us. :) On Mon, Apr 12, 2010 at 12:42 PM, k_day kevin.r@gmail.com wrote: Despite everything I have read about the difficulty of making low latency audio apps in Android, I am giving it a shot. To start, I loaded each note in an octave into a SoundPool, and then looped through each note that was to be played on that beat and called play(). This didn't even come close to being accurate enough for me, and got especially bad if a lot of notes were being played at once. From what I read, the only way to do something like this is to mix the audio yourself, though I am not entirely sure how to go about this. My initial thought is that for each beat, I could precompute the sound the sound that is to be played (i.e., combine the wav's), and then pass that
Re: [android-developers] Re: Audio Mixing
Very interesting.. but from what you've said, you're running into the same latency issues as everyone else on android. The chance of making a multi-touch MPC program, or a synth that can play multiple sounds at once seems a bit far off yet for Android at this point. :( On Mon, Apr 12, 2010 at 1:28 PM, Mario Zechner badlogicga...@gmail.comwrote: I did some audio work on Android and have to agree with Kevin's analysis. Writting to the audio device via AudioTrack works and you can also alter the buffer sizes to get to the lowest possible latency but from what i remember the buffer was still pretty big. Also, AudioTrack does not allow passing in direct buffers so you have to do everything with an array backed buffer if you go native which might incurr overhead as the array has to be locked when working with it in native code. And i know it's considered spam and off topic, but Kevin maybe the lib i'm working at the moment is of interest for you. It does have some features of XNA (cross-plattform, meaning Windows/Linux/Mac and Android) and even has more or less ports of some XNA classes like SpriteBatch) and is pretty big already, covering a lot of ground. You can check it out at http://www.badlogicgames.com and http://code.google.com/p/libgdx/. The public API is heavily document and there's a lot of examples in the SVN that should get you started. Alternatively there's a series of articles that serve as a tutorial. This series is not yet finished but gets updated on a constant basis. Sorry for the thread hijack :) On 12 Apr., 22:10, Kevin Duffey andjar...@gmail.com wrote: Mixing audio in itself is not too hard.. you basically add each byte of each sound (that plays at the same exact point in time). You do face the issue of dynamic range.. if you are mixing 16-bit sounds, you don't want to use a 16-bit value to store the mixed sounds.. you'll overflow it. or clip the sound. Usually you'll use a 32-bit integer to add all the sounds, then you'll lower it to 24-bit or 16-bit with some fancy algorithm that won't clip all the mixed sounds.. sort of like lowering their combined volumes so they don't clip. However, you can't keep lowering volumes with more sounds.. it changes the overall mixed volume.. there is some FFT or something like that which properly does this. It's been a long time since I did this stuff, back when SoundBlaster 8-bit sound card was out and mikmod and module players were quite popular. Long before the sound cards mixed audio themselves. ;) I am sure you can find stuff on it. I too wanted to work on a low-latency music app, but until google puts more resources into making the NDK and android platform on par with iPhone, I don't think it's worth the effort. There is just WAY too many problems with the issue of low latency audio right now. Really what you need is to use the NDK, pass the sound buffers of different sounds (or better yet, NDK can directly access the buffers of loaded sounds or SD stored sounds), do the mixing there, and then be able to play to a the sound output in some low latency manner. Unless things have changed, I've been led to believe we're a long ways off before we'll have anything like that. Sadly, it seems google/android team is completely quiet on any details at all with regards to this stuff. I've not been able to find one bit of info whether or not they are hearing us game/audio developers and are working on a better platform for us or not. Given their stagnant market work and lack of any info at all on anything being worked on.. I wouldn't count on anything anytime soon. Let's hope I am very wrong on this, but I fear that the articles that indicate android will surpass iphone by 2012 are grossly misleading if android as a platform can't compete on games and audio with iPhone. :( They still need to fix the multi-touch issue which plagues gamers on several devices but apparently it's in the hardware, not the platform. If I am wrong.. if there is some place google posts what is coming and when.. please correct me. I really love the idea of Android, and still follow along, but I've basically stopped any development primarily because there isn't much money in it, and with no idea if far better game/audio support is coming, I don't want to waste time hoping. There are other avenues of interest in non game/music related things for Android tho, but my heart lies in making a kick ass music app... and possibly a side scroller game at some point. Would be wonderful if Google had something like XNA for us. :) On Mon, Apr 12, 2010 at 12:42 PM, k_day kevin.r@gmail.com wrote: Despite everything I have read about the difficulty of making low latency audio apps in Android, I am giving it a shot. To start, I loaded each note in an octave into a SoundPool, and then looped through each note that was to be played on that beat and called