svcore  1.9
AggregateWaveModel.h
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _AGGREGATE_WAVE_MODEL_H_
00017 #define _AGGREGATE_WAVE_MODEL_H_
00018 
00019 #include "RangeSummarisableTimeValueModel.h"
00020 #include "PowerOfSqrtTwoZoomConstraint.h"
00021 
00022 #include <vector>
00023 
00024 class AggregateWaveModel : public RangeSummarisableTimeValueModel
00025 {
00026     Q_OBJECT
00027 
00028 public:
00029     struct ModelChannelSpec
00030     {
00031         ModelChannelSpec(RangeSummarisableTimeValueModel *m, int c) :
00032             model(m), channel(c) { }
00033         RangeSummarisableTimeValueModel *model;
00034         int channel;
00035     };
00036 
00037     typedef std::vector<ModelChannelSpec> ChannelSpecList;
00038 
00039     AggregateWaveModel(ChannelSpecList channelSpecs);
00040     ~AggregateWaveModel();
00041 
00042     bool isOK() const;
00043     bool isReady(int *) const;
00044 
00045     QString getTypeName() const { return tr("Aggregate Wave"); }
00046 
00047     int getComponentCount() const;
00048     ModelChannelSpec getComponent(int c) const;
00049 
00050     const ZoomConstraint *getZoomConstraint() const { return &m_zoomConstraint; }
00051 
00052     int getFrameCount() const;
00053     int getChannelCount() const;
00054     int getSampleRate() const;
00055 
00056     virtual Model *clone() const;
00057 
00058     float getValueMinimum() const { return -1.0f; }
00059     float getValueMaximum() const { return  1.0f; }
00060 
00061     virtual int getStartFrame() const { return 0; }
00062     virtual int getEndFrame() const { return getFrameCount(); }
00063 
00064     virtual int getData(int channel, int start, int count,
00065                            float *buffer) const;
00066 
00067     virtual int getData(int channel, int start, int count,
00068                            double *buffer) const;
00069 
00070     virtual int getData(int fromchannel, int tochannel,
00071                            int start, int count,
00072                            float **buffer) const;
00073 
00074     virtual int getSummaryBlockSize(int desired) const;
00075 
00076     virtual void getSummaries(int channel, int start, int count,
00077                               RangeBlock &ranges,
00078                               int &blockSize) const;
00079 
00080     virtual Range getSummary(int channel, int start, int count) const;
00081 
00082     virtual void toXml(QTextStream &out,
00083                        QString indent = "",
00084                        QString extraAttributes = "") const;
00085 
00086 signals:
00087     void modelChanged();
00088     void modelChangedWithin(int, int);
00089     void completionChanged();
00090 
00091 protected slots:
00092     void componentModelChanged();
00093     void componentModelChangedWithin(int, int);
00094     void componentModelCompletionChanged();
00095 
00096 protected:
00097     ChannelSpecList m_components;
00098     static PowerOfSqrtTwoZoomConstraint m_zoomConstraint;
00099 };
00100 
00101 #endif
00102