annotate data/model/test/MockWaveModel.h @ 1086:9f4505ac9072

Tidy dense time-value model API a bit; add first simple unit test for FFT model
author Chris Cannam
date Wed, 10 Jun 2015 17:06:02 +0100
parents
children 5fab8e4f5f19
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@1086 36 /** One Sort per channel! Length is in samples */
Chris@1086 37 MockWaveModel(std::vector<Sort> sorts, int length);
Chris@1086 38
Chris@1086 39 virtual float getValueMinimum() const { return -1.f; }
Chris@1086 40 virtual float getValueMaximum() const { return 1.f; }
Chris@1086 41 virtual int getChannelCount() const { return int(m_data.size()); }
Chris@1086 42
Chris@1086 43 virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count,
Chris@1086 44 float *buffer) const;
Chris@1086 45 virtual sv_frame_t getMultiChannelData(int fromchannel, int tochannel,
Chris@1086 46 sv_frame_t start, sv_frame_t count,
Chris@1086 47 float **buffers) const;
Chris@1086 48
Chris@1086 49 virtual bool canPlay() const { return true; }
Chris@1086 50 virtual QString getDefaultPlayClipId() const { return ""; }
Chris@1086 51
Chris@1086 52 virtual sv_frame_t getStartFrame() const { return 0; }
Chris@1086 53 virtual sv_frame_t getEndFrame() const { return m_data[0].size(); }
Chris@1086 54 virtual sv_samplerate_t getSampleRate() const { return 44100; }
Chris@1086 55 virtual bool isOK() const { return true; }
Chris@1086 56
Chris@1086 57 QString getTypeName() const { return tr("Mock Wave"); }
Chris@1086 58
Chris@1086 59 private:
Chris@1086 60 std::vector<std::vector<float> > m_data;
Chris@1086 61 std::vector<float> generate(Sort sort, int length) const;
Chris@1086 62 };
Chris@1086 63
Chris@1086 64 #endif