Honestly, the only way to get 100% accuracy is to mix the sounds
internally yourself. This is what Electrum Drum machine does. It then
feeds the sound to the AudioTrack class. However, due to the CPU
needed, it limits how many sounds you can mix at once of course.

-niko

On Oct 5, 1:32 pm, Robert Green <rbgrn....@gmail.com> wrote:
> Set a sound trigger schedule in milliseconds.  There are many ways to
> model it.  Use whatever you're most comfortable with.  The key
> elements are "what sound to trigger" and "when to trigger it."
>
> I wouldn't use absolute time.  I'd make it relative to something so
> that you can pause and resume and you don't need to update everything
> in the queue.
>
> Then I'd run a thread that loops with only a 1ms sleep on it that
> checks the queue and triggers sounds at the exact MS that they specify
> to be triggered at.
>
> That outta get you fairly accurate playback.  I also like to add
> things that make it so that if the loop missed a trigger, it plays it
> immediately unless it missed it over 15ms ago or something like that.
> I think 10-15ms is where people will be able to hear if something is
> getting off-beat.
>
> On Oct 5, 3:48 am, Zuli <paolo.zuli...@gmail.com> wrote:
>
> > Hi,
> > I am working on an app that uses the SoundPool class to play sounds.
> > Basically every n milliseconds I need to play up to 16 sounds and I
> > need this to be as steady as possible.
> > The best solution I found so far is to use a java.util.Timer and the
> > scheduleAtFixedRate method (setting also a
> > THREAD_PRIORITY_URGENT_AUDIO in the TimerTask run method), the result
> > is pretty good but it is still not perfect and sometimes the
> > executions get slightly delayed.
>
> > Is there some other way I should try to play sounds _exactly_ every n
> > milliseconds? Different threads, some kind of optimization, stuff like
> > this?
>
> > Thanks,
> > Zuli
>
> > ps: I am using .ogg files and there is not much graphic involved in
> > the computation.
>
>
--~--~---------~--~----~------------~-------~--~----~
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