34
34
#include "globaldefs.h"
37
39
namespace MusECore {
39
//bool Track::_isVisible=true;
40
41
unsigned int Track::_soloRefCnt = 0;
41
42
Track* Track::_tmpSoloChainTrack = 0;
42
43
bool Track::_tmpSoloChainDoIns = false;
43
44
bool Track::_tmpSoloChainNoDec = false;
44
//bool Track::_tmpIsAuxProcessing = false;
45
//int Track::_tmpIsAuxProcRefCount = 0;
47
46
const char* Track::_cname[] = {
48
47
"Midi", "Drum", "Wave", "AudioOut", "AudioIn", "AudioGroup",
111
110
Part* part = ip->second;
112
111
const EventList* el = part->cevents();
113
//unsigned len = part->lenTick();
114
112
for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
116
114
const Event& ev = ie->second;
117
// Added by T356. Do not remove events which are past the end of the part.
118
// No, actually, do remove ALL of them belonging to the part.
119
// Just in case there are stray values left after the part end.
120
//if(ev.tick() >= len)
123
116
if(ev.type() == Controller)
395
382
p->enableAllControllers(true);
385
if(type() == AUDIO_SOFTSYNTH)
387
SynthI* synth = static_cast<SynthI*>(this);
388
if(synth->synth() && synth->synth()->synthType() == Synth::DSSI_SYNTH)
390
SynthIF* sif = synth->sif();
393
DssiSynthIF* dssi_sif = static_cast<DssiSynthIF*>(sif);
394
dssi_sif->enableAllControllers(true);
399
400
t->recEvents()->clear();
418
419
void Track::updateAuxRoute(int refInc, Track* dst)
420
//if(isMidiTrack() || _type == AUDIO_AUX)
421
421
if(isMidiTrack())
424
//printf("Track::updateAuxRoute %s _auxRouteCount:%d refInc:%d\n", name().toLatin1().constData(), _auxRouteCount, refInc);
428
426
_nodeTraversed = true;
552
539
clefType = mt.clefType;
555
// FIXME: May get "addRoute: src track route already exists" when say,
556
// an audio output and wave track are selected just because
557
// of the redundancy (wave track wants to connect to output by default).
558
542
if(flags & ASSIGN_ROUTES)
560
544
for(ciRoute ir = mt._inRoutes.begin(); ir != mt._inRoutes.end(); ++ir)
561
// Amazingly, this single line seems to work.
562
MusEGlobal::audio->msgAddRoute(*ir, Route(this, ir->channel));
545
// Don't call msgAddRoute. Caller later calls msgAddTrack which 'mirrors' this routing node.
546
_inRoutes.push_back(*ir);
564
548
for(ciRoute ir = mt._outRoutes.begin(); ir != mt._outRoutes.end(); ++ir)
565
// Amazingly, this single line seems to work.
566
MusEGlobal::audio->msgAddRoute(Route(this, ir->channel), *ir);
549
// Don't call msgAddRoute. Caller later calls msgAddTrack which 'mirrors' this routing node.
550
_outRoutes.push_back(*ir);
568
552
else if(flags & ASSIGN_DEFAULT_ROUTES)
579
563
c = mp->defaultInChannels();
582
MusEGlobal::audio->msgAddRoute(Route(i, c), Route(this, c));
583
//updateFlags |= SC_ROUTE;
565
// Don't call msgAddRoute. Caller later calls msgAddTrack which 'mirrors' this routing node.
566
_inRoutes.push_back(Route(i, c));
589
571
c = mp->defaultOutChannels();
593
575
/// TODO: Switch if and when multiple output routes supported.
595
MusEGlobal::audio->msgAddRoute(Route(this, c), Route(i, c));
596
//updateFlags |= SC_ROUTE;
577
// Don't call msgAddRoute. Caller later calls msgAddTrack which 'mirrors' this routing node.
578
_outRoutes.push_back(Route(i, c));
598
580
for(ch = 0; ch < MIDI_CHANNELS; ++ch)
741
709
Route bRoute(this, chanmask);
744
//if((portmask & (1 << port)) && (chanmask & (1 << ch)))
745
712
if(portmask & (1 << port))
747
// Route already exists?
748
//if(iir != rl->end())
750
714
MusEGlobal::audio->msgAddRoute(aRoute, bRoute);
755
// Route does not exist?
756
//if(iir == rl->end())
758
719
MusEGlobal::audio->msgRemoveRoute(aRoute, bRoute);
913
874
xml.intTag(level, "device", outPort());
914
875
xml.intTag(level, "channel", outChannel());
915
//xml.intTag(level, "inportMap", inPortMask());
916
///xml.uintTag(level, "inportMap", inPortMask()); // Obsolete
917
///xml.intTag(level, "inchannelMap", inChannelMask()); // Obsolete
918
876
xml.intTag(level, "locked", _locked);
919
877
xml.intTag(level, "echo", _recEcho);
972
930
else if (tag == "channel")
973
931
setOutChannel(xml.parseInt());
974
932
else if (tag == "inportMap")
975
//setInPortMask(xml.parseInt());
976
///setInPortMask(xml.parseUInt());
977
//xml.skip(tag); // Obsolete.
978
portmask = xml.parseUInt(); // Support old files.
933
portmask = xml.parseUInt(); // Obsolete but support old files.
979
934
else if (tag == "inchannelMap")
980
///setInChannelMask(xml.parseInt());
981
//xml.skip(tag); // Obsolete.
982
chanmask = xml.parseInt(); // Support old files.
935
chanmask = xml.parseInt(); // Obsolete but support old files.
983
936
else if (tag == "locked")
984
937
_locked = xml.parseInt();
985
938
else if (tag == "echo")
1179
//if(r->type == Route::MIDI_DEVICE_ROUTE) // Obsolete since 1.1-RC2
1180
// s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType()); //
1181
//if(r->type != Route::TRACK_ROUTE) //
1182
1132
if(r->type != Route::TRACK_ROUTE && r->type != Route::MIDI_PORT_ROUTE)
1183
1133
s += QString(" type=\"%1\"").arg(r->type);
1185
//s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
1186
1135
if(r->type == Route::MIDI_PORT_ROUTE)
1187
1136
s += QString(" mport=\"%1\"/").arg(r->midiPort);
1147
int MidiTrack::getFirstControllerValue(int ctrl, int def)
1150
unsigned tick=-1; // maximum integer
1152
for (iPart pit=parts()->begin(); pit!=parts()->end(); pit++)
1154
Part* part=pit->second;
1155
if (part->tick() > tick) break; // ignore this and the rest. we won't find anything new.
1156
for (iEvent eit=part->events()->begin(); eit!=part->events()->end(); eit++)
1158
if (eit->first+part->tick() >= tick) break;
1159
if (eit->first > part->lenTick()) break; // ignore events past the end of the part
1160
// else if (eit->first+part->tick() < tick) and
1161
if (eit->second.type()==Controller && eit->second.dataA()==ctrl)
1163
val = eit->second.dataB();
1164
tick = eit->first+part->tick();
1173
int MidiTrack::getControllerChangeAtTick(unsigned tick, int ctrl, int def)
1175
for (iPart pit=parts()->begin(); pit!=parts()->end(); pit++)
1177
Part* part=pit->second;
1178
if (part->tick() > tick) break; // ignore this and the rest. we'd find nothing any more
1179
if (part->endTick() < tick) continue; // ignore only this.
1180
for (iEvent eit=part->events()->begin(); eit!=part->events()->end(); eit++)
1182
if (eit->first+part->tick() > tick) break; // we won't find anything in this part from now on.
1183
if (eit->first > part->lenTick()) break; // ignore events past the end of the part
1184
if (eit->first+part->tick() < tick) continue; // ignore only this
1186
// else if (eit->first+part->tick() == tick) and
1187
if (eit->second.type()==Controller && eit->second.dataA()==ctrl)
1188
return eit->second.dataB();
1195
// returns the tick where this CC gets overriden by a new one
1196
// returns UINT_MAX for "never"
1197
unsigned MidiTrack::getControllerValueLifetime(unsigned tick, int ctrl)
1199
unsigned result=UINT_MAX;
1201
for (iPart pit=parts()->begin(); pit!=parts()->end(); pit++)
1203
Part* part=pit->second;
1204
if (part->tick() > result) break; // ignore this and the rest. we won't find anything new.
1205
if (part->endTick() < tick) continue; // ignore only this part, we won't find anything there.
1206
for (iEvent eit=part->events()->begin(); eit!=part->events()->end(); eit++)
1208
if (eit->first+part->tick() >= result) break;
1209
if (eit->first > part->lenTick()) break; // ignore events past the end of the part
1210
// else if (eit->first+part->tick() < result) and
1211
if (eit->first+part->tick() > tick &&
1212
eit->second.type()==Controller && eit->second.dataA()==ctrl)
1214
result = eit->first+part->tick();
1198
1223
} // namespace MusECore