After several tests involving AudioTrack, both STATIC and STREAM mode,
It was obvious I could not use this because of the specificity of my
metronome, which can mix and play Notes, Half notes, quarter notes and
triplets at the same time. Filling and reseting the AudioTracks
buffers between each tempo change was way too long, even if after that
no more CPU was needed because I used the loops (pretty interesting
feature though, especially with the OnPlaybackPositionUpdateListener
features allowing to sync between several AudioTracks, or UI). In
STREAM mode, filling the buffer permanently was CPU consuming too, and
I was facing a sync problem with my UI, which needs to react to each
first beat of the bar.

To answer Kristopher, I can testify that the latencies are very low
and pretty appropriate to short loops (for Audiotrack at least, as I
didn't test Mediaplayer).

So, after that I followed Dianne 's idea and searched about delayed
message posting. Finally I came up to a mix between delayed messages
and Bret supposition with a timeStamp refreshed on each first beat to
compensate the (eventual) jitter.

GC doesn't bothers it seems, even if it happens, I see it in the debug
log, but do not hear jitter anyway.

Is there something like Task Manager on android to see how much CPU it
costs now ? I would like to compare the two versions now :)

Thanks for your reactive and precise help.

And oh, happy new year :)

Rgds, Alex

On 30 déc 2010, 10:56, Slash4 <alex.cen...@gmail.com> wrote:
> Thanks Kostya,
>
> Streaming seems to be a great solution. And it is very interesting
> because this way I can mix sounds... Let's do this :)
>
> Rgds, Alex
>
> On 29 déc, 21:23, Kostya Vasilyev <kmans...@gmail.com> wrote:
>
> > To elaborate a bit:
>
> >http://developer.android.com/reference/android/media/AudioTrack.html
>
> > AudioTrack supports "streaming" mode of operation, where data can be fed
> > into it on the fly.
>
> > You'd still need to do some sort of scheduled periodic loop, for feeding
> > data to AudioTrack in chunks, but this way can deal with much larger
> > jitter, which would be reasonable at application level.
>
> > At some point, you'd need to queue the metronome click, presumably from
> > an audio file packed within the application.
>
> > This should help with that:
>
> >http://mindtherobot.com/blog/580/android-audio-play-a-wav-file-on-an-...
>
> > -- Kostya
>
> > 29.12.2010 22:40, Frank Weiss пишет:
>
> > > I'd look into Kostya's suggestion. Ideally, you only need the click
> > > sample and you can program the audio player to play the sample at
> > > precise intervals.
> > > Trying to do precise timing with SDK programming is just frought with
> > > pitfalls, AFAIK.
> > > --
> > > 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
>
> > --
> > Kostya Vasilyev -- WiFi Manager + pretty widget 
> > --http://kmansoft.wordpress.com

-- 
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

Reply via email to