如何阅读3GP / AMR-NB音频格式的原始值? [英] How to read raw values of 3gp / AMR-NB audio format?

查看:252
本文介绍了如何阅读3GP / AMR-NB音频格式的原始值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,我记录用户的声音,我保存为一个名为.3gp EN codeD音频文件。

In my Android application I am recording the user's voice which I save as a .3gp encoded audio file.

我想要做的就是打开它,即序列x [n]的重presenting音频采样,以执行一些音频信号分析。

What I want to do is open it up, i.e. the sequence x[n] representing the audio sample, in order to perform some audio signal analysis.

有谁知道我怎么能去这样做?

Does anyone know how I could go about doing this?

推荐答案

您可以采用Android的 Meidia codeC 类脱code 3GP或其他文件。去codeR输出的是标准的PCM字节数组。您可以直接发送该输出到​​Android AudioTrack类播放或继续使用该输出字节数组进行进一步的处理,如DSP。要应用的DSP算法的字节数组必须转换成浮点/双阵列。有几个步骤来获得字节数组输出。总之,它看起来像如下:

You can use Android MeidiaCodec class to decode 3gp or other files. The decoder output is standard PCM byte array. You can directly send this output to the Android AudioTrack class to play or continue with this output byte array for further processing such as DSP. To apply DSP algorithm the byte array must be transform into float/double array. There are several steps to get the byte array output. In summary it looks like as follows:

  1. 实例化媒体codeC

  1. Instantiate MediaCodec

String mMime = "audio/3gpp"
MediaCodec  mMediaCodec = MediaCodec.createDecoderByType(mMime);

  • 创建Media格式,并配置媒体codeC

  • Create Media format and configure media codec

    MediaFormat mMediaFormat = new MediaFormat();
    mMediaFormat = MediaFormat.createAudioFormat(mMime,
        mMediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE),
        mMediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT));
    
    mMediaCodec.configure(mMediaFormat, null, null, 0);
    mMediaCodec.start();
    

  • 从媒体codeC输出捕捉(如果一个线程中处理)

  • Capture output from MediaCodec ( Should process inside a thread)

    MediaCodec.BufferInfo buf_info = new MediaCodec.BufferInfo();
    int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(buf_info, 0);
    byte[] pcm = new byte[buf_info.size];
    mOutputBuffers[outputBufferIndex].get(pcm, 0, buf_info.size);
    

  • 谷歌IO谈这里可能是相关的。

    这篇关于如何阅读3GP / AMR-NB音频格式的原始值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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