SilentEye 0.4.1

sef/audio.h

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye. If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #ifndef AUDIO_H_
00017 #define AUDIO_H_
00018 
00019 #include "media.h"
00020 
00021 #include <QString>
00022 #include <QtMultimedia/QAudioFormat>
00023 
00024 namespace SilentEyeFramework {
00025 
00027     class Audio : public Media
00028     {
00029     protected:
00031         QAudioFormat m_format;
00032 
00033         // Chunk description
00035         quint32 m_totalSize;
00036         // Sub chunk format
00038         quint32 m_subFmtSize;
00040         quint16 m_audioFormat;
00042         quint16 m_numChannels;
00044         quint32 m_sampleRate;
00046         quint32 m_byteRate;
00048         quint16 m_blockAlign;
00050         quint16 m_bitPerSample;
00051         // Sub chunk data
00053         quint32 m_subDataSize;
00055         QAudioFormat::Endian m_byteOrder;
00056 
00058         double m_duration;
00060         quint32 m_bitRate;
00061 
00062     private:
00063         QFile m_file;
00064         QDataStream m_sampleStream;
00065 
00066     public:
00067         Audio(const QString& filepath);
00068         Audio(const Audio&);
00069         Audio(Audio*);
00070         ~Audio();
00071 
00072         virtual double duration();
00073         virtual quint32 bitRate();
00074         virtual QAudioFormat format() const;
00075 
00077         static int headerLength() { return 44; }
00078 
00079     protected:
00081         bool openSamples();
00083         bool hasNextSample();
00085         QList<quint32> readSample();
00087         void skipSample(qint32);
00089         bool closeSamples();
00091         qint32 sampleSize() const;
00092 
00094         void readWaveHeader();
00096         void writeWaveHeader(QDataStream&);
00097     };
00098 
00099 }
00100 
00101 #endif