kailash09dabhi / omrecorder Goto Github PK
View Code? Open in Web Editor NEWA Simple Pcm / Wav audio recorder with nice api. https://play.google.com/store/apps/details?id=com.kingbull.omrecorder
License: Apache License 2.0
A Simple Pcm / Wav audio recorder with nice api. https://play.google.com/store/apps/details?id=com.kingbull.omrecorder
License: Apache License 2.0
@kailash09dabhi and @ultraklon Thanks for your great library. It work wells when I test on emulator.
But when install it to my Huawei Nexus 6P, It does not work well.
The recorded wav is much longer than the original input audio.
I look at the log, when on the device , the onAudioChunkPulled is called more often than in the emulator.
When on device, the onAudioChunkPulled is called more 10 times then in the emulator. Is that a reason for my problem?
Thanks!
According to WaveFormat, Subchunk2Size is the actual sound data size, i.e. the pcm file size and ChunkSize is 36 + SubChunk2Size.
However, in your WavHeader File, Subchunk2Size is the sound data size minus 44.
So, I am confused about why you substract 44?
Subchunk2Size is correspond to totalAudioLen, ChunkSize is correspond to totalDataLen in your WavHeader File.
If it is possible to add 1 second of silence (in recorded audio) once user called recorder.resume() or alternatively add 1-sec silence (in recorded audio) when a user called recorder.pause()
Can it be possible to listen the record on pause recording?
Hi Kailash,
how to use getMaxAmplitude() which is available for MediaRecorder class but how to acces this in your library.
And yes thanks for Pause/Resume feature :)
Thanks.
We've been using OmRecorder without issues for the past couple of weeks and received a few reports about a bad experience on API 16. Upon testing, we started receiving this error:
java.lang.IllegalArgumentException: Invalid audio buffer size.
We're following the steps and example, and don't have issues with API 18+. Any thoughts?
hey sir, just a quick question, I need to call for audioRecorder.release() when stop Recording, cause I also didnt ??
Cause I get this error E/AudioRecord-JNI: Error -38 during AudioRecord native read
when start the recording again.
Behaviour now:
E/AudioRecord-JNI: Error -38 during AudioRecord native read
This happened nearly every time in Android 10 device.
I know this may cause by mic is using by another app, but in my testing, my phone is not record anything else when having error.
May be because of the recorder is not release when stop recording?? I have no single clue.
Please give me some hint..
Audio Filecontinues existing record also
400M?????
Is it possible to only Remove Silence at the beginning of the recording and not stop audio recording when there is Silence in the middle?
Thank you
在小米 乐视上面
I got the following error when I click on the play button
04-28 21:18:20.607 8935-8935/morpheus.oniri E/AndroidRuntime: FATAL EXCEPTION: main
Process: morpheus.oniri, PID: 8935
java.lang.NullPointerException: Attempt to invoke interface method 'void omrecorder.Recorder.startRecording()' on a null object reference
at morpheus.oniri.activities.CarnetDeReve$1.onClick(CarnetDeReve.java:115)
at android.view.View.performClick(View.java:4780)
at android.view.View$PerformClick.run(View.java:19866)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
That happen when i click on the play button and below you can see the line where it says the error is.
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
play.setBackgroundResource(R.drawable.ic_stop);
recorder.startRecording();
}
});
eg:
The first byte can be the current time,
The second byte can be the location,
Then it can be the Audio content.
so i have writen a simple code based on your project to record .wav for multiple users but whenever i try the application everything is fine untel i clic on on the imageview containing the photo of mic to record its just crushes ?
any solution ??
this is a link for my question in stackoverflow too https://stackoverflow.com/questions/51821888/record-wav-format-file-in-android-using-omrecorder
plz anwser me asap ??
Hi
Is it possible to store the WAV file on the private Internal storage allocated to the app...?
For example instead of using a File can one use the FileOutputStream ?
best,
b16a
Hi,
Nice Library!
This may be a stupid question but just to confirm this is indeed lossless uncompressed voice data being stored in the WAV file...?
Many thanks,
b16a
wavsetupRecorder();
recorder.startRecording();
E/AudioRecord: Could not get audio input for record source 1, sample rate 44100, format 0x1, channel mask 0x10, session 161, flags 0
E/AudioRecord-JNI: Error creating AudioRecord instance: initialization check failed with status -22.
E/android.media.AudioRecord: Error code -20 when initializing native AudioRecord object.
E/AndroidRuntime: FATAL EXCEPTION: Thread-367
Process: com PID: 3241
java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
at android.media.AudioRecord.startRecording(AudioRecord.java:885)
at omrecorder.PullTransport$AbstractPullTransport.preparedSourceToBePulled(PullTransport.java:89)
at omrecorder.PullTransport$AbstractPullTransport.start(PullTransport.java:70)
at omrecorder.AbstractRecorder$1.run(AbstractRecorder.java:29)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalArgumentException: Invalid audio buffer size -2 (frame size 2)
at android.media.AudioRecord.audioBuffSizeCheck(AudioRecord.java:819)
at android.media.AudioRecord.(AudioRecord.java:397)
at android.media.AudioRecord.(AudioRecord.java:301)
at omrecorder.Source$Default.(Source.java:28)
at omrecorder.PullableSource$Default.(PullableSource.java:78)
at com.dancetime.WavRecorderActivity.mic(WavRecorderActivity.kt:121)
at com.dancetime.WavRecorderActivity.setupRecorder(WavRecorderActivity.kt:94)
at com.dancetime.WavRecorderActivity.onCreate(WavRecorderActivity.kt:44)
FileNotFound Exception arises on calling FIle() function , please do solve the problem quickly and thanks !
It's 1M+ when I recording only 10s
so big it is, so, how to compress it.
Hi kailash09dabhi. Thanks for your lib.
I have already use your lib to record .wav Audio. Its ok
But I do not know how can I record Pcm Audio file (.amr, .3gp?), the output file has data, but it can not play or read.
Here is my code:
recorder = OmRecorder.pcm(
new PullTransport.Default(RecorderUtil.getMic(source, channel, sampleRate)),
new File("path to my .amr file"));
Where is my wrong?
Hi there, currently I'm using default MediaRecord.getMaxAmplitude() to draw canvas base on the amplitude received. My codes below:
`Runnable updateVisualizer = new Runnable() {
@Override
public void run() {
// get the current amplitude
int x = mRecorder.getMaxAmplitude();
visualizerView.addAmplitude(x); // update the VisualizeView
visualizerView.invalidate(); // refresh the VisualizerView
// update in 40 milliseconds
handler.postDelayed(this, 40);
}
};`
I run the handler above when recording is start, however, by using your library I have no idea how to implement such handler using the MaxAmplitude return by AudioChunk, please help.
I am using the OmRecoder.pcm with 16KHZ sample rate and 16 bit PCM with skip silence options as default.
Sometimes i have noticed that the last 1 seconds in a 8-9 seconds total audio is missed when the wav file is saved.
Can u guide me whether I am doing anything wrong.
Regards,
WAV data can be write into mp3 format with lamemp3
below project, record wav to mp3 already.
https://github.com/GavinCT/AndroidMP3Recorder
hope omrecorder can implements mp3 format support.
Hi, @kailash09dabhi
Thanks for this great lib!
I'm using it to record an audio like karaoke. Most of it works fine, except that the music part is too louder than the human part.
(When I record the singing, I use the phone to play music at the same time).
Thanks for your time! :)
Hi, I am getting could not build OutputStream from this file
error on devices with android 5.1.1 and 8.0.0
it is from the private OutputStream outputStream(File file)
method ,when starting recording
But when I copied the the method to my MainActivity, and called it whith exact same file(file name/directory), it didn't throw any error
Any idea what could be the problem?
This library work like charm and also well maintained code.. But it would be great if you add Pause , Resume functionality.
agin this is not an issue but I posted here as I don't know where to give suggestion / request.
Thanks for this good library .
As the title says i can start a recording but when i try to reproduce it, that seems to be a broken file, i've tried in every third party player and it is broken. i thought that was a permission problem but it doesn't seems to be that.
can you look for it?
i dont know how to extend an mp3 type ,and there is is bug while recording over 8 hours ,it just only can record 2hours totaly ,but the audio file size is increase approximate 5.5Gb
Are there any chances to implement conversion from raw audio to m4a?
Please write duration calculation code
Hi Kailash,
You did a fantastic job! Cheers for that. I am fan of your coding man.
Let me explain you what others are getting issue like mine.
In some devices like Moto G, Samsung on5 alomost that i have , i am able to play the WAV file that it creates after record.
but there are also many devices like LENOVO, MI note 3 which are not playing WAV file after recording finished.
I am using MediaPlayer API in order to play file.
If i am not wrong then it seems problem is in write header part. WAV header is not appropriate writing for those devices to understand.
Do have a look at the link below :
This recorder demo works for all devices like LENOVO , MI etc.
Althrough VLC player and MX player both are able to play WAV file recorded by OM recorder in LEVENO , MI .
Hope this will help you to understand the issue with it.
I am using this library in my project but many users contact me every day saying that own devices cannot record the voice. Why ? Are there android devices that can't record WAV format ?
One of these is for example Asus zenfone 2
Hello,I want to get audio waveform from recording sound,and I found that the method onAudioChunkPulled() can return AudioChunk, can I draw a wave with audiochunk.toShorts()?
recorder = OmRecorder.wav( new PullTransport.Default(mic(), new PullTransport.OnAudioChunkPulledListener() { @Override public void onAudioChunkPulled(AudioChunk audioChunk) { animateVoice((float) (audioChunk.maxAmplitude() / 200.0)); } }), file());
What should be in animateVoice() method? i don't see any implementation of it!
When i record to 3 times , My app froze but it's not crashed. It is working great in android 5. Please check and fixed it.
Hi,
I am trying to rename the file after it is recorded by Omrecorder , suppose Omrecorder recorder file was "temp-file.mp3" after recording I want it to be meaningful so i change it to "new-recording-code-001.mp3".
To rename I wrote this piece of code:
public static boolean renameFile(String fromFilePathWithExt,String toFilePathWithExt){
LogUtils.d("from: "+fromFilePathWithExt);
LogUtils.d("to: "+toFilePathWithExt);
File dir = Environment.getExternalStorageDirectory();
if(dir.exists()){
File from = new File(fromFilePathWithExt);
File to = new File(toFilePathWithExt);
if(from.exists()) {
return from.renameTo(to);
}
}
return false;
}
This function is working and it renames the file and returns true , but after changing the filename, FILE GETS CORRUPTED AND DOES NOT PLAY.
Am I doing something wrong? or this is library bug.
I recently got this log in one of our apps and wanted to reach out. It was a Motorola 6 that it's from.
Fatal Exception: java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
at android.media.AudioRecord.startRecording(AudioRecord.java:894)
at omrecorder.PullTransport$AbstractPullTransport.preparedSourceToBePulled(PullTransport.java:89)
at omrecorder.PullTransport$AbstractPullTransport.start(PullTransport.java:70)
at omrecorder.AbstractRecorder$1.run(AbstractRecorder.java:29)
at java.lang.Thread.run(Thread.java:818)
Still receiving this error, even after confirming users have Recording permissions enabled on their device. Seeing issues on 4.4.2 - 7.1 and wanted to reopen this.
Fatal Exception: java.lang.IllegalStateException: startRecording() called on an uninitialized AudioRecord.
at android.media.AudioRecord.startRecording(AudioRecord.java:894)
at omrecorder.PullTransport$AbstractPullTransport.preparedSourceToBePulled(PullTransport.java:89)
at omrecorder.PullTransport$AbstractPullTransport.start(PullTransport.java:70)
at omrecorder.AbstractRecorder$1.run(AbstractRecorder.java:29)
at java.lang.Thread.run(Thread.java:818)
Hi,
I am using this library and when I am recording second time and stopping, I am getting below error. Please suggest.
Thank You.
Error is
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
**Code to start and stop **
`View.OnTouchListener touchListener = new View.OnTouchListener() {
@OverRide
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
if (permissionToRecordAccepted && permissionToReadExternalStorage && permissionToWriteExternalStorage) {
//startPulseAnimation();
timerTextView.setVisibility(View.VISIBLE);
countDownTimer.start();
recorder.startRecording();
}
} else if (event.getAction() == MotionEvent.ACTION_UP) {
timerTextView.setVisibility(View.INVISIBLE);
countDownTimer.cancel();
try {
recorder.stopRecording(); // Here I am getting error.
if (!TextUtils.isEmpty(mVerificationId)) {
mPresenter.configureVoice(mVerificationId, Utility.getDeviceId(), file().getPath(), audioBytes);
}
} catch (IOException e) {
e.printStackTrace();
}
}
return true;
}
}`
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.