Mercurial > hg > svapp
comparison audioio/AudioGenerator.h @ 350:aebee52e86b3
Merge from branch tony_integration
author | Chris Cannam |
---|---|
date | Wed, 14 May 2014 09:54:46 +0100 |
parents | 8d7f39df44ed |
children | 0876ea394902 |
comparison
equal
deleted
inserted
replaced
330:46b24009ce7a | 350:aebee52e86b3 |
---|---|
16 #ifndef _AUDIO_GENERATOR_H_ | 16 #ifndef _AUDIO_GENERATOR_H_ |
17 #define _AUDIO_GENERATOR_H_ | 17 #define _AUDIO_GENERATOR_H_ |
18 | 18 |
19 class Model; | 19 class Model; |
20 class NoteModel; | 20 class NoteModel; |
21 class FlexiNoteModel; | |
21 class DenseTimeValueModel; | 22 class DenseTimeValueModel; |
22 class SparseOneDimensionalModel; | 23 class SparseOneDimensionalModel; |
23 class RealTimePluginInstance; | |
24 class Playable; | 24 class Playable; |
25 class ClipMixer; | |
26 class ContinuousSynth; | |
25 | 27 |
26 #include <QObject> | 28 #include <QObject> |
27 #include <QMutex> | 29 #include <QMutex> |
28 | 30 |
29 #include <set> | 31 #include <set> |
55 * Remove all models. | 57 * Remove all models. |
56 */ | 58 */ |
57 virtual void clearModels(); | 59 virtual void clearModels(); |
58 | 60 |
59 /** | 61 /** |
60 * Reset playback, clearing plugins and the like. | 62 * Reset playback, clearing buffers and the like. |
61 */ | 63 */ |
62 virtual void reset(); | 64 virtual void reset(); |
63 | 65 |
64 /** | 66 /** |
65 * Set the target channel count. The buffer parameter to mixModel | 67 * Set the target channel count. The buffer parameter to mixModel |
90 * muted). | 92 * muted). |
91 */ | 93 */ |
92 virtual void clearSoloModelSet(); | 94 virtual void clearSoloModelSet(); |
93 | 95 |
94 protected slots: | 96 protected slots: |
95 void playPluginIdChanged(const Playable *, QString); | 97 void playClipIdChanged(const Playable *, QString); |
96 void playPluginConfigurationChanged(const Playable *, QString); | |
97 | 98 |
98 protected: | 99 protected: |
99 size_t m_sourceSampleRate; | 100 size_t m_sourceSampleRate; |
100 size_t m_targetChannelCount; | 101 size_t m_targetChannelCount; |
102 size_t m_waveType; | |
101 | 103 |
102 bool m_soloing; | 104 bool m_soloing; |
103 std::set<Model *> m_soloModelSet; | 105 std::set<Model *> m_soloModelSet; |
104 | 106 |
105 struct NoteData { | |
106 | |
107 NoteData(size_t _start, size_t _dur, int _mp, int _vel) : | |
108 start(_start), duration(_dur), midiPitch(_mp), frequency(0), | |
109 isMidiPitchQuantized(true), velocity(_vel) { }; | |
110 | |
111 size_t start; // audio sample frame | |
112 size_t duration; // in audio sample frames | |
113 int midiPitch; // 0-127 | |
114 int frequency; // Hz, to be used if isMidiPitchQuantized false | |
115 bool isMidiPitchQuantized; | |
116 int velocity; // MIDI-style 0-127 | |
117 }; | |
118 | |
119 typedef std::vector<NoteData> NoteList; | |
120 | |
121 struct NoteOff { | 107 struct NoteOff { |
122 | 108 |
123 NoteOff(int _p, size_t _f) : pitch(_p), frame(_f) { } | 109 NoteOff(float _freq, size_t _frame) : frequency(_freq), frame(_frame) { } |
124 | 110 |
125 int pitch; | 111 float frequency; |
126 size_t frame; | 112 size_t frame; |
127 | 113 |
128 struct Comparator { | 114 struct Comparator { |
129 bool operator()(const NoteOff &n1, const NoteOff &n2) const { | 115 bool operator()(const NoteOff &n1, const NoteOff &n2) const { |
130 return n1.frame < n2.frame; | 116 return n1.frame < n2.frame; |
131 } | 117 } |
132 }; | 118 }; |
133 }; | 119 }; |
134 | 120 |
135 typedef std::map<const Model *, RealTimePluginInstance *> PluginMap; | 121 |
122 typedef std::map<const Model *, ClipMixer *> ClipMixerMap; | |
136 | 123 |
137 typedef std::multiset<NoteOff, NoteOff::Comparator> NoteOffSet; | 124 typedef std::multiset<NoteOff, NoteOff::Comparator> NoteOffSet; |
138 typedef std::map<const Model *, NoteOffSet> NoteOffMap; | 125 typedef std::map<const Model *, NoteOffSet> NoteOffMap; |
139 | 126 |
127 typedef std::map<const Model *, ContinuousSynth *> ContinuousSynthMap; | |
128 | |
140 QMutex m_mutex; | 129 QMutex m_mutex; |
141 PluginMap m_synthMap; | 130 |
131 ClipMixerMap m_clipMixerMap; | |
142 NoteOffMap m_noteOffs; | 132 NoteOffMap m_noteOffs; |
143 static QString m_sampleDir; | 133 static QString m_sampleDir; |
144 | 134 |
145 virtual RealTimePluginInstance *loadPluginFor(const Model *model); | 135 ContinuousSynthMap m_continuousSynthMap; |
146 virtual RealTimePluginInstance *loadPlugin(QString id, QString program); | 136 |
137 bool usesClipMixer(const Model *); | |
138 bool wantsQuieterClips(const Model *); | |
139 bool usesContinuousSynth(const Model *); | |
140 | |
141 ClipMixer *makeClipMixerFor(const Model *model); | |
142 ContinuousSynth *makeSynthFor(const Model *model); | |
143 | |
147 static void initialiseSampleDir(); | 144 static void initialiseSampleDir(); |
148 static void setSampleDir(RealTimePluginInstance *plugin); | |
149 | 145 |
150 virtual size_t mixDenseTimeValueModel | 146 virtual size_t mixDenseTimeValueModel |
151 (DenseTimeValueModel *model, size_t startFrame, size_t frameCount, | 147 (DenseTimeValueModel *model, size_t startFrame, size_t frameCount, |
152 float **buffer, float gain, float pan, size_t fadeIn, size_t fadeOut); | 148 float **buffer, float gain, float pan, size_t fadeIn, size_t fadeOut); |
153 | 149 |
154 virtual size_t mixSyntheticNoteModel | 150 virtual size_t mixClipModel |
155 (Model *model, size_t startFrame, size_t frameCount, | 151 (Model *model, size_t startFrame, size_t frameCount, |
156 float **buffer, float gain, float pan, size_t fadeIn, size_t fadeOut); | 152 float **buffer, float gain, float pan); |
153 | |
154 virtual size_t mixContinuousSynthModel | |
155 (Model *model, size_t startFrame, size_t frameCount, | |
156 float **buffer, float gain, float pan); | |
157 | 157 |
158 NoteList getNotes(Model *model, size_t startFrame, size_t endFrame); | 158 static const size_t m_processingBlockSize; |
159 | |
160 static const size_t m_pluginBlockSize; | |
161 }; | 159 }; |
162 | 160 |
163 #endif | 161 #endif |
164 | 162 |