Chris@0
|
1 /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 A waveform viewer and audio annotation editor.
|
Chris@0
|
5 Chris Cannam, Queen Mary University of London, 2005
|
Chris@0
|
6
|
Chris@0
|
7 This is experimental software. Not for distribution.
|
Chris@0
|
8 */
|
Chris@0
|
9
|
Chris@0
|
10 #ifndef _AUDIO_GENERATOR_H_
|
Chris@0
|
11 #define _AUDIO_GENERATOR_H_
|
Chris@0
|
12
|
Chris@0
|
13 class Model;
|
Chris@0
|
14 class ViewManager;
|
Chris@0
|
15 class DenseTimeValueModel;
|
Chris@0
|
16 class SparseOneDimensionalModel;
|
Chris@0
|
17 class RealTimePluginInstance;
|
Chris@0
|
18
|
Chris@0
|
19 #include <set>
|
Chris@0
|
20 #include <map>
|
Chris@0
|
21
|
Chris@0
|
22 class AudioGenerator
|
Chris@0
|
23 {
|
Chris@0
|
24 public:
|
Chris@0
|
25 AudioGenerator(ViewManager *);
|
Chris@0
|
26 virtual ~AudioGenerator();
|
Chris@0
|
27
|
Chris@0
|
28 /**
|
Chris@0
|
29 * Add a data model to be played from and initialise any
|
Chris@0
|
30 * necessary audio generation code.
|
Chris@0
|
31 */
|
Chris@0
|
32 virtual void addModel(Model *model);
|
Chris@0
|
33
|
Chris@0
|
34 /**
|
Chris@0
|
35 * Remove a model.
|
Chris@0
|
36 */
|
Chris@0
|
37 virtual void removeModel(Model *model);
|
Chris@0
|
38
|
Chris@0
|
39 /**
|
Chris@0
|
40 * Remove all models.
|
Chris@0
|
41 */
|
Chris@0
|
42 virtual void clearModels();
|
Chris@0
|
43
|
Chris@0
|
44 /**
|
Chris@0
|
45 * Reset playback, clearing plugins and the like.
|
Chris@0
|
46 */
|
Chris@0
|
47 virtual void reset();
|
Chris@0
|
48
|
Chris@0
|
49 /**
|
Chris@0
|
50 * Set the target channel count. The buffer parameter to mixModel
|
Chris@0
|
51 * must always point to at least this number of arrays.
|
Chris@0
|
52 */
|
Chris@0
|
53 virtual void setTargetChannelCount(size_t channelCount);
|
Chris@0
|
54
|
Chris@0
|
55 /**
|
Chris@0
|
56 * Return the internal processing block size. The frameCount
|
Chris@0
|
57 * argument to all mixModel calls must be a multiple of this
|
Chris@0
|
58 * value.
|
Chris@0
|
59 */
|
Chris@0
|
60 virtual size_t getBlockSize() const;
|
Chris@0
|
61
|
Chris@0
|
62 /**
|
Chris@0
|
63 * Mix a single model into an output buffer.
|
Chris@0
|
64 */
|
Chris@0
|
65 virtual size_t mixModel(Model *model, size_t startFrame, size_t frameCount,
|
Chris@0
|
66 float **buffer);
|
Chris@0
|
67
|
Chris@0
|
68 protected:
|
Chris@0
|
69 ViewManager *m_viewManager;
|
Chris@0
|
70 size_t m_sourceSampleRate;
|
Chris@0
|
71 size_t m_targetChannelCount;
|
Chris@0
|
72
|
Chris@0
|
73 struct NoteOff {
|
Chris@0
|
74
|
Chris@0
|
75 int pitch;
|
Chris@0
|
76 size_t frame;
|
Chris@0
|
77
|
Chris@0
|
78 struct Comparator {
|
Chris@0
|
79 bool operator()(const NoteOff &n1, const NoteOff &n2) const {
|
Chris@0
|
80 return n1.frame < n2.frame;
|
Chris@0
|
81 }
|
Chris@0
|
82 };
|
Chris@0
|
83 };
|
Chris@0
|
84
|
Chris@0
|
85 typedef std::map<SparseOneDimensionalModel *,
|
Chris@0
|
86 RealTimePluginInstance *> PluginMap;
|
Chris@0
|
87
|
Chris@0
|
88 typedef std::set<NoteOff, NoteOff::Comparator> NoteOffSet;
|
Chris@0
|
89 typedef std::map<SparseOneDimensionalModel *, NoteOffSet> NoteOffMap;
|
Chris@0
|
90
|
Chris@0
|
91 PluginMap m_synthMap;
|
Chris@0
|
92 NoteOffMap m_noteOffs;
|
Chris@0
|
93
|
Chris@0
|
94 virtual size_t mixDenseTimeValueModel
|
Chris@0
|
95 (DenseTimeValueModel *model, size_t startFrame, size_t frameCount,
|
Chris@0
|
96 float **buffer, float gain, float pan);
|
Chris@0
|
97
|
Chris@0
|
98 virtual size_t mixSparseOneDimensionalModel
|
Chris@0
|
99 (SparseOneDimensionalModel *model, size_t startFrame, size_t frameCount,
|
Chris@0
|
100 float **buffer, float gain, float pan);
|
Chris@0
|
101
|
Chris@0
|
102 static const size_t m_pluginBlockSize;
|
Chris@0
|
103 };
|
Chris@0
|
104
|
Chris@0
|
105 #endif
|
Chris@0
|
106
|