PDA

View Full Version : buffered sound (wav) distorted at end



Wim De Backer
21st July 2011, 10:41
Hi,

Some wav files are distorted the last second when I play the file from a QByteArray. The sound plays nice when I use the file as MediaSource, but not when I first put the data in a QByteArray and pass it to the player using a QBuffer.
I can see no obvious difference (length, filesize, bitrate, …) between files that play normal and files that act weird.

Example:
Original file http://dl.dropbox.com/u/6552350/buy_one_free.wav
This is how the distorted file sounds: http://dl.dropbox.com/u/6552350/distorted.wav

(I’m working in Windows7)

This ‘feels like’ a bug, but maybe it’s just me.



QFile myFile(sndFile);
QByteArray a;
myFile.open(QIODevice::ReadOnly);
a = myFile.readAll();

myFile.close();
QBuffer *buf = new QBuffer(this);
buf->close();
buf->setData(a);

music = Phonon::createPlayer(Phonon::MusicCategory,buf); // sound distorted

//if (!sndFile.isEmpty()) {
//Phonon::MediaSource source(sndFile);}
// music = Phonon::createPlayer(Phonon::MusicCategory,source) ; // plays nice
music->play();


Thanks for your help!

Wim