I have tried to write a custom module for this but cannot get the button to send.
I want to select a variable from a switch that is inside a modal widget, and based on the switch value chosen, use this value to “prime” a button with a midi command that will be sent when the button is pressed.
Credit must go to @DMDComposer and JoeHidden at ViControl for posting their code and templates to get me started but I just can’t get this bit to work. I have commented out the if statements for copy or not on the transpose just for testing but regardless of what I do the b and # buttons just don’t do anything!
// Variables for Transpose Module
var transposeInterval = 0;
var transposeCopy = false;
var oscHost = '127.0.0.1';
var oscPort = '8080';
module.exports = {
init: function () {
//sendOsc({address: '/bg1', args: [{type: 's', value: 'ff0000'}], host: oscHost, port: oscPort})
//receive('/EDIT', 'bg1', { value: 'ff0000' })
},
oscOutFilter: function (data) {
// Filter incomming osc messages
var { address, args, host, port } = data
if (address === '/transpose') {
switch (args[0].value) {
case 'up':
// if (transposeCopy) {
// sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 24 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'oscIn' });
// } else
{
sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 0 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'oscIn' });
}
break;
case 'down':
// if (transposeCopy) {
// sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 36 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'oscIn' });
// } else
{
sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 12 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'oscIn' });
}
break;
}
return
}
if (address === '/transposeInterval') {
transposeInterval = args[0].value;
new_label = ["minor Second", "Major Second", "minor Third", "Major 3", "Perfect 4th", "TT", "Perfect 5", "minor 6", "Major 6", "minor 7", "Major 7", "Octave"];
receive('/EDIT', 'modal_transpose_interval', { type: 's', value: { 'label': new_label[args[0].value] } });
receive('/modal_transpose_interval', 0);
return;
}
// if (address === '/transposeCopy') { transposeCopy = args[0].value; console.log('Transpose Copy = ' + args[0].value); return; }
return data
}
}