00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
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);
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