22
22
// By T356. For caching jack in/out routing names BEFORE file save.
23
23
// Jack often shuts down during file save, causing the routes to be lost in the file.
24
24
// cacheJackRouteNames() is ONLY called from MusE::save() in app.cpp
25
// Update: Not required any more because the real problem was Jack RT priority, which has been fixed.
25
27
typedef std::multimap <const int, QString> jackRouteNameMap;
26
28
std::map <const AudioTrack*, jackRouteNameMap > jackRouteNameCache;
27
29
typedef std::multimap <const int, QString>::const_iterator ciJackRouteNameMap;
57
61
//---------------------------------------------------------
59
63
//---------------------------------------------------------
61
65
AudioTrack::AudioTrack(TrackType t)
66
//AudioTrack::AudioTrack(TrackType t, int num_out_bufs)
69
//_totalOutChannels = num_out_bufs; // Is either parameter-default MAX_CHANNELS, or custom value passed (used by syntis).
64
70
_processed = false;
66
72
_sendMetronome = false;
68
74
_efxPipe = new Pipeline();
71
_automationType = AUTO_READ;
77
_automationType = AUTO_OFF;
74
addController(new CtrlList(AC_VOLUME));
75
addController(new CtrlList(AC_PAN));
76
addController(new CtrlList(AC_MUTE));
80
addController(new CtrlList(AC_VOLUME,"Volume",0.0,1.0));
81
addController(new CtrlList(AC_PAN, "Pan", -1.0, 1.0));
82
addController(new CtrlList(AC_MUTE,"Mute",0.0,1.0));
78
84
// Changed by Tim. p3.3.15
79
85
//outBuffers = new float*[MAX_CHANNELS];
80
86
//for (int i = 0; i < MAX_CHANNELS; ++i)
81
87
// outBuffers[i] = new float[segmentSize];
82
for (int i = 0; i < MAX_CHANNELS; ++i)
83
posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
88
//for (int i = 0; i < MAX_CHANNELS; ++i)
89
// posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
84
91
// Let's allocate it all in one block, and just point the remaining buffer pointers into the block
85
92
// which allows faster one-shot buffer copying.
86
93
// Nope. Nice but interferes with possibility we don't know if other buffers are contiguous (jack buffers, local stack buffers etc.).
88
95
//for (int i = 0; i < MAX_CHANNELS; ++i)
89
96
// *(outBuffers + i) = sizeof(float) * segmentSize * i;
99
// Easy way, less desirable... Start out with enough for MAX_CHANNELS. Then multi-channel syntis can re-allocate,
100
// via a call to (a modified!) setChannels().
101
// Hard way, more desirable... Creating a synti instance passes the total channels to this constructor, overriding MAX_CHANNELS.
102
_totalOutChannels = MAX_CHANNELS;
103
outBuffers = new float*[_totalOutChannels];
104
for (int i = 0; i < _totalOutChannels; ++i)
105
posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
107
// This is only set by multi-channel syntis...
108
_totalInChannels = 0;
91
110
bufferPos = MAXINT;
112
132
//outBuffers = new float*[MAX_CHANNELS];
113
133
//for (int i = 0; i < MAX_CHANNELS; ++i)
114
134
// outBuffers[i] = new float[segmentSize];
115
for (int i = 0; i < MAX_CHANNELS; ++i)
116
posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
135
//for (int i = 0; i < MAX_CHANNELS; ++i)
136
// posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
139
int chans = _totalOutChannels;
140
// Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
141
if(chans < MAX_CHANNELS)
142
chans = MAX_CHANNELS;
143
outBuffers = new float*[chans];
144
for (int i = 0; i < chans; ++i)
145
posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
117
147
bufferPos = MAXINT;
118
148
_recFile = t._recFile;
124
154
//for (int i = 0; i < MAX_CHANNELS; ++i)
125
155
// delete[] outBuffers[i];
126
156
//delete[] outBuffers;
127
for(int i = 0; i < MAX_CHANNELS; ++i)
159
//for(int i = 0; i < MAX_CHANNELS; ++i)
162
// free(outBuffers[i]);
166
int chans = _totalOutChannels;
167
// Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
168
if(chans < MAX_CHANNELS)
169
chans = MAX_CHANNELS;
170
for(int i = 0; i < chans; ++i)
129
172
if(outBuffers[i])
130
173
free(outBuffers[i]);
134
179
//---------------------------------------------------------
166
211
//---------------------------------------------------------
168
213
void AudioTrack::addPlugin(PluginI* plugin, int idx)
217
PluginI* oldPlugin = (*_efxPipe)[idx];
220
oldPlugin->setID(-1);
221
oldPlugin->setTrack(0);
223
int controller = oldPlugin->parameters();
224
for (int i = 0; i < controller; ++i)
171
PluginI* oldPlugin = (*_efxPipe)[idx];
174
oldPlugin->setID(-1);
175
oldPlugin->setTrack(0);
177
int controller = oldPlugin->parameters();
178
for (int i = 0; i < controller; ++i) {
179
int id = genACnum(idx, i);
180
removeController(id);
184
efxPipe()->insert(plugin, idx);
187
plugin->setTrack(this);
189
int controller = plugin->parameters();
190
for (int i = 0; i < controller; ++i) {
191
int id = genACnum(idx, i);
192
const char* name = plugin->paramName(i);
194
plugin->range(i, &min, &max);
195
CtrlValueType t = plugin->valueType();
196
CtrlList* cl = new CtrlList(id);
197
cl->setRange(min, max);
198
cl->setName(QString(name));
200
LADSPA_PortRangeHint range = plugin->range(i);
201
if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
202
cl->setMode(CtrlList::DISCRETE);
204
cl->setMode(CtrlList::INTERPOLATE);
205
cl->setCurVal(plugin->param(i));
226
int id = genACnum(idx, i);
227
removeController(id);
231
efxPipe()->insert(plugin, idx);
235
plugin->setTrack(this);
237
int controller = plugin->parameters();
238
for (int i = 0; i < controller; ++i)
240
int id = genACnum(idx, i);
241
const char* name = plugin->paramName(i);
243
plugin->range(i, &min, &max);
244
CtrlValueType t = plugin->valueType();
245
CtrlList* cl = new CtrlList(id);
246
cl->setRange(min, max);
247
cl->setName(QString(name));
249
LADSPA_PortRangeHint range = plugin->range(i);
250
if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
251
cl->setMode(CtrlList::DISCRETE);
253
cl->setMode(CtrlList::INTERPOLATE);
254
cl->setCurVal(plugin->param(i));
211
260
//---------------------------------------------------------
880
929
bool AudioTrack::readProperties(Xml& xml, const QString& tag)
882
if (tag == "plugin") {
884
934
for(rackpos = 0; rackpos < PipelineDepth; ++rackpos)
886
936
if(!(*_efxPipe)[rackpos])
889
939
if(rackpos < PipelineDepth)
891
941
PluginI* pi = new PluginI();
967
1017
//---------------------------------------------------------
1018
// showPendingPluginNativeGuis
1019
// This is needed because OSC needs all tracks with plugins to be already
1020
// added to their track lists so it can find them and show their native guis.
1021
//---------------------------------------------------------
1023
void AudioTrack::showPendingPluginNativeGuis()
1025
for(int idx = 0; idx < PipelineDepth; ++idx)
1027
PluginI* p = (*_efxPipe)[idx];
1031
if(p->isShowNativeGuiPending())
1032
p->showNativeGui(true);
1036
//---------------------------------------------------------
968
1037
// mapRackPluginsToControllers
969
1038
//---------------------------------------------------------
1112
1182
//---------------------------------------------------------
1113
1183
// writeRouting
1114
1184
//---------------------------------------------------------
1116
1186
void AudioTrack::writeRouting(int level, Xml& xml) const
1119
1189
if (type() == Track::AUDIO_INPUT) {
1120
1190
ciJackRouteNameCache circ = jackRouteNameCache.find(this);