audiorecord

Android AudioRecord vs. MediaRecorder for recording audio

时光总嘲笑我的痴心妄想 提交于 2021-02-17 07:32:16
问题 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

Android录制和播放AudioRecord和AudioTrack

大兔子大兔子 提交于 2021-02-13 11:04:24
package com.esa.audio; import android.media.AudioFormat; import android.media.AudioManager; import android.media.AudioRecord; import android.media.AudioTrack; import android.media.MediaRecorder; public class Audio { public static final int AUDIO_SOURCE = MediaRecorder.AudioSource.MIC; public static final int STREAM_TYPE = AudioManager.STREAM_MUSIC; public static final int SAMPLE_RATE_IN_HZ = 8000;// 44100 public static final int CHANNEL_CONFIG = AudioFormat.CHANNEL_CONFIGURATION_MONO;// AudioTrack和AudioRecord都能用 public static final int RECORD_CHANNEL_CONFIG = AudioFormat.CHANNEL_IN_MONO;

Android Studio: While Loop Freezing Application

只谈情不闲聊 提交于 2021-01-29 08:13:47
问题 My code on an app in Android Studio, consisting of a start/stop button for recording audio using AudioRecord and then outputting that audio data to a text view, works great when done once. If I repeatedly click the button, it works too. However, if I put it in a while loop, the app freezes (only the app freezes; same result on an emulator and a real smartphone). I believe I've found that it doesn't have anything to do with AudioRecord, or putting the loop in the button listener or putting it

AudioRecord while also playing audio - accessing output playback data

放肆的年华 提交于 2021-01-29 08:08:23
问题 I'm messing around in my app with a custom model for speech commands - I have it working fine recording and processing input audio from an AudioRecord, and I give feedback to the user through text to speech. One issue I have is that I'd like this to work even when audio is playing - either through my own text to speech or through something else playing in the background (music for instance). I realize this is going to be a non trivial problem, but if I could get access in some way to the

Android AudioRecord Headphones with MIC

混江龙づ霸主 提交于 2020-03-03 09:09:32
问题 I am having some issues with the AudioRecord class. I have an app that records audio while someone is listening to audio through headphones. In this scenario, it works fine. Users are able to record without an issue. Any user using headphones with a built-in mic are not able to record at all. My class creates the .wav file from PCM data but no audio is being input from the mic. Its all silence. I use the following the init my AudioRecorder: extAudioRecorder = new ExtAudioRecorder(true,

Android AudioRecord Headphones with MIC

大城市里の小女人 提交于 2020-03-03 09:09:24
问题 I am having some issues with the AudioRecord class. I have an app that records audio while someone is listening to audio through headphones. In this scenario, it works fine. Users are able to record without an issue. Any user using headphones with a built-in mic are not able to record at all. My class creates the .wav file from PCM data but no audio is being input from the mic. Its all silence. I use the following the init my AudioRecorder: extAudioRecorder = new ExtAudioRecorder(true,

AudioRecord: buffer overflow?

て烟熏妆下的殇ゞ 提交于 2020-01-30 19:14:49
问题 I'm getting buffer overflow while RECORDING with my app. The recording is performed in a Service . I could not figure out why I'm getting this message from AudioFlinger . Below I instantiate the AudioRecord object and set it's callbacks. bufferSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat); aRecorder = new AudioRecord(audioSource, sampleRate, channelConfig, audioFormat, bufferSize); aRecorder.setRecordPositionUpdateListener(updateListener); bytesPerSample =

Recording sound in android

老子叫甜甜 提交于 2020-01-25 09:45:12
问题 I'd like to know how to record sound for a specific amount of time, without saving it to a file - holding in a byte stream for example. Also, if possible, make it look like an AMR file. I've tried to search google, and also wrote some code myself, but had no success. If you can link me to a page that explains how to do so, or give an example, it would be very nice of you :) Thanks. 回答1: MediaRecorder recorder = new MediaRecorder(); recorder.setAudioSource(MediaRecorder.AudioSource.MIC);

Android AudioRecord failing when calling the startRecording() method

血红的双手。 提交于 2020-01-25 05:25:12
问题 I'm trying to record audio in android and store it in an array of bytes, and for that I use Android's AudioRecord built-in class. I've already used this class before, and all was good, but for some reason, it seems the AudioRecord won't work anymore. The problem is that the AudioRecord gets initialized and shows no errors, but when it's time to actually record something, by calling its' startRecording() method, something is failing and I don't even get a proper reason why. This is ALL the

Immediate Audio Input & Output Android

╄→尐↘猪︶ㄣ 提交于 2020-01-12 12:53:45
问题 In my Android App, I would like to take in some audio from the mic of the smartphone and play it immediately, live, like a microphone, with no lag. I am currently thinking of using AudioRecord and AudioTrack classes (from what I have read), but I'm not quite sure how to proceed. I checked out some other questions on Stack Overflow but they don't exactly answer what I would like to do. And most are from 2012. So how can I use these classes to input and output audio simultaneously? ALSO: I had