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. AVFoundation Support for wav files
QtWS25 Last Chance

AVFoundation Support for wav files

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 2 Posters 470 Views
  • 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 Offline
    M Offline
    mgreenish
    wrote on last edited by mgreenish
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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
      0
      • M Offline
        M Offline
        mgreenish
        wrote on last edited by
        #3

        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
        0
        • M Offline
          M Offline
          mgreenish
          wrote on last edited by
          #4

          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
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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
            0

            • Login

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