4 #include <QtMultimedia/QAudioBuffer>
5 #include <QtMultimedia/QAudioFormat>
25 format.setSampleSize(16);
26 format.setSampleRate(44100);
27 format.setChannelCount(2);
28 format.setCodec(
"audio/pcm");
29 format.setByteOrder(QAudioFormat::LittleEndian);
30 format.setSampleType(QAudioFormat::SignedInt);
33 QAudioBuffer::S16S * getAudioSamples(QString filename)
37 inputFile.setFileName(filename);
38 inputFile.open(QIODevice::ReadOnly);
39 header = inputFile.read(44) ;
41 wavBuffer = inputFile.readAll();
47 qab =
new QAudioBuffer(wavBuffer, format);
49 return qab->data<QAudioBuffer::S16S>();
52 void writeNewAudioFile(QString filename)
57 outputFile.setFileName(filename);
58 outputFile.open(QIODevice::WriteOnly);
59 outBuffer.setRawData((
char *) qab->data(), qab->byteCount() );
61 outputFile.write(header);
62 outputFile.write(outBuffer);
68 return qab->frameCount();
Definition: wavesound.h:12