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


C++ QAudioFormat::setChannels方法代码示例

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


在下文中一共展示了QAudioFormat::setChannels方法的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;
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:26,代码来源:s60audioencodercontrol.cpp

示例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;
    }
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:30,代码来源:s60audioencodercontrol.cpp

示例3: 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);
}
开发者ID:berndhs,项目名称:qxmpp,代码行数:31,代码来源:xmppClient.cpp

示例4: 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;
}
开发者ID:maxxant,项目名称:qt,代码行数:46,代码来源:qaudiodeviceinfo_symbian_p.cpp

示例5: 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;
}
开发者ID:dtbinh,项目名称:dviz,代码行数:19,代码来源:qaudiodeviceinfo_win32_p.cpp

示例6: 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);
 }
开发者ID:cadencii,项目名称:cadencii-nt,代码行数:11,代码来源:DeviceAudioOutput.hpp

示例7: 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)));
}
开发者ID:hardaker,项目名称:Agenda,代码行数:54,代码来源:MainWindow.cpp

示例8: 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;
}
开发者ID:corecode,项目名称:CuteCW,代码行数:15,代码来源:MainWindow.cpp

示例9: 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);
    }
}
开发者ID:ChengLunHu,项目名称:manyears,代码行数:46,代码来源:StreamOutputWidget.cpp

示例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());
}
开发者ID:bavanisp,项目名称:qtmobility-1.1.0,代码行数:17,代码来源:s60audioencodercontrol.cpp

示例11: 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;
}
开发者ID:wsygzyr,项目名称:YYClient,代码行数:17,代码来源:AudioHelper.cpp

示例12: 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;
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:19,代码来源:qaudio_mac.cpp

示例13: 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;
    }
}
开发者ID:dimanzinov,项目名称:EmiPSX,代码行数:19,代码来源:emuinterface.cpp

示例14: 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();
}
开发者ID:korbatit,项目名称:qtwolf3d,代码行数:39,代码来源:wlaudio.cpp

示例15: info

/*!
  Constructor.
*/
AudioOut::AudioOut(AudioSource *source, QObject *parent /* = 0 */)
    : QThread(parent),
      m_audioOutput(0),
      m_outTarget(0),
      m_source(source),
      m_sendBuffer(0),
      m_sendBufferSize(0),
      m_samplesMixed(0),
      m_threadState(NotRunning),
      m_usingThread(false)
{
    QAudioFormat format;
    format.setFrequency(AUDIO_FREQUENCY);
    format.setChannels(GEDefaultChannelCount);
    format.setSampleSize(AUDIO_SAMPLE_BITS);
    format.setCodec(GEDefaultAudioCodec);
    format.setByteOrder(GEByteOrder);
    format.setSampleType(GESampleType);

    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());

    if (!info.isFormatSupported(format))
        format = info.nearestFormat(format);

    m_audioOutput = new QAudioOutput(info, format);
    m_audioOutput->setBufferSize(4096 * 8);
    m_sendBufferSize = 4096 * 8;
    m_outTarget = m_audioOutput->start();

    DEBUG_INFO("Buffer size: " << m_audioOutput->bufferSize());
    m_sendBuffer = new AUDIO_SAMPLE_TYPE[m_sendBufferSize];

#ifndef Q_OS_SYMBIAN
    m_usingThread = true;
    start();
#endif

}
开发者ID:ltomuta,项目名称:quickhit,代码行数:41,代码来源:GEAudioOut.cpp


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