本文整理汇总了C++中QAudioDeviceInfo::supportedCodecs方法的典型用法代码示例。如果您正苦于以下问题:C++ QAudioDeviceInfo::supportedCodecs方法的具体用法?C++ QAudioDeviceInfo::supportedCodecs怎么用?C++ QAudioDeviceInfo::supportedCodecs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAudioDeviceInfo
的用法示例。
在下文中一共展示了QAudioDeviceInfo::supportedCodecs方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recordVoice
void MyEngine::recordVoice() {
qDebug() << "Called recordVoice" ;
QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
foreach (const QString &str, info.supportedCodecs ())
qDebug() << "Supported codecs: "<< str;
foreach (const QAudioDeviceInfo &audioDeviceInfo, QAudioDeviceInfo::availableDevices ( QAudio::AudioInput ))
qDebug() << "Devices: " << audioDeviceInfo.deviceName();
outputFile.setFileName("test.raw");
outputFile.open( QIODevice::WriteOnly | QIODevice::Truncate )?qDebug() << "file created":qDebug() << "file creation error";
//qDebug() << "Sample rate: " << format.sampleRate();
//QAudioDeviceInfo info = QAudioDeviceInfo::defaultInputDevice();
if (!info.isFormatSupported(format)) {
qWarning()<<"default format not supported try to use nearest";
format = info.nearestFormat(format);
}
audio = new QAudioInput(format, this);
connect(audio, SIGNAL(stateChanged(QAudio::State)),
this, SLOT(stateChanged(QAudio::State)));
QTimer::singleShot(2000, this, SLOT(stopRecording())); // Records audio for 2 sec
audio->start(&outputFile);
}
示例2: 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()));
}
示例3: 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");
}