I am recording my voice using AudioRecord class and I am playing it with a small delay using AudioTrack
How can I change what my voice sounds like?
You can use the SoundPool class:
https://developer.android.com/reference/android/media/SoundPool.html
for example, using the setRate (int streamID, float rate) method, you can change the rate at which sound is played back. If you increase the rate, you'll sound like a chipmunk :-)
Related
I'm writing a simple Voice Recording app in Android and want to display a waveform based on the voice input. I have gone through the Visualizer class and got it to work with the playback of the voice recording (through MediaPlayer)
mVisualizer = new Visualizer(mediaPlayer.getAudioSessionId());
But I'm not sure how to do this with the MediaRecorder class. Is there a way to use the Visualizer class for MediaRecorder or is it meant only for MediaPlayer?
Ideally I want similar wave forms for both recording & playback.
i want to know what is the difference between setting audio sample rate in Android AudioRecord class and Media record class? In audio record class we set sample rate while creating an object of the class like
recorder = new AudioRecord(MediaRecorder.AudioSource.MIC,
SampleRateInHz, RECORDER_CHANNELS,RECORDER_AUDIO_ENCODING, bufferSize);
while in MediaRecorder class we set explicitly through a function call. i.e.
mrec.setAudioSamplingRate(samplingRate);
I tried both but effect of sample rate can only be seen while audio recording not while recording throug mediaRecorder class. I can not understand what is the differnce between both.
AS of android sdk documentation, MediaRecord is used to record audio and video. The recording control is based on a simple state machine. You will always use MediaRecord to record sounds unless you need to access the raw audio data and process them(eg, apply your own DSP effects).In this scenario you will use AudioRecord.setAudioSamplingRateof MediaRecord does the same as passing SampleRateInHz to the AudioRecord, setting the desired sampling rate.The higher the sampling rate the better sound quality and frequency range you will get.An ideal uman ear can hear sound from 20 to 20000 hz.If you set your sampling rate to 4100hz then your frequency response will equal to 4100/2 which is almost 20000hz.However the supported freq range by devices are different. you should always check if the device supports your desired frequency.
In order to check if a specific freq works, you may use the following piece of code:
int bufferSize = AudioRecord.getMinBufferSize(rate[i],AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
if bufferSize value is bigger than 0 then you the requency you provided is supported by device.
i am developing a video recorder which should change the frequency and pitch of the sound only. video should play with the same rate. I used the Soundpool library to change rate of sound in android but it says it only works for audio files. Meanwhile for video recording i am using Mediarecorder library. I used setAudioSamplingRate but it just alters the frequency not pitch of sound. Can you tell me the solution.
Regards
I'm not that familiar with android programming and would like to set the audio volume while (or before) recording a video with MediaRecorder. Is there a way to do that? Or is there a better way to record a video with variable audio volume, instead of using MediaRecorder?
There is no way to set volume while recording using MediaRecorder. But you can set volume while playing using MediaPlayer by using the method setVolume(float, float)
I want to record human voice on my Android phone. I noticed that Android has two classes to do this: AudioRecord and MediaRecorder. Can someone tell me what's the difference between the two and what are appropriate use cases for each?
I want to be able to analyse human speech in real-time to measure amplitude, etc. Am I correct in understanding that AudioRecord is better suited for this task?
I noticed on the official Android guide webpage for recording audio, they use MediaRecorder with no mention of AudioRecord.
If you want to do your analysis while recording is still in progress, you need to use AudioRecord, as MediaRecorder automatically records into a file. AudioRecord has the disadvantage, that after calling startRecording() you need to poll the data yourself from the AudioRecord instance. Also, you must read and process the data fast enough such that the internal buffer is not overrun (look in the logcat output, AudioRecord will tell you when that happens).
As I understand MediaRecorder is a black box which gives compressed audio file on the output and AudioRecorder gives you just raw sound stream and you have to compress it by yourself.
MediaRecorder gives you the max amptitude from last call of getMaxAmplitude() method so you can implement a sound visualizer for example.
So in most cases MediaRecorder is the best choice except those in which you should make some complicated sound processing and you need access to the raw audio stream.
AudioRecorderer first saves data in minBuffer then it is copied from there to the temporary buffer, in MediaRecorder it is copied to files.
In AudioRecorder we need the api setRecordPosition() to copy the saved data at required position, whereas in MediaRecorder the file pointer is does this job to set the position of the marker.
AudioRecorder can be used to those apps which run on an emulator this can be done by providing low sample rate such as 8000, while using MediaRecorder the audio cannot be recorded using emulator.
In AudioRecord the screen sleep after sometime, while in MediaRecorder the screen does not sleep.