(Solved)Push and Pull ?QAudioOutput



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


  • Lifetime Qt Champion

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



  • 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.


  • Lifetime Qt Champion

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



  • 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


  • Lifetime Qt Champion

    Then use the push mode



  • 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.



  • 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.


  • Lifetime Qt Champion

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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.