[Interest] Only buzzing sound while playing wav file through QAudioOutput

Viktor Engelmann viktor.engelmann at qt.io
Mon Aug 15 15:34:29 CEST 2016


I'm not an expert on audio formats & hardware, but I guess sending raw
data directly to an output device without a decoder in between is
probably not a good idea.

Have you tried the examples from http://doc.qt.io/qt-5/audiooverview.html ?

Viktor


On 12.08.2016 14:00, Anisha Kaul wrote:
> Much thankful for your polite response. 
>
> My problem is that I first tried this program with an mp3 file. It
> didn't work, then I tried the wav file.
> Which file format should directly work with it? Is there there
> something hardware specific that I need to figure out to make this work?
>
> I am on windows desktop.
>
> On Friday, 12 August 2016, Maurice Kalinowski
> <Maurice.Kalinowski at qt.io <mailto:Maurice.Kalinowski at qt.io>> wrote:
>
>     Hi,
>
>      
>
>     Please note that a wav file is a _/container/_ format, meaning it
>     starts with a header describing the audio format and then
>     continues with chunks of data. For more details have a look here:
>     https://de.wikipedia.org/wiki/RIFF_WAVE
>     <https://de.wikipedia.org/wiki/RIFF_WAVE>
>
>      
>
>     This means that you will need to parse the header and provide the
>     data, not just a file as QIODevice which is meant to be a data
>     stream after you have set up the format correctly.
>
>      
>
>     Maurice
>
>      
>
>      
>
>     *From:*Interest [mailto:interest-bounces+maurice.kalinowski
>     <javascript:_e(%7B%7D,'cvml','interest-bounces%2Bmaurice.kalinowski');>=qt.io at qt-project.org
>     <javascript:_e(%7B%7D,'cvml','qt.io at qt-project.org');>] *On Behalf
>     Of *Anisha Kaul
>     *Sent:* Friday, August 12, 2016 12:31 PM
>     *To:* interest at qt-project.org
>     <javascript:_e(%7B%7D,'cvml','interest at qt-project.org');>
>     *Subject:* [Interest] Only buzzing sound while playing wav file
>     through QAudioOutput
>
>      
>
>     Hi,
>
>      
>
>     This time I tried playing a wav file, but I cannot hear anything
>     else than a buzzing sound.
>
>     Platform is windows if that matters.
>
>      
>
>     This time the code is in main.cpp. 
>
>      
>
>     Please guide.
>
>     ***********************************************************************************************
>
>     #include<QCoreApplication>
>
>     #include<QAudioOutput>
>
>     #include<QFile>
>
>     #include<QDebug>
>
>      
>
>     intmain(intargc,char*argv[])
>
>     {
>
>         QCoreApplicationa(argc,argv);
>
>      
>
>         QAudioOutput*audioOutpu;
>
>      
>
>         QFilesourceFile;
>
>         sourceFile.setFileName("c.wav");
>
>         boolp=sourceFile./open/(QIODevice::ReadOnly);
>
>         if(p==false)
>
>             qDebug()<<"nofile";
>
>         else
>
>             qDebug()<<"yesfile";
>
>      
>
>      
>
>         QAudioDeviceInfod1;
>
>        
>     QList<QAudioDeviceInfo>l1=d1.availableDevices(QAudio::AudioOutput);
>
>      
>
>        
>     qDebug()<<"======================================================";
>
>         qDebug()<<l1.first().supportedCodecs();
>
>         qDebug()<<l1.first().supportedChannelCounts();
>
>         qDebug()<<l1.first().supportedSampleTypes();
>
>         qDebug()<<l1.first().supportedSampleRates();
>
>         qDebug()<<l1.first().supportedSampleSizes();
>
>      
>
>         QAudioFormatdesiredFormat1;
>
>         desiredFormat1.setChannelCount(2);
>
>         desiredFormat1.setByteOrder(QAudioFormat::LittleEndian);
>
>         desiredFormat1.setCodec("audio/pcm");
>
>         desiredFormat1.setSampleType(QAudioFormat::SignedInt);
>
>         desiredFormat1.setSampleRate(44100);
>
>         desiredFormat1.setSampleSize(16);
>
>      
>
>         QAudioDeviceInfoinfo1(QAudioDeviceInfo::defaultOutputDevice());
>
>         if(!info1.isFormatSupported(desiredFormat1))
>
>         {
>
>               
>     qWarning()<<"Defaultformatnotsupported,tryingtousethenearest.";
>
>                desiredFormat1=info1.preferredFormat();
>
>         }
>
>      
>
>         audioOutpu=newQAudioOutput(desiredFormat1);
>
>         audioOutpu->setVolume(1.0);
>
>      
>
>         audioOutpu->start(&sourceFile);
>
>         qDebug()<<"bbbbbbbbbb";
>
>      
>
>         returna.exec();
>
>     }
>
>      
>
>     **************************************************************************************************
>
>     Output:
>
>      
>
>     ("audio/pcm")
>
>     (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18)
>
>     (SignedInt, UnSignedInt, Float)
>
>     (8000, 11025, 16000, 22050, 32000, 44100, 48000, 88200, 96000, 192000)
>
>     (8, 16, 24, 32, 48, 64)
>
>     bbbbbbbbbb
>
>      
>
>      
>
> -- Anisha Kaul
>
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
-- 
Viktor Engelmann Software Engineer The Qt Company GmbH Rudower Chaussee
13 D-12489 Berlin Viktor.Engelmann at qt.io +49 151 26784521 http://qt.io
Geschäftsführer: Mika Pälsi, Juha Varelius, Mika Harjuaho Sitz der
Gesellschaft: Berlin, Registergericht: Amtsgericht Charlottenburg, HRB
144331 B
<http://qt.io>
<http://www.facebook.com/Qt> 	<http://www.twitter.com/qtproject>
<https://www.linkedin.com/company/the-qt-company/>
<https://plus.google.com/104580575722059274792>
<https://www.youtube.com/QtStudios>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_logo_with_text_green_rgb_400x141.png
Type: image/png
Size: 16849 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_facebook.png
Type: image/png
Size: 1407 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment-0001.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_twitter.png
Type: image/png
Size: 1778 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_linkedin.png
Type: image/png
Size: 1532 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment-0003.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_googleplus.png
Type: image/png
Size: 1957 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment-0004.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qt_youtube.png
Type: image/png
Size: 1610 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment-0005.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: viktor_engelmann.vcf
Type: text/x-vcard
Size: 271 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160815/3448bbe5/attachment.vcf>


More information about the Interest mailing list