36
36
AudioDevice* audioDevice; // current audio device in use
38
static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
39
static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
39
extern unsigned int volatile midiExtSyncTicks;
42
//static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
43
//static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
41
45
const char* seqMsgList[] = {
42
46
"SEQM_ADD_TRACK", "SEQM_REMOVE_TRACK", "SEQM_CHANGE_TRACK", "SEQM_MOVE_TRACK",
245
248
done = audioPrefetch->seekDone();
248
// Added by Tim. p3.3.20
250
// printf("Audio::sync done:%d state %s\n", done, audioStates[state]);
257
State s = State(jackState);
259
// STOP -> START_PLAY start rolling
260
// STOP -> STOP seek in stop state
261
// PLAY -> START_PLAY seek in play state
263
if (state != START_PLAY) {
264
//Pos p(frame, AL::FRAMES);
269
done = audioPrefetch->seekDone();
274
//if (frame != _seqTime.pos.frame()) {
275
if (frame != _pos.frame()) {
277
//seek(Pos(frame, AL::FRAMES));
278
seek(Pos(frame, false));
280
done = audioPrefetch->seekDone();
255
287
//---------------------------------------------------------
894
957
write(sigFd, "1", 1); // Play
896
// Changed by Tim. p3.3.6
898
// midiPorts[txSyncPort].sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
901
// midiPorts[txSyncPort].sendContinue();
903
// midiPorts[txSyncPort].sendStart();
905
for(int port = 0; port < MIDI_PORTS; ++port)
960
// Don't send if external sync is on. The master, and our sync routing system will take care of that.
961
if(!extSyncFlag.value())
907
MidiPort* mp = &midiPorts[port];
908
MidiDevice* dev = mp->device();
964
// Changed by Tim. p3.3.6
966
// midiPorts[txSyncPort].sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
969
// midiPorts[txSyncPort].sendContinue();
971
// midiPorts[txSyncPort].sendStart();
973
for(int port = 0; port < MIDI_PORTS; ++port)
975
MidiPort* mp = &midiPorts[port];
976
MidiDevice* dev = mp->device();
980
// Shall we check open flags?
981
//if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
982
//if(!(dev->openFlags() & 1))
985
MidiSyncInfo& si = mp->syncInfo();
912
// Shall we check open flags?
913
//if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
914
//if(!(dev->openFlags() & 1))
917
MidiSyncInfo& si = mp->syncInfo();
987
//if(genMMC && si.MMCOut())
989
//mp->sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
990
mp->sendMMCDeferredPlay();
919
//if(genMMC && si.MMCOut())
921
mp->sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
923
//if(genMCSync && si.MCOut())
992
//if(genMCSync && si.MCOut())
934
1005
for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
1077
// Changed by Tim. p3.3.6
1078
//MidiPort* syncPort = &midiPorts[txSyncPort];
1080
// unsigned char mmcPos[] = {
1081
// 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
1084
// int frame = tempomap.tick2frame(curTickPos);
1085
// MTC mtc(double(frame) / double(sampleRate));
1086
// mmcPos[6] = mtc.h() | (mtcType << 5);
1087
// mmcPos[7] = mtc.m();
1088
// mmcPos[8] = mtc.s();
1089
// mmcPos[9] = mtc.f();
1090
// mmcPos[10] = mtc.sf();
1091
// syncPort->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
1092
// syncPort->sendSysex(mmcPos, sizeof(mmcPos));
1094
//if (genMCSync) { // Midi Clock
1152
// Don't send if external sync is on. The master, and our sync routing system will take care of that.
1153
if(!extSyncFlag.value())
1156
// Changed by Tim. p3.3.6
1157
//MidiPort* syncPort = &midiPorts[txSyncPort];
1159
// unsigned char mmcPos[] = {
1160
// 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
1163
// int frame = tempomap.tick2frame(curTickPos);
1164
// MTC mtc(double(frame) / double(sampleRate));
1165
// mmcPos[6] = mtc.h() | (mtcType << 5);
1166
// mmcPos[7] = mtc.m();
1167
// mmcPos[8] = mtc.s();
1168
// mmcPos[9] = mtc.f();
1169
// mmcPos[10] = mtc.sf();
1170
// syncPort->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
1171
// syncPort->sendSysex(mmcPos, sizeof(mmcPos));
1173
//if (genMCSync) { // Midi Clock
1175
// "set song position pointer"
1176
// syncPort->sendStop();
1177
// syncPort->sendSongpos(curTickPos * 4 / config.division);
1179
for(int port = 0; port < MIDI_PORTS; ++port)
1181
MidiPort* mp = &midiPorts[port];
1182
MidiDevice* dev = mp->device();
1186
// Shall we check open flags?
1187
//if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
1188
//if(!(dev->openFlags() & 1))
1191
MidiSyncInfo& si = mp->syncInfo();
1193
//if(genMMC && si.MMCOut())
1196
//unsigned char mmcPos[] = {
1197
// 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
1203
int frame = tempomap.tick2frame(curTickPos);
1204
MTC mtc(double(frame) / double(sampleRate));
1207
//mmcPos[6] = mtc.h() | (mtcType << 5);
1208
//mmcPos[7] = mtc.m();
1209
//mmcPos[8] = mtc.s();
1210
//mmcPos[9] = mtc.f();
1211
//mmcPos[10] = mtc.sf();
1213
//mp->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
1215
//mp->sendSysex(mmcPos, sizeof(mmcPos));
1218
// Added check of option send continue not start.
1219
// Hmm, is this required? Seems to make other devices unhappy.
1221
if(!si.sendContNotStart())
1222
mp->sendMMCLocate(mtc.h() | (mtcType << 5),
1223
mtc.m(), mtc.s(), mtc.f(), mtc.sf());
1228
//if(genMCSync && si.MCOut()) // Midi Clock
1229
//if(si.MCOut()) // Midi Clock
1095
1232
// send STOP and
1096
1233
// "set song position pointer"
1097
// syncPort->sendStop();
1098
// syncPort->sendSongpos(curTickPos * 4 / config.division);
1100
for(int port = 0; port < MIDI_PORTS; ++port)
1102
MidiPort* mp = &midiPorts[port];
1103
MidiDevice* dev = mp->device();
1107
// Shall we check open flags?
1108
//if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
1109
//if(!(dev->openFlags() & 1))
1112
MidiSyncInfo& si = mp->syncInfo();
1114
//if(genMMC && si.MMCOut())
1117
unsigned char mmcPos[] = {
1118
0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
1121
int frame = tempomap.tick2frame(curTickPos);
1122
MTC mtc(double(frame) / double(sampleRate));
1123
mmcPos[6] = mtc.h() | (mtcType << 5);
1124
mmcPos[7] = mtc.m();
1125
mmcPos[8] = mtc.s();
1126
mmcPos[9] = mtc.f();
1127
mmcPos[10] = mtc.sf();
1129
mp->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
1130
mp->sendSysex(mmcPos, sizeof(mmcPos));
1133
//if(genMCSync && si.MCOut()) // Midi Clock
1134
if(si.MCOut()) // Midi Clock
1137
// "set song position pointer"
1139
mp->sendSongpos(curTickPos * 4 / config.division);
1237
// Added check of option send continue not start.
1238
// Hmm, is this required? Seems to make other devices unhappy.
1240
if(!si.sendContNotStart())
1241
mp->sendSongpos(curTickPos * 4 / config.division);
1145
1249
for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)