annotate data/model/test/MockWaveModel.h @ 1652:08bed13d3a26 single-point

Update Labeller to new event API + fewer magical side-effects
author Chris Cannam
date Tue, 19 Mar 2019 13:05:56 +0000
parents c01cbe41aeb5
children 82d03c9661f9
rev   line source
Chris@1086 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@1086 2
Chris@1086 3 /*
Chris@1086 4 Sonic Visualiser
Chris@1086 5 An audio file viewer and annotation editor.
Chris@1086 6 Centre for Digital Music, Queen Mary, University of London.
Chris@1086 7 This file copyright 2006 Chris Cannam.
Chris@1086 8
Chris@1086 9 This program is free software; you can redistribute it and/or
Chris@1086 10 modify it under the terms of the GNU General Public License as
Chris@1086 11 published by the Free Software Foundation; either version 2 of the
Chris@1086 12 License, or (at your option) any later version. See the file
Chris@1086 13 COPYING included with this distribution for more information.
Chris@1086 14 */
Chris@1086 15
Chris@1086 16 #ifndef MOCK_WAVE_MODEL_H
Chris@1086 17 #define MOCK_WAVE_MODEL_H
Chris@1086 18
Chris@1086 19 #include "../DenseTimeValueModel.h"
Chris@1086 20
Chris@1086 21 #include <vector>
Chris@1086 22
Chris@1086 23 enum Sort {
Chris@1086 24 DC,
Chris@1086 25 Sine,
Chris@1086 26 Cosine,
Chris@1086 27 Nyquist,
Chris@1086 28 Dirac
Chris@1086 29 };
Chris@1086 30
Chris@1086 31 class MockWaveModel : public DenseTimeValueModel
Chris@1086 32 {
Chris@1086 33 Q_OBJECT
Chris@1086 34
Chris@1086 35 public:
Chris@1088 36 /** One Sort per channel! Length is in samples, and is in addition
Chris@1088 37 * to "pad" number of zero samples at the start and end */
Chris@1088 38 MockWaveModel(std::vector<Sort> sorts, int length, int pad);
Chris@1086 39
Chris@1580 40 float getValueMinimum() const override { return -1.f; }
Chris@1580 41 float getValueMaximum() const override { return 1.f; }
Chris@1580 42 int getChannelCount() const override { return int(m_data.size()); }
Chris@1086 43
Chris@1580 44 floatvec_t getData(int channel, sv_frame_t start, sv_frame_t count) const override;
Chris@1580 45 std::vector<floatvec_t> getMultiChannelData(int fromchannel, int tochannel, sv_frame_t start, sv_frame_t count) const override;
Chris@1086 46
Chris@1580 47 bool canPlay() const override { return true; }
Chris@1580 48 QString getDefaultPlayClipId() const override { return ""; }
Chris@1086 49
Chris@1580 50 sv_frame_t getStartFrame() const override { return 0; }
Chris@1580 51 sv_frame_t getEndFrame() const override { return m_data[0].size(); }
Chris@1580 52 sv_samplerate_t getSampleRate() const override { return 44100; }
Chris@1580 53 bool isOK() const override { return true; }
Chris@1086 54
Chris@1580 55 QString getTypeName() const override { return tr("Mock Wave"); }
Chris@1086 56
Chris@1086 57 private:
Chris@1086 58 std::vector<std::vector<float> > m_data;
Chris@1088 59 std::vector<float> generate(Sort sort, int length, int pad) const;
Chris@1086 60 };
Chris@1086 61
Chris@1086 62 #endif