当前位置: 首页>>代码示例>>C++>>正文


C++ QAudioDeviceInfo::supportedSampleSizes方法代码示例

本文整理汇总了C++中QAudioDeviceInfo::supportedSampleSizes方法的典型用法代码示例。如果您正苦于以下问题:C++ QAudioDeviceInfo::supportedSampleSizes方法的具体用法?C++ QAudioDeviceInfo::supportedSampleSizes怎么用?C++ QAudioDeviceInfo::supportedSampleSizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QAudioDeviceInfo的用法示例。


在下文中一共展示了QAudioDeviceInfo::supportedSampleSizes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: QObject

FrequencyAnalyzer::FrequencyAnalyzer(QObject *parent) :
    QObject(parent),
    d_ptr(new FrequencyAnalyzerPrivate(this))
{
    Q_D(FrequencyAnalyzer);

    QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();

    qDebug() << "device name: " << info.deviceName() << "\n"
             << "supported frequency:" << info.supportedFrequencies() << "\n"
             << "supported codecs" << info.supportedCodecs() << "\n"
             << "supported sample sizes" << info.supportedSampleSizes() << "\n"
             << "supported sample types" << info.supportedSampleTypes() << "\n";

    QAudioFormat format = info.preferredFormat();
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::SignedInt);
    format.setSampleSize(32);
    //format.setFrequency(d->sampling = 11025);
    //format.setFrequency(d->sampling = 22050);
    format.setFrequency(d->sampling = info.supportedFrequencies().last());
    format.setChannelCount(1);

    if (!info.isFormatSupported(format)) {
        qWarning("Format is unsupported");
        return;
    }

    d->input = new QAudioInput(info, format, this);
    connect(d->input, SIGNAL(stateChanged(QAudio::State)), SLOT(_q_onStateChanged()));
}
开发者ID:alekseysidorov,项目名称:MeeTuner,代码行数:32,代码来源:frequencyanalyzer.cpp

示例2: isDeviceGood

bool CSoundCommonQT::isDeviceGood(const QAudioDeviceInfo &di, const int *desiredsamplerates) const
{
    bool bSampleRateOk = false;
    for (const int* dsr=desiredsamplerates; *dsr; dsr++)
    {
        int samplerate = abs(*dsr);
        if (isSampleRateSupported(di, samplerate))
        {
            bSampleRateOk = true;
            break;
        }
    }
    return
        bSampleRateOk &&
        di.supportedChannelCounts().contains(2) && // TODO
        di.supportedSampleSizes().contains(16) &&
        di.supportedSampleTypes().contains(QAudioFormat::SignedInt) &&
        di.supportedByteOrders().contains(QAudioFormat::LittleEndian) &&
        di.supportedCodecs().contains("audio/pcm");
}
开发者ID:castrouk,项目名称:LinDrm,代码行数:20,代码来源:qtaudio.cpp


注:本文中的QAudioDeviceInfo::supportedSampleSizes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。