annotate data/model/WritableWaveFileModel.h @ 1124:efea94b04d5a 3.0-integration

Merge from branch recording
author Chris Cannam
date Thu, 20 Aug 2015 13:15:19 +0100
parents 4d9816ba0ebe b9faee02afa5
children e994747fb9dd
rev   line source
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@1122 16 #ifndef WRITABLE_WAVE_FILE_MODEL_H
Chris@1122 17 #define WRITABLE_WAVE_FILE_MODEL_H
Chris@175 18
Chris@175 19 #include "WaveFileModel.h"
Chris@1122 20 #include "ReadOnlyWaveFileModel.h"
Chris@1122 21 #include "PowerOfSqrtTwoZoomConstraint.h"
Chris@175 22
Chris@175 23 class WavFileWriter;
Chris@175 24 class WavFileReader;
Chris@175 25
Chris@1122 26 class WritableWaveFileModel : public WaveFileModel
Chris@175 27 {
Chris@175 28 Q_OBJECT
Chris@175 29
Chris@175 30 public:
Chris@1040 31 WritableWaveFileModel(sv_samplerate_t sampleRate, int channels, QString path = "");
Chris@175 32 ~WritableWaveFileModel();
Chris@175 33
Chris@188 34 /**
Chris@188 35 * Call addSamples to append a block of samples to the end of the
Chris@188 36 * file. Caller should also call setCompletion to update the
Chris@188 37 * progress of this file, if it has a known end point, and should
Chris@188 38 * call setCompletion(100) when the file has been written.
Chris@188 39 */
Chris@1038 40 virtual bool addSamples(float **samples, sv_frame_t count);
Chris@175 41
Chris@175 42 bool isOK() const;
Chris@175 43 bool isReady(int *) const;
Chris@175 44
Chris@188 45 virtual void setCompletion(int completion); // percentage
Chris@188 46 virtual int getCompletion() const { return m_completion; }
Chris@188 47
Chris@179 48 const ZoomConstraint *getZoomConstraint() const {
Chris@179 49 static PowerOfSqrtTwoZoomConstraint zc;
Chris@179 50 return &zc;
Chris@179 51 }
Chris@179 52
Chris@1038 53 sv_frame_t getFrameCount() const;
Chris@929 54 int getChannelCount() const { return m_channels; }
Chris@1040 55 sv_samplerate_t getSampleRate() const { return m_sampleRate; }
Chris@1122 56 sv_samplerate_t getNativeRate() const { return m_sampleRate; }
Chris@1122 57
Chris@1122 58 QString getTitle() const {
Chris@1122 59 if (m_model) return m_model->getTitle();
Chris@1122 60 else return "";
Chris@1122 61 }
Chris@1122 62 QString getMaker() const {
Chris@1122 63 if (m_model) return m_model->getMaker();
Chris@1122 64 else return "";
Chris@1122 65 }
Chris@1122 66 QString getLocation() const {
Chris@1122 67 if (m_model) return m_model->getLocation();
Chris@1122 68 else return "";
Chris@1122 69 }
Chris@175 70
Chris@175 71 float getValueMinimum() const { return -1.0f; }
Chris@175 72 float getValueMaximum() const { return 1.0f; }
Chris@175 73
Chris@1038 74 virtual sv_frame_t getStartFrame() const { return m_startFrame; }
Chris@1038 75 virtual sv_frame_t getEndFrame() const { return m_startFrame + getFrameCount(); }
Chris@175 76
Chris@1038 77 void setStartFrame(sv_frame_t startFrame);
Chris@175 78
Chris@1096 79 virtual std::vector<float> getData(int channel, sv_frame_t start, sv_frame_t count) const;
Chris@175 80
Chris@1096 81 virtual std::vector<std::vector<float>> getMultiChannelData(int fromchannel, int tochannel, sv_frame_t start, sv_frame_t count) const;
Chris@363 82
Chris@929 83 virtual int getSummaryBlockSize(int desired) const;
Chris@377 84
Chris@1038 85 virtual void getSummaries(int channel, sv_frame_t start, sv_frame_t count,
Chris@929 86 RangeBlock &ranges, int &blockSize) const;
Chris@300 87
Chris@1038 88 virtual Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const;
Chris@175 89
Chris@345 90 QString getTypeName() const { return tr("Writable Wave File"); }
Chris@345 91
Chris@175 92 virtual void toXml(QTextStream &out,
Chris@175 93 QString indent = "",
Chris@175 94 QString extraAttributes = "") const;
Chris@175 95
Chris@175 96 protected:
Chris@1122 97 ReadOnlyWaveFileModel *m_model;
Chris@175 98 WavFileWriter *m_writer;
Chris@175 99 WavFileReader *m_reader;
Chris@1040 100 sv_samplerate_t m_sampleRate;
Chris@929 101 int m_channels;
Chris@1038 102 sv_frame_t m_frameCount;
Chris@1038 103 sv_frame_t m_startFrame;
Chris@188 104 int m_completion;
Chris@175 105 };
Chris@175 106
Chris@175 107 #endif
Chris@175 108