本文整理汇总了C++中QAudioDeviceInfo::supportedSampleTypes方法的典型用法代码示例。如果您正苦于以下问题:C++ QAudioDeviceInfo::supportedSampleTypes方法的具体用法?C++ QAudioDeviceInfo::supportedSampleTypes怎么用?C++ QAudioDeviceInfo::supportedSampleTypes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAudioDeviceInfo
的用法示例。
在下文中一共展示了QAudioDeviceInfo::supportedSampleTypes方法的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()));
}
示例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");
}