annotate data/model/test/MockWaveModel.h @ 1793:f0ffc88a36b3 time-frequency-boxes

Add duration-and-extent type, which corresponds to a box model
author Chris Cannam
date Wed, 25 Sep 2019 11:06:59 +0100
parents 78fe29adfd16
children
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@1725 51 sv_frame_t getTrueEndFrame() 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@1671 54 int getCompletion() const override { return 100; }
Chris@1086 55
Chris@1580 56 QString getTypeName() const override { return tr("Mock Wave"); }
Chris@1086 57
Chris@1086 58 private:
Chris@1086 59 std::vector<std::vector<float> > m_data;
Chris@1088 60 std::vector<float> generate(Sort sort, int length, int pad) const;
Chris@1086 61 };
Chris@1086 62
Chris@1086 63 #endif