Chris@175
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@175
|
2
|
Chris@175
|
3 /*
|
Chris@175
|
4 Sonic Visualiser
|
Chris@175
|
5 An audio file viewer and annotation editor.
|
Chris@175
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@175
|
7 This file copyright 2006 Chris Cannam.
|
Chris@175
|
8
|
Chris@175
|
9 This program is free software; you can redistribute it and/or
|
Chris@175
|
10 modify it under the terms of the GNU General Public License as
|
Chris@175
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@175
|
12 License, or (at your option) any later version. See the file
|
Chris@175
|
13 COPYING included with this distribution for more information.
|
Chris@175
|
14 */
|
Chris@175
|
15
|
Chris@175
|
16 #ifndef _WRITABLE_WAVE_FILE_MODEL_H_
|
Chris@175
|
17 #define _WRITABLE_WAVE_FILE_MODEL_H_
|
Chris@175
|
18
|
Chris@175
|
19 #include "WaveFileModel.h"
|
Chris@175
|
20
|
Chris@175
|
21 class WavFileWriter;
|
Chris@175
|
22 class WavFileReader;
|
Chris@175
|
23
|
Chris@175
|
24 class WritableWaveFileModel : public RangeSummarisableTimeValueModel,
|
Chris@175
|
25 virtual public PowerOfSqrtTwoZoomConstraint
|
Chris@175
|
26 {
|
Chris@175
|
27 Q_OBJECT
|
Chris@175
|
28
|
Chris@175
|
29 public:
|
Chris@175
|
30 WritableWaveFileModel(size_t sampleRate, size_t channels, QString path = "");
|
Chris@175
|
31 ~WritableWaveFileModel();
|
Chris@175
|
32
|
Chris@175
|
33 virtual bool addSamples(float **samples, size_t count);
|
Chris@175
|
34 virtual void sync();
|
Chris@175
|
35
|
Chris@175
|
36 bool isOK() const;
|
Chris@175
|
37 bool isReady(int *) const;
|
Chris@175
|
38
|
Chris@175
|
39 size_t getFrameCount() const;
|
Chris@175
|
40 size_t getChannelCount() const { return m_channels; }
|
Chris@175
|
41 size_t getSampleRate() const { return m_sampleRate; }
|
Chris@175
|
42
|
Chris@175
|
43 virtual Model *clone() const;
|
Chris@175
|
44
|
Chris@175
|
45 float getValueMinimum() const { return -1.0f; }
|
Chris@175
|
46 float getValueMaximum() const { return 1.0f; }
|
Chris@175
|
47
|
Chris@175
|
48 virtual size_t getStartFrame() const { return 0; }
|
Chris@175
|
49 virtual size_t getEndFrame() const { return getFrameCount(); }
|
Chris@175
|
50
|
Chris@175
|
51 virtual size_t getValues(int channel, size_t start, size_t end,
|
Chris@175
|
52 float *buffer) const;
|
Chris@175
|
53
|
Chris@175
|
54 virtual size_t getValues(int channel, size_t start, size_t end,
|
Chris@175
|
55 double *buffer) const;
|
Chris@175
|
56
|
Chris@175
|
57 virtual RangeBlock getRanges(size_t channel, size_t start, size_t end,
|
Chris@175
|
58 size_t &blockSize) const;
|
Chris@175
|
59
|
Chris@175
|
60 virtual Range getRange(size_t channel, size_t start, size_t end) const;
|
Chris@175
|
61
|
Chris@175
|
62 virtual void toXml(QTextStream &out,
|
Chris@175
|
63 QString indent = "",
|
Chris@175
|
64 QString extraAttributes = "") const;
|
Chris@175
|
65
|
Chris@175
|
66 virtual QString toXmlString(QString indent = "",
|
Chris@175
|
67 QString extraAttributes = "") const;
|
Chris@175
|
68
|
Chris@175
|
69 protected:
|
Chris@175
|
70 WaveFileModel *m_model;
|
Chris@175
|
71 WavFileWriter *m_writer;
|
Chris@175
|
72 WavFileReader *m_reader;
|
Chris@175
|
73 size_t m_sampleRate;
|
Chris@175
|
74 size_t m_channels;
|
Chris@175
|
75 size_t m_frameCount;
|
Chris@175
|
76 };
|
Chris@175
|
77
|
Chris@175
|
78 #endif
|
Chris@175
|
79
|