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@202
|
7 This file copyright 2006 QMUL.
|
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@179
|
24 class WritableWaveFileModel : public RangeSummarisableTimeValueModel
|
Chris@175
|
25 {
|
Chris@175
|
26 Q_OBJECT
|
Chris@175
|
27
|
Chris@175
|
28 public:
|
Chris@175
|
29 WritableWaveFileModel(size_t sampleRate, size_t channels, QString path = "");
|
Chris@175
|
30 ~WritableWaveFileModel();
|
Chris@175
|
31
|
Chris@188
|
32 /**
|
Chris@188
|
33 * Call addSamples to append a block of samples to the end of the
|
Chris@188
|
34 * file. Caller should also call setCompletion to update the
|
Chris@188
|
35 * progress of this file, if it has a known end point, and should
|
Chris@188
|
36 * call setCompletion(100) when the file has been written.
|
Chris@188
|
37 */
|
Chris@175
|
38 virtual bool addSamples(float **samples, size_t count);
|
Chris@175
|
39
|
Chris@175
|
40 bool isOK() const;
|
Chris@175
|
41 bool isReady(int *) const;
|
Chris@175
|
42
|
Chris@188
|
43 virtual void setCompletion(int completion); // percentage
|
Chris@188
|
44 virtual int getCompletion() const { return m_completion; }
|
Chris@188
|
45
|
Chris@179
|
46 const ZoomConstraint *getZoomConstraint() const {
|
Chris@179
|
47 static PowerOfSqrtTwoZoomConstraint zc;
|
Chris@179
|
48 return &zc;
|
Chris@179
|
49 }
|
Chris@179
|
50
|
Chris@175
|
51 size_t getFrameCount() const;
|
Chris@175
|
52 size_t getChannelCount() const { return m_channels; }
|
Chris@175
|
53 size_t getSampleRate() const { return m_sampleRate; }
|
Chris@175
|
54
|
Chris@175
|
55 virtual Model *clone() const;
|
Chris@175
|
56
|
Chris@175
|
57 float getValueMinimum() const { return -1.0f; }
|
Chris@175
|
58 float getValueMaximum() const { return 1.0f; }
|
Chris@175
|
59
|
Chris@300
|
60 virtual size_t getStartFrame() const { return m_startFrame; }
|
Chris@300
|
61 virtual size_t getEndFrame() const { return m_startFrame + getFrameCount(); }
|
Chris@175
|
62
|
Chris@300
|
63 void setStartFrame(size_t startFrame);
|
Chris@175
|
64
|
Chris@300
|
65 virtual size_t getData(int channel, size_t start, size_t count,
|
Chris@300
|
66 float *buffer) const;
|
Chris@175
|
67
|
Chris@300
|
68 virtual size_t getData(int channel, size_t start, size_t count,
|
Chris@300
|
69 double *buffer) const;
|
Chris@175
|
70
|
Chris@300
|
71 virtual void getSummaries(size_t channel, size_t start, size_t count,
|
Chris@300
|
72 RangeBlock &ranges, size_t &blockSize) const;
|
Chris@300
|
73
|
Chris@300
|
74 virtual Range getSummary(size_t channel, size_t start, size_t count) const;
|
Chris@175
|
75
|
Chris@345
|
76 QString getTypeName() const { return tr("Writable Wave File"); }
|
Chris@345
|
77
|
Chris@175
|
78 virtual void toXml(QTextStream &out,
|
Chris@175
|
79 QString indent = "",
|
Chris@175
|
80 QString extraAttributes = "") const;
|
Chris@175
|
81
|
Chris@175
|
82 protected:
|
Chris@175
|
83 WaveFileModel *m_model;
|
Chris@175
|
84 WavFileWriter *m_writer;
|
Chris@175
|
85 WavFileReader *m_reader;
|
Chris@175
|
86 size_t m_sampleRate;
|
Chris@175
|
87 size_t m_channels;
|
Chris@175
|
88 size_t m_frameCount;
|
Chris@300
|
89 size_t m_startFrame;
|
Chris@188
|
90 int m_completion;
|
Chris@175
|
91 };
|
Chris@175
|
92
|
Chris@175
|
93 #endif
|
Chris@175
|
94
|