After calling play you need to keep calling write so you can feed
AudioTrack´s internal buffer and keep the audio playing. Then, before
you call read you can process your stream the way you want.

About upsampling, downsamplig: it´s a tecnique for changing the
samplerate of a signal trying to modify it as little as possible. When
you downsample you lose information; when you upsample you interpolate
to try to figure out what the information would be since you dont have
it.

For example, if you have a stream sampled at 10khz and want to
downsample it to 5khz (which will play faster at your AudioTrack 10khz
object) you just need to use the even or odd samples, and discard the
rest.

Hope it helps,
Gabriel

On 26 mar, 08:57, Simone Russo <simone.russ...@gmail.com> wrote:
> Hi, thank you very much for your answer.
> The problem I have is that I got an audio stream, say 5 seconds long.
> I want the user to be able to change the volume and the playbackrate while
> the sound is being played.
> I'm able to modify those parameters before i call the play() method, but I
> need to change them
> while the stream is being played as well
> What do you mean by "you can upsample/downsample your streams to get
> the desired efect"?
> Thanks again
> Simone
>
> 2010/3/26 Gabriel Simões <gsim...@gmail.com>
>
>
>
> > Hello Simone.
>
> > What problems have you been facing with AudioTrack?
>
> > Besides the fact that you will need to handle all the overhead of time/
> > streams controling everything should work fine with AudioTrack, even
> > using the Emulator.
>
> > For the volume change for example, try to each position of your audio
> > streams for a float between 0.0f (no sound) and 1.0f (volume at 100%)
> > and cast back to short before playing. Should give you the results you
> > want.
>
> > For the SampleRate, once AudioTrack is created you cannot change it´s
> > samplerate value, but you can upsample/downsample your streams to get
> > the desired efect.
>
> > Hope it helps,
> > Gabriel
>
> > On 23 mar, 17:57, Simone <simone.russ...@gmail.com> wrote:
> > > Hi everyone, I'll try to explain briefly what I need to do.
> > > I need to load an audio resource and play it, but I also need to be
> > > able to modify some parameters (like the volume, or the playback rate)
> > > while the audio is being played.
> > > For example, I might want to play a 10 seconds audio stream, and
> > > change the volume only after 3 seconds.
> > > Is there a way to do it? I've been experimenting a little with
> > > AudioTrack without results.
> > > Thanks,
> > > Simone
>
> > --
> > 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<android-developers%2bunsubs­cr...@googlegroups.com>
> > For more options, visit this group at
> >http://groups.google.com/group/android-developers?hl=en
>
> > To unsubscribe from this group, send email to android-developers+
> > unsubscribegooglegroups.com or reply to this email with the words "REMOVE
> > ME" as the subject.- Ocultar texto das mensagens anteriores -
>
> - Mostrar texto das mensagens anteriores -

-- 
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 from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to