Well, just to try I´ve downloaded the SDK 1.6 (v. 4), created a new
AVD based on that and then tried the source code from the first post
in two different situations:

- App compiled using SDK 1.6 on an AVD running 1.6
- App compiled using SDK 1.6 on an AVD running 2.1


Had exactly the same results as "compiling" and running on 2.1: audio
chopping, distortion and artfacts even if I solo the microfone input
level (using a 1 second buffer, sometimes the audio decays in a lot
longer) and AudioRecord buffer overflow messages even if all I do in
the thread is to read from AudioRecord and to play using AudioTrack.


Tomorrow I will try to test my code using another computer and even
on
a real device. In the mean time, any other ideas?


Gabriel


On 15 mar, 01:31, HeHe <cnm...@gmail.com> wrote:
> no chopping, likely because my computer (Core2 E8400) is lightening
> fast.
>
> my AudioRecord.read() returns a value equal to my buffer size, too.
>
> however, it returns recorded samples in a speed "faster than 8khz",
> which makes later playback sound like my voice is slowed.
>
> again, the same code works correctly on 1.5 emulator.
>
> so, seems your problem is not the same as mine :(
>
> On Mar 14, 6:53 pm, Gabriel Simões <gsim...@gmail.com> wrote:
>
>
>
> > Audio chopping also?
> > Could you please test the code above?
>
> > I´ve checked and AudioRecord.read() returns a value equal to my buffer
> > size. Based on that I understand that AudioRecord.read() blocks the
> > execution, waits for the buffer to get a number of samples at least
> > equal to the buffer size and then it returns the audio stream (older
> > "buffer size" number of samples in the AudioRecord internal buffer).
>
> > On 14 mar, 22:34, HeHe <cnm...@gmail.com> wrote:
>
> > > seems i am experiencing similar issue as you 
> > > r.http://groups.google.com/group/android-developers/browse_thread/threa...
>
> > > without any single line of code modification to my app, the count of
> > > frames recorded by app running on sdk 1.6 emulator is significantly
> > > more than that recorded by the same app running on sdk 1.5 emulator.
>
> > > however, the same app runs equally well on both 1.5/1.6 emulators.
>
> > > it is weird.....
>
> > > On Mar 14, 3:00 pm, Gabriel Simões <gsim...@gmail.com> wrote:
>
> > > > Hello,
>
> > > > Since my day 1 I´ve been facing problems with Android AudioRecord API.
> > > > After a lot of research and a lot more trial and error I´ve found my
> > > > way into the code and was able to write an asynctask for audio streams
> > > > recording which encapsules most of the audiorecord and asynctask
> > > > features as a lib, so the developers doesn´t need to worry about
> > > > finding the best audio parameters, work on stop and release, etc.
> > > > So far, everything was right.
> > > > Yesterday I started trying to process the audio I got from the
> > > > microfone input and my code was reacting bad. I revisited it many
> > > > times and decided then to check the audio I was getting from the mic.
> > > > Created in instance of AudioTrack and tried to play it back. The sound
> > > > was horrible, with lots of chopping, lots of distortion and giving me
> > > > even the sensation of low samplerate playback (a single word spoken
> > > > sometimes lasted for seconds on the earphone).
> > > > To check if it was actually my code I went for the internet and found
> > > > the code above. Tried it and got the same results. The only thing that
> > > > comes to my mind actually is that, it doesn´t matter what I do and the
> > > > configuration I try, I always get the buffer overflow message. Even if
> > > > I don´t actually do anything but read from AudioRecord and write to
> > > > AudioTrack (example above, and not in debug mode). If the emulator can
> > > > ´t do it fast enought .... then I´m completly lost here.
>
> > > > Based on the output of my algorithm I think the audio streams I´m
> > > > reading are not right.
>
> > > > Have anyone faced this? does anyone know how to solve it? Could anyone
> > > > try the code (copy and paste) and check if it´s actually my computer
> > > > or my emulator?
>
> > > > package com.example.test;
>
> > > > import android.app.Activity;
> > > > import android.content.Context;
> > > > import android.media.AudioFormat;
> > > > import android.media.AudioManager;
> > > > import android.media.AudioRecord;
> > > > import android.media.AudioTrack;
> > > > import android.media.MediaRecorder;
> > > > import android.os.Bundle;
>
> > > > public class test extends Activity {
>
> > > >     boolean isRecording; //currently not used
> > > >     AudioManager am;
>
> > > >    /** Called when the activity is first created. */
> > > >   �...@override
> > > >    public void onCreate(Bundle savedInstanceState) {
> > > >        super.onCreate(savedInstanceState);
> > > >        setContentView(R.layout.main);
> > > >        am = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
> > > >        Record record = new Record();
> > > >        record.run();
>
> > > >    }
>
> > > >       public class Record extends Thread
> > > >       {
> > > >              // SoundPower sndPower = new SoundPower();
>
> > > >               static final int bufferSize = 200000;
> > > >               final short[] buffer = new short[bufferSize];
> > > >               short[] readBuffer = new short[bufferSize];
>
> > > >               public void run() {
> > > >                 isRecording = true;
> > > >                 android.os.Process.setThreadPriority
> > > >                 (android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
>
> > > >                 int buffersize = AudioRecord.getMinBufferSize(8000,
> > > >                 AudioFormat.CHANNEL_CONFIGURATION_MONO,
> > > >                 AudioFormat.ENCODING_PCM_16BIT);
> > > >                 buffersize = 2048;
>
> > > >                                AudioRecord arec = new
> > > > AudioRecord(MediaRecorder.AudioSource.MIC,
> > > >                                                8000,
>
> > > > AudioFormat.CHANNEL_CONFIGURATION_MONO,
>
> > > > AudioFormat.ENCODING_PCM_16BIT,
> > > >                                                buffersize);
>
> > > >                                AudioTrack atrack = new
> > > > AudioTrack(AudioManager.STREAM_VOICE_CALL,
> > > >                                                8000,
>
> > > > AudioFormat.CHANNEL_CONFIGURATION_MONO,
>
> > > > AudioFormat.ENCODING_PCM_16BIT,
> > > >                                                buffersize,
>
> > > > AudioTrack.MODE_STREAM);
>
> > > >                                atrack.setPlaybackRate(8000);
>
> > > >                                byte[] buffer = new byte[buffersize];
> > > >                                arec.startRecording();
> > > >                                atrack.play();
>
> > > >                                while(isRecording) {
> > > >                                        arec.read(buffer, 0,
> > > > buffersize);
> > > >                                        atrack.write(buffer, 0,
> > > > buffer.length);
> > > >                                }
>
> > > >                                arec.stop();
> > > >                                atrack.stop();
> > > >                                isRecording = false;
> > > >               }
> > > >       }
>
> > > > }
>
> > > > This code is not mine. I´ve just cut and replaced some values (as the
> > > > SampleRate) so it would work.
>
> > > > My specs:
>
> > > > AndroidOS 2.1, last emulator and package (downloaded one week ago).
> > > > Dell Vostro 1000 (onboard soundcard), windows XP SP3.
>
> > > > Thank you very much,
> > > > Gabriel Simões- Ocultar texto das mensagens anteriores -
>
> > > - Mostrar texto das mensagens anteriores -- 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

Reply via email to