Android的AudioRecord和MediaRecorder [英] Android AudioRecord and MediaRecorder

查看:380
本文介绍了Android的AudioRecord和MediaRecorder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发展,我需要录制音频,然后再对其进行处理,以获得该记录功能的音频处理应用。不过,我想播放格式音频与之后的MediaPlayer播放它。

I'm developing an audio processing application where I need to record audio, and then process it to obtain features of that recording. However, I want the audio in a playable format to play it after with MediaPlayer.

我见过的录制音频处理它,最好使用AudioRecord,因为我可以从那里得到的原始音频。但我不能将数据写入一个文件播放格式(有没有图书馆为此在机器人?)。

I've seen that to record audio to process it it's better to use AudioRecord, because I can get the raw audio from there. But then I can't write the data to a file in a playable format (is there any library to do this in android?).

我用这个方法来记录原始数据,然后将其写入一个文件:
http://andrewbrobinson.com/2011/11/ 27 /捕获-原始音频数据在安卓/
但是,当我尝试在设备上播放这个文件,它是不能播放。

I used this method to record raw data and then write it into a file: http://andrewbrobinson.com/2011/11/27/capturing-raw-audio-data-in-android/ But when i try to play this file on the device, it is not playable.

然后,如果我用MediaRecorder我不知道如何反code中的数据提取功能。我一直在寻找MediaExtractor,但接缝的MediaExtractor不脱code中的帧。

Then if I use MediaRecorder I don't know how to decode the data to extract the features. I've been looking at MediaExtractor, but it seams that MediaExtractor doesn't decode the frames.

所以..什么是做到这一点的最好方法是什么?我想这是任何音频处理应用普遍,但我没能找到管理问题的办法。

So.. what's the best way to do this? I imagine that's common in any audio processing application, but I wasn't able to find the way to manage this.

感谢您的答复。

推荐答案

使用 AudioRecord 是,如果你需要做任何处理,以正确的方式去。要播放它回来,你有几个选择。如果你只是要被打回的的您的应用程序的,你可以使用 AudioTrack 而不是的MediaPlayer 来播放原始PCM流。

Using AudioRecord is the right way to go if you need to do any kind of processing. To play it back, you have a couple options. If you're only going to be playing it back in your app, you can use AudioTrack instead of MediaPlayer to play raw PCM streams.

如果您希望它是可玩与其他应用程序,你需要将它转化成别的东西第一。通常WAV是最简单的,因为你只需要添加<一个href=\"http://stackoverflow.com/questions/4777181/creating-a-wav-file-from-raw-pcm-data-using-the-android-sdk\">header.您还可以找到库转换为其他格式,如JOrbis为OGG,或JLayer为MP3等。

If you want it to be playable with other applications, you'll need to convert it to something else first. WAV is normally the simplest, since you just need to add the header. You can also find libraries for converting to other formats, like JOrbis for OGG, or JLayer for MP3, etc.

这篇关于Android的AudioRecord和MediaRecorder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆