svcore  1.9
WritableWaveFileModel.h
Go to the documentation of this file.
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 
25 {
26  Q_OBJECT
27 
28 public:
29  WritableWaveFileModel(int sampleRate, int channels, QString path = "");
31 
38  virtual bool addSamples(float **samples, int 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 
48  return &zc;
49  }
50 
51  int getFrameCount() const;
52  int getChannelCount() const { return m_channels; }
53  int 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 int getStartFrame() const { return m_startFrame; }
61  virtual int getEndFrame() const { return m_startFrame + getFrameCount(); }
62 
63  void setStartFrame(int startFrame);
64 
65  virtual int getData(int channel, int start, int count,
66  float *buffer) const;
67 
68  virtual int getData(int channel, int start, int count,
69  double *buffer) const;
70 
71  virtual int getData(int fromchannel, int tochannel,
72  int start, int count,
73  float **buffer) const;
74 
75  virtual int getSummaryBlockSize(int desired) const;
76 
77  virtual void getSummaries(int channel, int start, int count,
78  RangeBlock &ranges, int &blockSize) const;
79 
80  virtual Range getSummary(int channel, int start, int count) const;
81 
82  QString getTypeName() const { return tr("Writable Wave File"); }
83 
84  virtual void toXml(QTextStream &out,
85  QString indent = "",
86  QString extraAttributes = "") const;
87 
88 protected:
97 };
98 
99 #endif
100 
QString getTypeName() const
Return the type of the model.
virtual void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const
Stream this exportable object out to XML on a text stream.
float getValueMinimum() const
Return the minimum possible value found in this model type.
float getValueMaximum() const
Return the minimum possible value found in this model type.
virtual Model * clone() const
Return a copy of this model.
Reader for audio files using libsndfile.
Definition: WavFileReader.h:36
virtual void getSummaries(int channel, int start, int count, RangeBlock &ranges, int &blockSize) const
Return ranges from the given start frame, corresponding to the given number of underlying sample fram...
bool isOK() const
Return true if the model was constructed successfully.
virtual void setCompletion(int completion)
const ZoomConstraint * getZoomConstraint() const
If this model imposes a zoom constraint, i.e.
virtual int getCompletion() const
bool isReady(int *) const
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
virtual int getStartFrame() const
Return the first audio frame spanned by the model.
void setStartFrame(int startFrame)
WritableWaveFileModel(int sampleRate, int channels, QString path="")
Model is the base class for all data models that represent any sort of data on a time scale based on ...
Definition: Model.h:35
virtual Range getSummary(int channel, int start, int count) const
Return the range from the given start frame, corresponding to the given number of underlying sample f...
virtual int getSummaryBlockSize(int desired) const
int getSampleRate() const
Return the frame rate in frames per second.
int getChannelCount() const
Return the number of distinct channels for this model.
Base class for models containing dense two-dimensional data (value against time) that may be meaningf...
ZoomConstraint is a simple interface that describes a limitation on the available zoom sizes for a vi...
virtual int getData(int channel, int start, int count, float *buffer) const
Get the specified set of samples from the given channel of the model in single-precision floating-poi...
virtual int getEndFrame() const
Return the last audio frame spanned by the model.
virtual bool addSamples(float **samples, int count)
Call addSamples to append a block of samples to the end of the file.