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. (Solved)Push and Pull ?QAudioOutput
Forum Updated to NodeBB v4.3 + New Features

(Solved)Push and Pull ?QAudioOutput

Scheduled Pinned Locked Moved General and Desktop
9 Posts 2 Posters 3.8k 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.
  • V Offline
    V Offline
    vpwal
    wrote on last edited by
    #1

    I did not understand what is pull and push ..
    May be some examples could let me understand.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Not in pull mode. In pull mode, it's the device that gets the data at the rate it needs.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vpwal
        wrote on last edited by
        #3

        if i have .wav data in chunks say 512 and more (till the file is finished).i want to play this chunk then which mode would be better for this.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          It's not really clear, do you want to play the complete file or just a chunk of it ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vpwal
            wrote on last edited by
            #5

            Hi..
            Actually i am converting my mp3 file to wav file using 3rd API for conversion.
            That conversion gives me a chunk (in wav) so that i can play it simultaneously in Qt(using QAudioOutput).
            Read File mp3----->Convert it into wav--->play it (QAudioOutput)
            again read next chunks mp3 ---->convert it ---->play it
            until the file finished.

            For More Clear what my intention is. i am providing you a link.
            in play URL section, i want to use Qt Player instead of libao(3rd Party)
            "please find here":http://hzqtc.github.io/2012/05/play-mp3-with-libmpg123-and-libao.html

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Then use the push mode

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vpwal
                wrote on last edited by
                #7

                Hi..

                if i use push mode then how i have to wait till the data is not played.then i have to read and write the next chunks.

                1 Reply Last reply
                0
                • V Offline
                  V Offline
                  vpwal
                  wrote on last edited by
                  #8

                  Hi.
                  @void CAudio::PlayAudio()
                  {

                  m_format.setSampleRate(22050); //44100 //48000 //22050 //11025
                  m_format.setChannelCount(2); // one for mono or two for stereo
                  m_format.setSampleSize(16); //8 or 16
                  m_format.setCodec("audio/pcm");
                  m_format.setByteOrder(QAudioFormat::LittleEndian); //Byte ordering of sample (typically little endian, big endian)
                  m_format.setSampleType(QAudioFormat::SignedInt); //Numerical representation of sample (typically signed integer, unsigned integer or float)

                   QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
                   if (!info.isFormatSupported(m_format)) 
                  

                  {
                  qWarning() << "Default format not supported - trying to use nearest";
                  m_format = info.nearestFormat(m_format);
                  }
                  QAudioDeviceInfo m_device(QAudioDeviceInfo::defaultOutputDevice());
                  //pvcRW_Obj = new CReadWrite;

                  m_audioOutput = new QAudioOutput(m_device, m_format, this);
                  connect(m_audioOutput, SIGNAL(notify()), SLOT(notified()));
                  connect(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), SLOT(stateChanged(QAudio::State)));

                  mfile.setFileName("d:/out_Converted1.wav");
                  mfile.open(QIODevice::ReadOnly);
                  pIO_Device = m_audioOutput->start();
                  pIO_Device->open(QIODevice::ReadWrite);

                  qint64 size = mfile.size();
                  qint64 tot =0;
                  while(tot < size)
                  {
                  QByteArray ba = mfile.read(512);
                  qint64 bytesWritten = pIO_Device->write(ba,ba.size());
                  tot+=bytesWritten;

                  }

                  }@
                  The above is my code it always produces sound with lot of distortion.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Since you have a wav file, why don't use pull mode ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    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