WritableWaveFileModel.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2006 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _WRITABLE_WAVE_FILE_MODEL_H_
00017 #define _WRITABLE_WAVE_FILE_MODEL_H_
00018 
00019 #include "WaveFileModel.h"
00020 
00021 class WavFileWriter;
00022 class WavFileReader;
00023 
00024 class WritableWaveFileModel : public RangeSummarisableTimeValueModel
00025 {
00026     Q_OBJECT
00027 
00028 public:
00029     WritableWaveFileModel(size_t sampleRate, size_t channels, QString path = "");
00030     ~WritableWaveFileModel();
00031 
00038     virtual bool addSamples(float **samples, size_t count);
00039     
00040     bool isOK() const;
00041     bool isReady(int *) const;
00042 
00043     virtual void setCompletion(int completion); // percentage
00044     virtual int getCompletion() const { return m_completion; }
00045 
00046     const ZoomConstraint *getZoomConstraint() const {
00047         static PowerOfSqrtTwoZoomConstraint zc;
00048         return &zc;
00049     }
00050 
00051     size_t getFrameCount() const;
00052     size_t getChannelCount() const { return m_channels; }
00053     size_t getSampleRate() const { return m_sampleRate; }
00054 
00055     virtual Model *clone() const;
00056 
00057     float getValueMinimum() const { return -1.0f; }
00058     float getValueMaximum() const { return  1.0f; }
00059 
00060     virtual size_t getStartFrame() const { return m_startFrame; }
00061     virtual size_t getEndFrame() const { return m_startFrame + getFrameCount(); }
00062 
00063     void setStartFrame(size_t startFrame);
00064 
00065     virtual size_t getData(int channel, size_t start, size_t count,
00066                            float *buffer) const;
00067 
00068     virtual size_t getData(int channel, size_t start, size_t count,
00069                            double *buffer) const;
00070 
00071     virtual size_t getData(size_t fromchannel, size_t tochannel,
00072                            size_t start, size_t count,
00073                            float **buffer) const;
00074 
00075     virtual size_t getSummaryBlockSize(size_t desired) const;
00076 
00077     virtual void getSummaries(size_t channel, size_t start, size_t count,
00078                               RangeBlock &ranges, size_t &blockSize) const;
00079 
00080     virtual Range getSummary(size_t channel, size_t start, size_t count) const;
00081 
00082     QString getTypeName() const { return tr("Writable Wave File"); }
00083 
00084     virtual void toXml(QTextStream &out,
00085                        QString indent = "",
00086                        QString extraAttributes = "") const;
00087 
00088 protected:
00089     WaveFileModel *m_model;
00090     WavFileWriter *m_writer;
00091     WavFileReader *m_reader;
00092     size_t m_sampleRate;
00093     size_t m_channels;
00094     size_t m_frameCount;
00095     size_t m_startFrame;
00096     int m_completion;
00097 };
00098 
00099 #endif
00100 

Generated on Wed Feb 20 15:45:30 2008 for SonicVisualiser by  doxygen 1.5.1