Hi, The human voice frequency is between 60Hz to 7 KHz see : http://en.m.wikipedia.org/wiki/Human_voice The nyquist-Shannon theorem says that the sampling rate need to be AT LEAST twice as the maximum frequency of the original signal : http://en.m.wikipedia.org/wiki/Nyquist–Shannon_sampling_theorem which mean that a sampling rate of 8 KHz will only allow you to record frequencies below 4 KHz which are low frequencies. In order to hear human voice you would need to sample your recording at 16 KHz. Please that the industrial recording frequency is 44.1 KHz. Regards, Julien-François COLLIN On 16 sep, 19:30, niko20 <[email protected]> wrote: > You definitely need to use a higher sample rate. At 8Khz it will sound > like talking through a phone - very noisy. > > -niko > > On Sep 15, 3:51 am, Harpreet <[email protected]> wrote: > > > > > Hello everybody > > > Any thought? > > > On Sep 13, 9:19 pm, harpreet singh <[email protected]> wrote: > > > > Hi, > > > > I am trying to record the voice using AudioRecord class and writing > > > the read bytes to speaker using AudioTrack class. I am able to hear > > > the voice coming from Speaker but the voice is very low and a lot > > > ofnoiseis coming along with the recorded voice. > > > > Any solution to resolve this problem to reduce thenoiseand loud the > > > actual voice. > > > > I am using below code for this: > > > > package com.my.mic.record; > > > > import android.media.AudioFormat; > > > import android.media.AudioManager; > > > import android.media.AudioRecord; > > > import android.media.AudioTrack; > > > import android.media.MediaRecorder; > > > import android.util.Log; > > > > public class Record extends Thread > > > { > > > > int numCrossing,p,numSamples,af; > > > > static final int bufferSize = 200000; > > > short[] buffer = new short[bufferSize]; > > > short[] readBuffer = new short[bufferSize]; > > > boolean isRecording; > > > AudioManager am; > > > > public AudioRecord arec; > > > public AudioTrack atrack; > > > > private int sampleRate = 8000; > > > > public void run() { > > > > isRecording = true; > > > > android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URG > > > ENT_AUDIO); > > > > int buffersize = > > > AudioRecord.getMinBufferSize(sampleRate,AudioFormat.CHANNEL_CONFIGURATION_M > > > ONO, > > > AudioFormat.ENCODING_PCM_16BIT); > > > > arec = new > > > AudioRecord(MediaRecorder.AudioSource.MIC,sampleRate,AudioFormat.CHANNEL_CO > > > NFIGURATION_MONO,AudioFormat.ENCODING_PCM_16BIT, > > > buffersize); > > > > //buffersize = arec.getMinBufferSize(arec.getSampleRate(), > > > arec.getChannelConfiguration(), arec.getAudioFormat()); > > > > atrack = new > > > AudioTrack(AudioManager.STREAM_MUSIC,arec.getSampleRate(),arec.getChannelCo > > > nfiguration(),arec.getAudioFormat(), > > > buffersize,AudioTrack.MODE_STREAM); > > > > > > > am.setRouting(AudioManager.MODE_NORMAL,AudioManager.ROUTE_EARPIECE, > > > AudioManager.ROUTE_ALL); > > > //am.setMode(AudioManager.MODE_NORMAL); > > > > Log.d("SPEAKERPHONE", "Is speakerphone on? : " + > > > am.isSpeakerphoneOn()); > > > > atrack.setPlaybackRate(sampleRate); > > > > byte[] buffer = new byte[buffersize]; > > > arec.startRecording(); > > > atrack.play(); > > > //atrack.setStereoVolume(atrack.getMaxVolume(), > > > atrack.getMaxVolume()); > > > > final float frequency = sampleRate; > > > float increment = (float)((2*Math.PI) * frequency / 44100); // > > > angular increment for each sample > > > float angle = 0; > > > //AndroidAudioDevice device = new AndroidAudioDevice( ); > > > > while(isRecording) { > > > > try { > > > > arec.read(buffer, 0, buffersize); > > > atrack.write(buffer, 0, buffer.length); > > > > } catch (Exception e) { > > > Log.d("Record", ""+e); > > > } > > > } > > > > arec.stop(); > > > atrack.stop(); > > > //device.releaseTrack(); > > > isRecording = false; > > > } > > > > public boolean isRecording() { > > > return isRecording; > > > } > > > > public void setRecording(boolean isRecording) { > > > this.isRecording = isRecording; > > > } > > > > public AudioManager getAm() { > > > return am; > > > } > > > > public void setAm(AudioManager am) { > > > this.am = am; > > > } > > > > public void stopRecording(){ > > > arec.stop(); > > > arec.release(); > > > atrack.stop(); > > > atrack.release(); > > > arec=null; > > > atrack=null; > > > setRecording(false); > > > this.stop(); > > > } > > > > }
-- 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

