Android AudioRecord 支持的采样率 [英] Android AudioRecord Supported Sampling Rates

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

问题描述

我想弄清楚运行 Android 2.2 及更高版本的手机支持的采样率.我们希望以低于 44.1kHz 的速率进行采样,而不必重新采样.
我知道所有手机都支持 44100Hz,但想知道是否有表格显示特定手机的有效采样率.我看过 Android 的文档(http://developer.android.com/reference/android/media/AudioRecord.html) 但它没有多大帮助.
有没有人找到这些采样率的列表?

I'm trying to figure out what sampling rates are supported for phones running Android 2.2 and greater. We'd like to sample at a rate lower than 44.1kHz and not have to resample.
I know that all phones support 44100Hz but was wondering if there's a table out there that shows what sampling rates are valid for specific phones. I've seen Android's documentation ( http://developer.android.com/reference/android/media/AudioRecord.html) but it doesn't help much.
Has anyone found a list of these sampling rates??

推荐答案

最初的海报可能已经很久没有更新了,但我会发布这个以防其他人发现这个问题.

The original poster has probably long since moved on, but I'll post this in case anyone else finds this question.

不幸的是,根据我的经验,每个设备都可以支持不同的采样率.了解设备支持的采样率的唯一可靠方法是通过检查 AudioRecord.getMinBufferSize() 的结果是否为非负值(这意味着存在错误)来单独测试它们,并返回有效的最小缓冲区大小.

Unfortunately, in my experience, each device can support different sample rates. The only sure way of knowing what sample rates a device supports is to test them individually by checking the result of AudioRecord.getMinBufferSize() is non negative (which means there was an error), and returns a valid minimum buffer size.

public void getValidSampleRates() {
    for (int rate : new int[] {8000, 11025, 16000, 22050, 44100}) {  // add the rates you wish to check against
        int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_CONFIGURATION_DEFAULT, AudioFormat.ENCODING_PCM_16BIT);
        if (bufferSize > 0) {
            // buffer size is valid, Sample rate supported

        }
    }
}

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

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