Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved AVFoundation Support for wav files

    General and Desktop
    2
    5
    217
    Loading More Posts
    • 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.
    • M
      mgreenish last edited by mgreenish

      I need add the ability to open an audio file within my application, decode it and send the media content to an embedded controller for it to play. I have implemented the feature with QAudioDecode as follows:

      in class declaration:

      public slots:
         void readAudioFile( QString filename );    // called when file is selected inside the file dialog
      

      Function implementation

      void AudioFileForm::readAudioFile( QString file_ref )  {
      
              // Decode file
          QAudioDecoder* decoder = new QAudioDecoder();
      
          // Connect decoder error handler
          connect( decoder, QOverload<QAudioDecoder::Error>::of(&QAudioDecoder::error), [=]( QAudioDecoder::Error error ) {
              QString error_text;
              switch( error ) {
              case QAudioDecoder::FormatError:
                  error_text = "Format error";
              case QAudioDecoder::ServiceMissingError:
                  error_text = "Service missing";
                  break;
              default:
                  error_text = "Unknown error";
                  break;
              }
              qDebug() << "Audio decoder error: " + error_text;
          } );
      
          // Connect file decoding done
          connect( decoder, &QAudioDecoder::bufferReady, [=]() {
              QAudioBuffer audio_buffer = decoder->read();
              emit audioLoaded( audio_buffer );
          });
      
          decoder->setSourceFilename( QFileInfo( file_ref ).fileName() );
          decoder->start();       // reads in the file and decodes, throws ready signal when 
                                                 // done which is handled by the lambda functions
      }
      

      I am falling into the error hander with the following:

      defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.audiodecode"
      2020-09-29 10:13:47.432663+0200 VibeCreator[24919:1325702] errors encountered while discovering extensions: Error Domain=PlugInKit 
          Code=13 "query cancelled" UserInfo={NSLocalizedDescription=query cancelled}
      

      I am developing on OS X. Looking at https://wiki.qt.io/Qt_5.13_Multimedia_Backends, it is hard to know of QAudioDecoder is supported by the AVFoundation. I also don't know if I have this plugin installed, although I would assume it is installed by default.

      How do I check if AVFoundation is installed on my Mac and if it includes support for QAudioDecode ?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        AVFoundation is part of the core librarie of macOS there's no need to install them.

        Based on the matrxi you gave, the audio decoding is currently not supported.

        Out of curiosity, what exactly do you need to send to your device ?

        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 Reply Quote 0
        • M
          mgreenish last edited by

          Ok, thanks for confirming what I feared. I'll have to try another approach.

          I basically have to send the decoded audio file / "song" which I understand is just a series of pwm values.

          1 Reply Last reply Reply Quote 0
          • M
            mgreenish last edited by

            Any suggestions on the easiest / best way to decode and extract the audio stream from a wav or MP3 file while developing on Mac for OS X & Win 10 ?

            1 Reply Last reply Reply Quote 0
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              On Windows, you can use Qt Multimedia, on macOS Core Audio is the official backend.

              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 Reply Quote 0
              • First post
                Last post