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. Mp3 Decoder using QAudioDecoder
Forum Updated to NodeBB v4.3 + New Features

Mp3 Decoder using QAudioDecoder

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 7.9k 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.
  • M Offline
    M Offline
    Matt141
    wrote on last edited by
    #1

    Hello,

    I would like to get the raw data (pcm) from an mp3 file by using QAudioDecoder. According an example I found it's possible to do so with QAudioDecoder. Please tell if not.

    I implemented this example, but get an error "defaultServiceProvider:requestService<> : no service found for - org.qt-project.qt.audiocode" when I do "decoder = new QAudioDecoder();".
    Someone has an idea why?

    My code is :
    @
    Decoder::Decoder():QObject()
    {
    QAudioFormat desiredFormat;
    desiredFormat.setChannelCount(2);
    desiredFormat.setCodec("audio/x-raw");
    desiredFormat.setSampleType(QAudioFormat::UnSignedInt);
    desiredFormat.setSampleRate(48000);
    desiredFormat.setSampleSize(16);

    decoder = new QAudioDecoder();
    decoder->setAudioFormat(desiredFormat);
    decoder->setSourceFilename("sample.mp3");
    
    connect(decoder, SIGNAL(bufferReady()), this, SLOT(readBuffer()));
    decoder->start();
    
    printf("Erreur : %d",decoder->error());
    

    }

    void Decoder::readBuffer()
    {
    buffer=decoder->read();
    }
    @

    [edit, code tags added]

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Please use "code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 They make your code readable :-)

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        Zylann
        wrote on last edited by
        #3

        I have a "similar problem":https://qt-project.org/forums/viewthread/26237/ for writing my audio engine, does anyone knows how to solve it?

        1 Reply Last reply
        0
        • M Offline
          M Offline
          Matt141
          wrote on last edited by
          #4

          You can't used Qt to decode mp3, well ,I mean I didn't succeeded. Use instead mpeg123 (decode only mp3) or FFmpeg (decode many format). I did and it works.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            chenmo20074639
            wrote on last edited by
            #5

            [quote author="Matt141" date="1365522623"]You can't used Qt to decode mp3, well ,I mean I didn't succeeded. Use instead mpeg123 (decode only mp3) or FFmpeg (decode many format). I did and it works.[/quote]

            I'm a fresh to this forum, so not familiar with it.
            And this problem have another replay???
            Now, I have met the problem too. I'm trying to solve it too.

            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