AggregateWaveModel.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 2007 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 SV_AGGREGATE_WAVE_MODEL_H
17 #define SV_AGGREGATE_WAVE_MODEL_H
18 
21 
22 #include <vector>
23 
25 {
26  Q_OBJECT
27 
28 public:
30  {
31  ModelChannelSpec(ModelId m, int c) : model(m), channel(c) { }
33  int channel;
34  };
35 
36  typedef std::vector<ModelChannelSpec> ChannelSpecList;
37 
38  AggregateWaveModel(ChannelSpecList channelSpecs);
40 
41  bool isOK() const override;
42  bool isReady(int *) const override;
43  int getCompletion() const override {
44  int c = 0;
45  (void)isReady(&c);
46  return c;
47  }
48 
49  QString getTypeName() const override { return tr("Aggregate Wave"); }
50 
51  int getComponentCount() const;
52  ModelChannelSpec getComponent(int c) const;
53 
54  const ZoomConstraint *getZoomConstraint() const override { return &m_zoomConstraint; }
55 
56  sv_frame_t getFrameCount() const;
57  int getChannelCount() const override;
58  sv_samplerate_t getSampleRate() const override;
59 
60  float getValueMinimum() const override { return -1.0f; }
61  float getValueMaximum() const override { return 1.0f; }
62 
63  sv_frame_t getStartFrame() const override { return 0; }
64  sv_frame_t getTrueEndFrame() const override { return getFrameCount(); }
65 
66  floatvec_t getData(int channel, sv_frame_t start, sv_frame_t count) const override;
67 
68  std::vector<floatvec_t> getMultiChannelData(int fromchannel, int tochannel, sv_frame_t start, sv_frame_t count) const override;
69 
70  int getSummaryBlockSize(int desired) const override;
71 
72  void getSummaries(int channel, sv_frame_t start, sv_frame_t count,
73  RangeBlock &ranges,
74  int &blockSize) const override;
75 
76  Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const override;
77 
78  void toXml(QTextStream &out,
79  QString indent = "",
80  QString extraAttributes = "") const override;
81 
82 protected slots:
86 
87 protected:
88  ChannelSpecList m_components;
90 };
91 
92 #endif
93 
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
void componentModelChanged(ModelId)
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
float getValueMinimum() const override
Return the minimum possible value found in this model type.
static PowerOfSqrtTwoZoomConstraint m_zoomConstraint
ModelChannelSpec getComponent(int c) const
int getChannelCount() const override
Return the number of distinct channels for this model.
floatvec_t getData(int channel, sv_frame_t start, sv_frame_t count) const override
Get the specified set of samples from the given channel of the model in single-precision floating-poi...
sv_frame_t getFrameCount() const
AggregateWaveModel(ChannelSpecList channelSpecs)
sv_frame_t getTrueEndFrame() const override
Return the audio frame at the end of the model.
ChannelSpecList m_components
std::vector< float, breakfastquay::StlAllocator< float > > floatvec_t
Definition: BaseTypes.h:53
sv_samplerate_t getSampleRate() const override
Return the frame rate in frames per second.
float getValueMaximum() const override
Return the minimum possible value found in this model type.
QString getTypeName() const override
Return the type of the model.
Range getSummary(int channel, sv_frame_t start, sv_frame_t count) const override
Return the range from the given start frame, corresponding to the given number of underlying sample f...
int getSummaryBlockSize(int desired) const override
void componentModelChangedWithin(ModelId, sv_frame_t, sv_frame_t)
sv_frame_t getStartFrame() const override
Return the first audio frame spanned by the model.
std::vector< ModelChannelSpec > ChannelSpecList
bool isReady(int *) const override
Return true if the model has finished loading or calculating all its data, for a model that is capabl...
Base class for models containing dense two-dimensional data (value against time) that may be meaningf...
void toXml(QTextStream &out, QString indent="", QString extraAttributes="") const override
Stream this exportable object out to XML on a text stream.
ZoomConstraint is a simple interface that describes a limitation on the available zoom sizes for a vi...
const ZoomConstraint * getZoomConstraint() const override
If this model imposes a zoom constraint, i.e.
void componentModelCompletionChanged(ModelId)
int getCompletion() const override
Return an estimated percentage value showing how far through any background operation used to calcula...
bool isOK() const override
Return true if the model was constructed successfully.
int getComponentCount() const
Definition: ById.h:115
void getSummaries(int channel, sv_frame_t start, sv_frame_t count, RangeBlock &ranges, int &blockSize) const override
Return ranges from the given start frame, corresponding to the given number of underlying sample fram...
std::vector< floatvec_t > getMultiChannelData(int fromchannel, int tochannel, sv_frame_t start, sv_frame_t count) const override
Get the specified set of samples from given contiguous range of channels of the model in single-preci...