Really sorry to keep annoying you Micheal, head just doesn't seem to be
functioning properly today.
I currenlty have the AudiRecord buffer set up like this:
static final int bufferSize = 80000;
final short[] buffer = new short[bufferSize];
short[] readBuffer = new short[bufferSize];
File file = new File(Environment.getExternalStorageDirectory
().getAbsolutePath() + "/record.pcm");
OutputStream os = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(os);
DataOutputStream dos = new DataOutputStream(bos);
So that sets up to buffer to the file record.pcm and the AudioRecord.read()
methos is as follows:
int bufferReadResult = audioRecord.read(readBuffer, 0,bufferSize);
for (int i = 0; i < bufferSize; i++)
buffer[i] = readBuffer[i];
for (int i = 0; i < bufferReadResult; i++)
dos.writeShort(buffer[i]);
So it ends up reading to the file that way, so instead of the OutputStream
os being set
to a FileOutputStream do I set it to something else? and then add the
OutputStream to
a BufferedOutputStream and then that to DaraOutPutStream?
Or does buffer[i] hold exactly what I need and I just need to get whats in
buffer[i] to
the AudioTrack?
Thanks again and sorry to be so much hassle
On Thu, Jan 21, 2010 at 3:19 PM, Michael <[email protected]> wrote:
> Hi Donal,
>
> Once you have constructed an AudioRecord instance you can call
> startRecording and then you can use the various read methods to pull
> the PCM data out.
> Likewise once you have constructed an AudioTrack and called play you
> can use one of the write methods to push the data you got from
> AudioRecord into the play buffer.
>
> Mike
>
> On Jan 21, 3:12 pm, "[email protected]" <[email protected]> wrote:
> > Hi Micheal,
> >
> > Thanks again,
> >
> > I now have it recording in PCM format from the mic and saving it to
> > the sd card and then
> > playing it back through the ear piece.
> >
> > So I just have to look into how to into piping the AudioRecord
> > straight into the AuditTrack.
> >
> > So with the AudioRecord instead of creating a file to save to what
> > should I look into doing?
> >
> > And with the AudioTrack, instead of looking for a file to read in what
> > should I look into doing?
> >
> > Thanks,
> > Kind Regards,
> > Donal
> >
> > On Jan 21, 1:10 pm, Michael <[email protected]> wrote:
> >
> > > Hi Donal,
> >
> > > Yeah if you kick the record off and the play, then you can sit in a
> > > loop reading the data out of Record and putting it into play (on a
> > > thread other than the UI thread of course).
> >
> > > Not 100% sure about the earpiece, but you specify a stream when you
> > > create the AudioTrack and I think a stream encpsulates audio routing
> > > and volume amongst possibly other things.
> >
> > > If you set the stream to STREAM_VOICE_CALL it might come through the
> > > earpiece as this is where a call would be routed, although I guess
> > > that depends on headsets and stuff.
> >
> > > Can anyone clarify if I am right?
> >
> > > Mike
> >
> > > On Jan 21, 11:49 am, "[email protected]" <[email protected]> wrote:
> >
> > > > Hi Mike,
> >
> > > > Thanks for the prompt reply.
> >
> > > > I was looking at the AudioRecord class but had somehow missed the
> > > > AudioTrack class,
> >
> > > > thanks for pointing it out.
> >
> > > > From looking at the classes I think what I have to do is read the
> > > > recording data and put it straight into a streamed
> > > > AudioTrack, would I be correct in saying that?
> >
> > > > And then is it possible to send it to the earpiece?
> >
> > > > Thanks again,
> >
> > > > Donal
> >
> > > > On Jan 21, 11:36 am, Michael <[email protected]> wrote:
> >
> > > > > AudioRecord and AudioTrack are the classes you need.
> >
> > > > > If you use them in streaming mode then you can pipe data out of
> > > > > AudioRecord straight into AudioTrack and you should be able to
> acheive
> > > > > the desired effect.
> >
> > > > > I have done something similar, but without the delay.
> >
> > > > > Mike
> >
> > > > > On Jan 21, 11:28 am, "[email protected]" <[email protected]>
> wrote:
> >
> > > > > > Hi all,
> >
> > > > > > I was wondering is it possible with Android to record from the
> mic and
> > > > > > play the sound back out the earpiece with just a 1 second delay?
> >
> > > > > > I have seen the tutorials and can currently record from the mike
> and
> > > > > > save a 3gp file to the sd card.
> >
> > > > > > However is it posssible to record and say stream the audio
> straight to
> > > > > > the ear piece with just a 1 - 2 second delay?
> >
> > > > > > If so how would I go about doing this?
> >
> > > > > > Would I need to record from the mic and save it to a file and
> then
> > > > > > repaly to the ear piece? and continually do this?
> >
> > > > > > Or would it be possible to record from the mic and stream it
> directly
> > > > > > to the ear piece with just a slight delay?
> >
> > > > > > Any help, info or directions to tutorials would be greatly
> > > > > > appreciated,
> >
> > > > > > Thanks in advance
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]<android-developers%[email protected]>
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en