本文整理汇总了C++中QAudioFormat::setFrequency方法的典型用法代码示例。如果您正苦于以下问题:C++ QAudioFormat::setFrequency方法的具体用法?C++ QAudioFormat::setFrequency怎么用?C++ QAudioFormat::setFrequency使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAudioFormat
的用法示例。
在下文中一共展示了QAudioFormat::setFrequency方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setQuality
void S60AudioEncoderControl::setAudioSettings(const QAudioEncoderSettings &settings)
{
QAudioFormat fmt = m_session->format();
if (settings.encodingMode() == QtMultimediaKit::ConstantQualityEncoding) {
fmt.setCodec(settings.codec());
setQuality(settings.quality(), fmt);
if (settings.sampleRate() > 0) {
fmt.setFrequency(settings.sampleRate());
}
if (settings.channelCount() > 0)
fmt.setChannels(settings.channelCount());
}else {
if (settings.sampleRate() == 8000) {
fmt.setSampleType(QAudioFormat::UnSignedInt);
fmt.setSampleSize(8);
} else {
fmt.setSampleType(QAudioFormat::SignedInt);
fmt.setSampleSize(16);
}
fmt.setCodec(settings.codec());
fmt.setFrequency(settings.sampleRate());
fmt.setChannels(settings.channelCount());
}
m_session->setFormat(fmt);
m_settings = settings;
}
示例2: switch
void S60AudioEncoderControl::setQuality(QtMultimediaKit::EncodingQuality value, QAudioFormat &fmt)
{
switch (value) {
case QtMultimediaKit::VeryLowQuality:
case QtMultimediaKit::LowQuality:
// low, 8000Hz mono U8
fmt.setSampleType(QAudioFormat::UnSignedInt);
fmt.setSampleSize(8);
fmt.setFrequency(8000);
fmt.setChannels(1);
break;
case QtMultimediaKit::NormalQuality:
// medium, 22050Hz mono S16
fmt.setSampleType(QAudioFormat::SignedInt);
fmt.setSampleSize(16);
fmt.setFrequency(22050);
fmt.setChannels(1);
break;
case QtMultimediaKit::HighQuality:
case QtMultimediaKit::VeryHighQuality:
// high, 44100Hz mono S16
fmt.setSampleType(QAudioFormat::SignedInt);
fmt.setSampleSize(16);
fmt.setFrequency(44100);
fmt.setChannels(2);
break;
default:
break;
}
}
示例3: 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()));
}
示例4: slotConnected
void xmppClient::slotConnected()
{
QXmppCall *call = qobject_cast<QXmppCall*>(sender());
Q_ASSERT(call);
qDebug() << "Call connected";
QXmppRtpChannel *channel = call->audioChannel();
// prepare audio format
QAudioFormat format;
format.setFrequency(channel->payloadType().clockrate());
format.setChannels(channel->payloadType().channels());
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
// the size in bytes of the audio buffers to/from sound devices
// 160 ms seems to be the minimum to work consistently on Linux/Mac/Windows
const int bufferSize = (format.frequency() * format.channels() * (format.sampleSize() / 8) * 160) / 1000;
// initialise audio output
QAudioOutput *audioOutput = new QAudioOutput(format, this);
audioOutput->setBufferSize(bufferSize);
audioOutput->start(channel);
// initialise audio input
QAudioInput *audioInput = new QAudioInput(format, this);
audioInput->setBufferSize(bufferSize);
audioInput->start(channel);
}
示例5: preferredFormat
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
{
QAudioFormat format;
switch (m_mode) {
case QAudio::AudioOutput:
format.setFrequency(44100);
format.setChannels(2);
format.setSampleSize(16);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
format.setCodec(QLatin1String("audio/pcm"));
break;
case QAudio::AudioInput:
format.setFrequency(8000);
format.setChannels(1);
format.setSampleSize(16);
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
format.setCodec(QLatin1String("audio/pcm"));
break;
default:
Q_ASSERT_X(false, Q_FUNC_INFO, "Invalid mode");
}
if (!isFormatSupported(format)) {
format = QAudioFormat();
format.setCodec(QLatin1String("audio/pcm"));
if (m_capabilities.contains(format.codec())) {
const Capabilities &codecCaps = m_capabilities[format.codec()];
if (codecCaps.m_frequencies.size())
format.setFrequency(codecCaps.m_frequencies[0]);
if (codecCaps.m_channels.size())
format.setChannels(codecCaps.m_channels[0]);
if (codecCaps.m_sampleSizes.size())
format.setSampleSize(codecCaps.m_sampleSizes[0]);
if (codecCaps.m_byteOrders.size())
format.setByteOrder(codecCaps.m_byteOrders[0]);
if (codecCaps.m_sampleTypes.size())
format.setSampleType(codecCaps.m_sampleTypes[0]);
}
}
return format;
}
示例6: preferredFormat
QAudioFormat QAudioDeviceInfoInternal::preferredFormat() const
{
QAudioFormat nearest;
if(mode == QAudio::AudioOutput) {
nearest.setFrequency(44100);
nearest.setChannels(2);
nearest.setByteOrder(QAudioFormat::LittleEndian);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(16);
nearest.setCodec(QLatin1String("audio/pcm"));
} else {
nearest.setFrequency(11025);
nearest.setChannels(1);
nearest.setSampleType(QAudioFormat::SignedInt);
nearest.setSampleSize(8);
nearest.setCodec(QLatin1String("audio/pcm"));
}
return nearest;
}
示例7: DeviceAudioOutput
explicit DeviceAudioOutput(int sampleRate) :
AudioOutput(sampleRate) {
format.setChannels(2);
format.setFrequency(sampleRate);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setSampleType(QAudioFormat::SignedInt);
out = new QAudioOutput(format);
device = 0;
memset(buffer, 0, sizeof(char) * kUnitBufferLength);
}
示例8: info
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow), m_timer(), m_totalNeededTime(0,0), m_spentTime(0,0), m_belowAlarmTime(false), m_belowEndTime(false),
m_dbusInterface(0), m_alarmTime(60), m_useLED(true), m_useSounds(true)
{
ui->setupUi(this);
m_topics.push_back(new AgendaTopic("topic #1", QTime(0,5)));
m_topics.push_back(new AgendaTopic("topic #2", QTime(0,15)));
calculateTotalTimes();
m_currentTopic = 1;
mainWindowSetup();
setupMenus();
connect(ui->next, SIGNAL(clicked()), this, SLOT(switchToNextTopic()));
connect(ui->previous, SIGNAL(clicked()), this, SLOT(switchToPreviousTopic()));
connect(ui->start, SIGNAL(clicked()), this, SLOT(startOrStop()));
connect(ui->plus15, SIGNAL(clicked()), this, SLOT(add15m()));
connect(ui->plus5, SIGNAL(clicked()), this, SLOT(add5m()));
connect(ui->plus1, SIGNAL(clicked()), this, SLOT(add1m()));
connect(ui->minus15, SIGNAL(clicked()), this, SLOT(minus15m()));
connect(ui->minus5, SIGNAL(clicked()), this, SLOT(minus5m()));
connect(ui->minus1, SIGNAL(clicked()), this, SLOT(minus1m()));
connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeElapsed()));
#ifdef IS_MAEMO
m_dbusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, QDBusConnection::systemBus(), this);
QDBusMessage reply = m_dbusInterface->call(MCE_ENABLE_LED);
if (reply.type() == QDBusMessage::ErrorMessage)
qDebug() << reply.errorMessage();
#endif
// set up the output audio
QAudioFormat format;
// Set up the format, eg.
format.setFrequency(44100);
format.setChannels(1);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
m_audioOut = new QAudioOutput(format);
// connect(m_audioOut,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State)));
}
示例9: QAudioOutput
QAudioOutput *
MainWindow::createAudioOutput()
{
QAudioFormat settings;
settings.setFrequency(44100);
settings.setChannels(1);
settings.setSampleSize(16);
settings.setCodec("audio/pcm");
settings.setByteOrder(QAudioFormat::LittleEndian);
settings.setSampleType(QAudioFormat::SignedInt);
m_audioOutput = new QAudioOutput(settings);
return m_audioOutput;
}
示例10:
S60AudioEncoderControl::S60AudioEncoderControl(QObject *session, QObject *parent)
:QAudioEncoderControl(parent), m_quality(QtMultimediaKit::NormalQuality)
{
m_session = qobject_cast<S60AudioCaptureSession*>(session);
QAudioFormat fmt = m_session->format();
// medium, 22050Hz mono S16
fmt.setSampleType(QAudioFormat::SignedInt);
if (fmt.codec().compare("PCM", Qt::CaseInsensitive) == 0) {
fmt.setSampleSize(16);
fmt.setFrequency(22050);
}
fmt.setChannels(1);
m_session->setFormat(fmt);
m_settings.setChannelCount(fmt.channels());
m_settings.setCodec(fmt.codec());
m_settings.setSampleRate(fmt.sampleRate());
}
示例11: startButtonClicked
void StreamOutputWidget::startButtonClicked()
{
qDebug("void StreamOutputWidget::startButtonClicked()");
//Get available output devices...
QList<QAudioDeviceInfo> myList = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput);
if (m_audioOutput)
{
delete m_audioOutput;
m_audioOutput = NULL;
}
for (int i =0; i < myList.size(); i++)
{
if (myList[i].deviceName() == m_ui.m_comboDeviceSelection->currentText())
{
//QAudioFormat
QAudioFormat format;
//Set up the format
format.setFrequency(48000);
format.setChannels(1);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
m_audioOutput = new QAudioOutput(myList[i],format,this);
//m_audioOutput = new QAudioOutput(QAudioDeviceInfo::defaultOutputDevice(),format,this);
//We have 10ms frames, this should be enough
m_audioOutput->setNotifyInterval(5);
}
}
if (m_audioOutput)
{
connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)),this,SLOT(audioStateChanged(QAudio::State)));
connect(m_audioOutput,SIGNAL(notify()),this,SLOT(notify()));
m_audioOutput->setBufferSize(1000000);
m_IODevice = m_audioOutput->start();
m_ui.m_controlTextEdit->append("Starting stream... \n");
m_ui.m_startButton->setEnabled(false);
m_ui.m_stopButton->setEnabled(true);
}
}
示例12: AudioInputIsOK
bool AudioHelper::AudioInputIsOK()
{
QAudioFormat format;
format.setFrequency(22050);
format.setChannels(1);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::UnSignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
if (!info.isFormatSupported(format)) {
AudioHelperDebug("no default input device");
return false;
}
return true;
}
示例13: toQAudioFormat
// Conversion
QAudioFormat toQAudioFormat(AudioStreamBasicDescription const& sf)
{
QAudioFormat audioFormat;
audioFormat.setFrequency(sf.mSampleRate);
audioFormat.setChannels(sf.mChannelsPerFrame);
audioFormat.setSampleSize(sf.mBitsPerChannel);
audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
audioFormat.setByteOrder((sf.mFormatFlags & kAudioFormatFlagIsBigEndian) != 0 ? QAudioFormat::BigEndian : QAudioFormat::LittleEndian);
QAudioFormat::SampleType type = QAudioFormat::UnSignedInt;
if ((sf.mFormatFlags & kAudioFormatFlagIsSignedInteger) != 0)
type = QAudioFormat::SignedInt;
else if ((sf.mFormatFlags & kAudioFormatFlagIsFloat) != 0)
type = QAudioFormat::Float;
audioFormat.setSampleType(type);
return audioFormat;
}
示例14: InitAudio
int InitAudio(){
QAudioFormat format;
format.setFrequency(22050);
format.setChannels(1);
format.setSampleSize(16);
format.setCodec("audio/pcm");
format.setByteOrder(QAudioFormat::LittleEndian);
format.setSampleType(QAudioFormat::SignedInt);
QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
emuWindow->audioOut = new QAudioOutput(info, format, emuWindow);
if(emuWindow->audioOut){
emuWindow->setDevice();
return 1;
}else{
return 0;
}
}
示例15: GameSoundServer
WLAudio::WLAudio():
m_adLib(false), m_soundBlaster(false), m_soundPositioned(0),
m_numReadySamples(0), m_curAlSound(0), m_curAlSoundPtr(0), m_curAlLengthLeft(0),
m_soundTimeCounter(5), m_originalSampleRate(7042), m_sqMaxTracks(10),
m_alChar(0x20), m_alScale(0x40), m_alAttack(0x60), m_alSus(0x80), m_alWave(0xe0),
m_alFreqL(0xa0), m_alFreqH(0xb0), m_alFeedCon(0xc0), m_alEffects(0xbd),
m_nextSoundPos(false)
{
QAudioFormat format;
#if QT_VERSION >= 0x050000
format.setSampleRate(param_samplerate);
format.setChannelCount(2);
#else
format.setFrequency(param_samplerate);
format.setChannels(2);
#endif
format.setByteOrder(QAudioFormat::LittleEndian);
format.setCodec("audio/pcm");
format.setSampleSize(16);
format.setSampleType(QAudioFormat::SignedInt);
m_soundServer = new GameSoundServer(format);
m_samplesPerMusicTick = param_samplerate / 700;
if(YM3812Init(1,3579545,param_samplerate)) {
printf("Unable to create virtual OPL!!\n");
}
for(int i = 1;i < 0xf6;i++)
YM3812Write(0,i,0);
YM3812Write(0, 1, 0x20); // Set WSE=1
m_adLib = true;
m_soundBlaster = true;
m_alTimeCount = 0;
setSoundMode(sdm_Off);
setMusicMode(smm_Off);
setupDigi();
}