Permalink
Browse files

handle MIDIIn.connectAll failures more gracefully

MIDIIn.connectAll often failes since I've switched to Ubuntustudio 16
with a 'prinitive failed' error. I don't understand clearly why - maybe
this doesn't happen on other platforms and the fix shouldn't have any
negative impact then. In case of failure a warning gets posted, telling
to connect manually.

Signed-off-by: Stefan Nussbaumer <st9fan@gmail.com>
  • Loading branch information...
nuss committed Aug 9, 2018
1 parent 40be46c commit c9d87db1fb81ad3370abd028248daba013584fc4
View
@@ -92,7 +92,10 @@ CVCenter {
Class.initClassTree(MIDIClient);
Class.initClassTree(MIDIEndPoint);
MIDIClient.init;
MIDIIn.connectAll;
try { MIDIIn.connectAll } { |error|
error.postln;
"MIDIIn.connectAll failed. Please establish the necessary connections manually.".warn;
}
})
})
};
@@ -4,11 +4,11 @@ CVCenterKeyboard {
var on, off, bend, namesCVs;
var <>debug = false;
*new { |synthDefName, keyboardArg = \freq, velocArg = \veloc, bendArg = \bend, widgetsPrefix = \kb|
^super.newCopyArgs(synthDefName, keyboardArg, velocArg, bendArg, widgetsPrefix).init;
*new { |synthDefName, keyboardArg = \freq, velocArg = \veloc, bendArg = \bend, widgetsPrefix = \kb, connectMidi = true|
^super.newCopyArgs(synthDefName, keyboardArg, velocArg, bendArg, widgetsPrefix).init(connectMidi);
}
init {
init { |connectMidi|
synthDefName = synthDefName.asSymbol;
SynthDescLib.at(synthDefName) ?? {
@@ -38,7 +38,12 @@ CVCenterKeyboard {
MIDIClient.init;
// doesn't seem to work properly on Ubuntustudio 16
// possibly has to be done manually in QJackQtl...
MIDIClient.connectAll;
if (connectMidi) {
try { MIDIIn.connectAll } { |error|
error.postln;
"MIDIIn.connectAll failed. Please establish the necessary connections manually".warn;
}
}
}
// keyboardArg is the arg that will be set through playing the keyboard
@@ -188,7 +188,11 @@ CVCenterLoadDialog {
]).action_({ |b|
midiSources = ();
if(MIDIClient.initialized, {
MIDIClient.restart; MIDIIn.connectAll;
MIDIClient.restart;
try { MIDIIn.connectAll } { |error|
error.postln;
"MIDIIn.connectAll failed. Please establish the necessary connections manually".warn;
}
}, { MIDIClient.init; MIDIIn.connectAll });
if(MIDIClient.initialized, {
b.states_([
View
@@ -36,7 +36,7 @@ CVWidgetEditor : AbstractCVWidgetEditor {
var wdgtActions;
var cmdNames, orderedCmds, orderedCmdSlots;
var tmp, gapNextX, gapNextY;
var buildCheckbox, ddIPsItems, cmdPairs, dropDownIPs;
var buildCheckbox, midiConnectAll, ddIPsItems, cmdPairs, dropDownIPs;
var connectIP, connectPort;
var mouseOverFunc;
var modsDict, arrModsDict, arrowKeys;
@@ -59,6 +59,13 @@ CVWidgetEditor : AbstractCVWidgetEditor {
cBox;
};
midiConnectAll = {
try { MIDIIn.connectAll } { |error|
error.postln;
"MIDIIn.connectAll failed. Please establish the necessary connections manually".warn;
}
};
switch(GUI.id,
\cocoa, {
modsDict = KeyDownActions.modifiersCocoa;
@@ -417,8 +424,12 @@ CVWidgetEditor : AbstractCVWidgetEditor {
.font_(staticTextFont)
.action_({ |mb|
if(MIDIClient.initialized, {
MIDIClient.restart; MIDIIn.connectAll
}, { MIDIClient.init; MIDIIn.connectAll });
MIDIClient.restart;
midiConnectAll.value;
}, {
MIDIClient.init;
midiConnectAll.value;
});
wcm.midiDisplay.model.value_(
wcm.midiDisplay.model.value
).changedKeys(widget.synchKeys);
@@ -51,7 +51,7 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
var wdgtActions;
var cmdNames, orderedCmds, orderedCmdSlots;
var tmp, tmpIP, tmpPortRestrictor, gapNextX, gapNextY;
var buildCheckbox, ddIPsItems, cmdPairs, dropDownIPs;
var buildCheckbox, midiConnectAll, ddIPsItems, cmdPairs, dropDownIPs;
var connectWarning;
var mouseOverFunc;
var numCalibActive;
@@ -75,6 +75,14 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
cBox;
};
midiConnectAll = {
try { MIDIIn.connectAll } { |error|
error.postln;
"MIDIIn.connectAll failed. Please establish the necessary connections manually".warn;
}
};
switch(GUI.id,
\cocoa, {
modsDict = KeyDownActions.modifiersCocoa;
@@ -567,8 +575,12 @@ CVWidgetMSEditor : AbstractCVWidgetEditor {
.font_(staticTextFont)
.action_({ |mb|
if(MIDIClient.initialized, {
MIDIClient.restart; MIDIIn.connectAll
}, { MIDIClient.init; MIDIIn.connectAll });
MIDIClient.restart;
midiConnectAll.value;
}, {
MIDIClient.init;
midiConnectAll.value;
});
wcmMS.slots[0].midiDisplay.model.value_(
wcmMS.slots[0].midiDisplay.model.value
).changedKeys(widget.synchKeys);

0 comments on commit c9d87db

Please sign in to comment.