Mp3 Decoder using QAudioDecoder
-
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]
-
Please use "code wrappings":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 They make your code readable :-)
-
I have a "similar problem":https://qt-project.org/forums/viewthread/26237/ for writing my audio engine, does anyone knows how to solve it?
-
[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.