Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
1085:bf6f64dabe73 | 1086:9f4505ac9072 |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Visualiser | |
5 An audio file viewer and annotation editor. | |
6 Centre for Digital Music, Queen Mary, University of London. | |
7 This file copyright 2006 Chris Cannam. | |
8 | |
9 This program is free software; you can redistribute it and/or | |
10 modify it under the terms of the GNU General Public License as | |
11 published by the Free Software Foundation; either version 2 of the | |
12 License, or (at your option) any later version. See the file | |
13 COPYING included with this distribution for more information. | |
14 */ | |
15 | |
16 #ifndef MOCK_WAVE_MODEL_H | |
17 #define MOCK_WAVE_MODEL_H | |
18 | |
19 #include "../DenseTimeValueModel.h" | |
20 | |
21 #include <vector> | |
22 | |
23 enum Sort { | |
24 DC, | |
25 Sine, | |
26 Cosine, | |
27 Nyquist, | |
28 Dirac | |
29 }; | |
30 | |
31 class MockWaveModel : public DenseTimeValueModel | |
32 { | |
33 Q_OBJECT | |
34 | |
35 public: | |
36 /** One Sort per channel! Length is in samples */ | |
37 MockWaveModel(std::vector<Sort> sorts, int length); | |
38 | |
39 virtual float getValueMinimum() const { return -1.f; } | |
40 virtual float getValueMaximum() const { return 1.f; } | |
41 virtual int getChannelCount() const { return int(m_data.size()); } | |
42 | |
43 virtual sv_frame_t getData(int channel, sv_frame_t start, sv_frame_t count, | |
44 float *buffer) const; | |
45 virtual sv_frame_t getMultiChannelData(int fromchannel, int tochannel, | |
46 sv_frame_t start, sv_frame_t count, | |
47 float **buffers) const; | |
48 | |
49 virtual bool canPlay() const { return true; } | |
50 virtual QString getDefaultPlayClipId() const { return ""; } | |
51 | |
52 virtual sv_frame_t getStartFrame() const { return 0; } | |
53 virtual sv_frame_t getEndFrame() const { return m_data[0].size(); } | |
54 virtual sv_samplerate_t getSampleRate() const { return 44100; } | |
55 virtual bool isOK() const { return true; } | |
56 | |
57 QString getTypeName() const { return tr("Mock Wave"); } | |
58 | |
59 private: | |
60 std::vector<std::vector<float> > m_data; | |
61 std::vector<float> generate(Sort sort, int length) const; | |
62 }; | |
63 | |
64 #endif |