Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QAudioOutput in Qt5 is not producing any sound
Qt 6.11 is out! See what's new in the release blog

QAudioOutput in Qt5 is not producing any sound

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fredaime
    wrote on last edited by
    #1

    Hi all,

    I'm working under kubuntu 12.10 and developping an application into which i need to generate some sound into a QIODevice, then play it with QAudioOutput.

    I've read all the litterature around speaking of how to properly do that, and I think to have done so.

    So far I've done :

    @
    QVector <double> * soundData = SoundGenerator::getSound();

    soundBuffer->open(QIODevice::ReadWrite);
    QDataStream writeStream(soundBuffer);
    foreach(double d, *soundData) {
        char value = d * (2 << 7);
        //  qDebug() << "Value : " << (short int)value;
        writeStream << value;
    }
    
    QAudioFormat format;
    // Set up the format, eg.
    format.setSampleRate(SoundGenerator::getAudioSampleRate());
    format.setChannelCount(1);
    format.setSampleSize(8);
    format.setCodec("audio/pcm");
    format.setByteOrder(QAudioFormat::LittleEndian);
    format.setSampleType(QAudioFormat::SignedInt);
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
    
    audio = new QAudioOutput(format, this);
    if (audio->error() != QAudio::NoError) {
        qDebug() << "Problem playing sound";
    }
    
    connect(audio, SIGNAL(stateChanged(QAudio::State)), this, SLOT(aboutToFinish(QAudio::State)));
    

    @

    I have also a call to
    @
    audio->start(soundBuffer)
    @

    from another slot

    I do not have any error in the initialization of the QAudioOutput

    And I have NO SOUND AT ALL (all other applications have sound, and I'm porting a Qt4 app to Qt5, in Qt4 everything is ok with Phonon)

    The aboutToFinish slot is called at the beggining with ActiveState as state, and NoError when calling QAudioOutput::error, but it's not called anymore, even if waiting far more than the expected generated sound duration.

    The sound generation process is not to be put in question, it has been tested by writing wav files, and it works.

    Moreover, I have built the multimedia example from Qt's sources, when it comes to pure audio there is no output (for example in the sprectrum example), on another hand, video plays with the sound perfectly.

    Is there any known issue concerning that ? Is that a bug ? Am I doing something wrong ?

    Thanks in advance ;)

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fredaime
      wrote on last edited by
      #2

      I've recompiled Qt by forcing pulseaudio support to false and Alsa to true
      by doing so, I'm able to have the spectrum demo works

      I still have issues concerning my code, but apparently it's related to the way I generate data to feed the QIODevice which I provides to QAudioOutput

      It seems that there is some issues with Qt5 and pulseaudio right now (with the prebuilt release)

      On my configuration it seems that the prebuilt Qt is not able to play sound under Ubuntu 12.10 out of the box (KDE/Qt4, pulseaudio and Qt5 caveheats ?)

      I've opened an issue in jira : https://bugreports.qt-project.org/browse/QTBUG-30345?focusedCommentId=198994#comment-198994

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved