Nobody will know what you want to do untill you give more info.

On 12月7日, 上午10时34分, Hunter  Peress <hunt...@gmail.com> wrote:
> Logic:
>         for (int i = 0; i < tempBuffer.length; i++) {
>                                 saveBuffer[saveBufferPos] = tempBuffer[i];
>                                 saveBufferPos++;
>                         }
>
> On Dec 6, 6:23 pm, Hunter  Peress <hunt...@gmail.com> wrote:
>
>
>
> > Here is my AudioRecorder class, using audio record, why is it not
> > producing any sound data?
>
> > import java.io.FileOutputStream;
> > import java.io.IOException;
>
> > import android.content.Context;
> > import android.media.AudioFormat;
> > import android.media.AudioRecord;
> > import android.media.MediaRecorder;
>
> > public class AudioRecorder implements Runnable
> > {
>
> >         public boolean isRecording = false;
>
> >         byte[] tempBuffer = new byte[AudioRecord.getMinBufferSize(44100,
> > AudioFormat.CHANNEL_CONFIGURATION_STEREO,
> > AudioFormat.ENCODING_PCM_16BIT)];
> >         byte[] saveBuffer = new byte[tempBuffer.length * 1000];
> >         int saveBufferPos=0;
> >         Context ctx;
> >         String filePath;
> >         /**
> >          * Handler is passed to pass messages to main screen Recording is
> > done
> >          */
> >         public AudioRecorder(Context ctx,String filePath)
> >         {
> >                 super();
> >                 this.filePath = filePath;
> >                 this.ctx = ctx;
> >         }
>
> >         public void run()
> >         {
> >                 AudioRecord recordInstance = null;
> >                 // We're important...
> >                 android.os.Process.setThreadPriority
> > (android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
> >                 recordInstance = new 
> > AudioRecord(MediaRecorder.AudioSource.MIC,
> > 44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,
> > AudioFormat.ENCODING_PCM_16BIT,tempBuffer.length);
> >                 recordInstance.startRecording();
> >                 // Continue till STOP button is pressed.
> >                 this.isRecording = true;
> >                 long cms = System.currentTimeMillis();
> >                 while (System.currentTimeMillis() - cms < 5000) {
> >                         for (int i = 0; i < tempBuffer.length; i++) {
> >                                 tempBuffer[i] = 0;
> >                         }
> >                         recordInstance.read(tempBuffer, 0, 
> > tempBuffer.length);
> >                         for (int i = saveBufferPos; i < tempBuffer.length; 
> > i++) {
> >                                 saveBuffer[i] = tempBuffer[i-saveBufferPos];
> >                                 saveBufferPos++;
> >                         }
> >                 }
> >                 recordInstance.stop();
> >                 try {
> >                         FileOutputStream ofo = new 
> > FileOutputStream(filePath);
> >                         ofo.write(saveBuffer);
> >                         ofo.close();
> >                 } catch (IOException e) {
> >                         e.printStackTrace();
> >                 }
> >         }
>
> > }- 隐藏被引用文字 -
>
> - 显示引用的文字 -

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