annotate data/model/test/MockWaveModel.h @ 1174:0ad516dc5d8d

Presume that the Vamp SDK exists at the directory next door
author Chris Cannam
date Fri, 18 Mar 2016 13:42:54 +0000
parents 5fab8e4f5f19
children 4d9816ba0ebe
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@1086 40 virtual float getValueMinimum() const { return -1.f; }
Chris@1086 41 virtual float getValueMaximum() const { return 1.f; }
Chris@1086 42 virtual int getChannelCount() const { return int(m_data.size()); }
Chris@1086 43
Chris@1086 44 virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count,
Chris@1086 45 float *buffer) const;
Chris@1086 46 virtual sv_frame_t getMultiChannelData(int fromchannel, int tochannel,
Chris@1086 47 sv_frame_t start, sv_frame_t count,
Chris@1086 48 float **buffers) const;
Chris@1086 49
Chris@1086 50 virtual bool canPlay() const { return true; }
Chris@1086 51 virtual QString getDefaultPlayClipId() const { return ""; }
Chris@1086 52
Chris@1086 53 virtual sv_frame_t getStartFrame() const { return 0; }
Chris@1086 54 virtual sv_frame_t getEndFrame() const { return m_data[0].size(); }
Chris@1086 55 virtual sv_samplerate_t getSampleRate() const { return 44100; }
Chris@1086 56 virtual bool isOK() const { return true; }
Chris@1086 57
Chris@1086 58 QString getTypeName() const { return tr("Mock Wave"); }
Chris@1086 59
Chris@1086 60 private:
Chris@1086 61 std::vector<std::vector<float> > m_data;
Chris@1088 62 std::vector<float> generate(Sort sort, int length, int pad) const;
Chris@1086 63 };
Chris@1086 64
Chris@1086 65 #endif