comparison data/model/WritableWaveFileModel.h @ 0:fc9323a41f5a

start base : Sonic Visualiser sv1-1.0rc1
author lbajardsilogic
date Fri, 11 May 2007 09:08:14 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:fc9323a41f5a
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 QMUL.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #ifndef _WRITABLE_WAVE_FILE_MODEL_H_
17 #define _WRITABLE_WAVE_FILE_MODEL_H_
18
19 #include "WaveFileModel.h"
20
21 class WavFileWriter;
22 class WavFileReader;
23
24 class WritableWaveFileModel : public RangeSummarisableTimeValueModel
25 {
26 Q_OBJECT
27
28 public:
29 WritableWaveFileModel(size_t sampleRate, size_t channels, QString path = "");
30 ~WritableWaveFileModel();
31
32 /**
33 * Call addSamples to append a block of samples to the end of the
34 * file. Caller should also call setCompletion to update the
35 * progress of this file, if it has a known end point, and should
36 * call setCompletion(100) when the file has been written.
37 */
38 virtual bool addSamples(float **samples, size_t count);
39
40 bool isOK() const;
41 bool isReady(int *) const;
42
43 virtual void setCompletion(int completion); // percentage
44 virtual int getCompletion() const { return m_completion; }
45
46 const ZoomConstraint *getZoomConstraint() const {
47 static PowerOfSqrtTwoZoomConstraint zc;
48 return &zc;
49 }
50
51 size_t getFrameCount() const;
52 size_t getChannelCount() const { return m_channels; }
53 size_t getSampleRate() const { return m_sampleRate; }
54
55 virtual Model *clone() const;
56
57 float getValueMinimum() const { return -1.0f; }
58 float getValueMaximum() const { return 1.0f; }
59
60 virtual size_t getStartFrame() const { return 0; }
61 virtual size_t getEndFrame() const { return getFrameCount(); }
62
63 virtual size_t getValues(int channel, size_t start, size_t end,
64 float *buffer) const;
65
66 virtual size_t getValues(int channel, size_t start, size_t end,
67 double *buffer) const;
68
69 virtual void getRanges(size_t channel, size_t start, size_t end,
70 RangeBlock &ranges, size_t &blockSize) const;
71
72 virtual Range getRange(size_t channel, size_t start, size_t end) const;
73
74 virtual void toXml(QTextStream &out,
75 QString indent = "",
76 QString extraAttributes = "") const;
77
78 virtual QString toXmlString(QString indent = "",
79 QString extraAttributes = "") const;
80
81 protected:
82 WaveFileModel *m_model;
83 WavFileWriter *m_writer;
84 WavFileReader *m_reader;
85 size_t m_sampleRate;
86 size_t m_channels;
87 size_t m_frameCount;
88 int m_completion;
89 };
90
91 #endif
92