I'm starting to learn more about the custom module and I cannot figure out the basics. How can I simply set a faders preargs with a custom module? I want to send multiple preargs with a single fader.
For example: a fader that control cc1 and cc11, or a fader that sends on multiple midi channels etc..
Here's an example of one fader sending the same value to multiple CCs.
The OSC fader has the following props setup:
"address: /fader" //this is an arbitrary custom OSC address
"perArgs: [1, 11, 12, 13, 14]" // these are the CC numbers the fader will send message to
"target: midi:none" // this is a dummy midi port name. This message will be caught by the custom module, transformed and bypassed
As you can see, the props are used in a different way.
Now, the custom module looks like this:
module.exports = {
//this function intercepts all messages the client send and store them in the data argument
oscOutFilter: function (data) {
//this is called destructuring, and breaks down the data into those four variables
const { address, args, host, port } = data
// checks if the address is the same custom address assigned to the client fader
if (address == "/fader") {
// args is an array of objects in the form {type: string, value: number}
// and the last element is the fader current value
// here its value is stored in a new variable at the same time
// it's popped from the original array
const value = args.pop().value
//looping through all the remaining elements of the args array
//that represent all the CCs to send out
args.forEach(cc => {
//finally, each CC is sent out with the current fader value
// replace "midiPortNameToYourDAW" with the midi port used to send midi to your DAW
send("midi", "midiPortNameToYourDAW", "/control", 1, cc.value, value)
});
// after intercepting, transforming and sending the data, the original one is bypassed
// by returning nothing inside this if statement
return
}
// outside the if statement, to make sure all the other data still can be sent out
// the original data must be returned
return data
}
}
Thank you, this has been very helpful. I believe I've managed to adapt this to use a single slider to send on multiple midi channels.
Any ideas of why this isn't working? I have multiple instruments in kontakt, each on a different channel, I want the fader to control the same parameter on all of them.
The debug appears to be correct, but the result is the fader only affects channel 1 in kontakt and none of the others.
module.exports = {
oscInFilter:function(data){
var {address, args, host, port} = data
return {address, args, host, port}
},
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
if (address === "/fader") {
const value = args.pop().value
for (let x = 1; x <17; x++) {
send("midi", "OSCMIDICONTROL", "/control", x, 23, value)
}
return
}
return data
}
}
EDIT: Figured it out, was a DAW issue. Track has to be enabled to receive ANY or ALL midi inputs.
Would you happen to know what's wrong with this? Things seem to work, but I'm getting an error when I click in the project window or press another button widget.
oscOutFilter:function(data){
var {address, args, host, port, clientId} = data
if (address === "/micFaderClose" || "/micFaderTree" || "/micFaderAmbient" || "micFaderOutriggers") {
const value = args[2].value
const midiCC = args[1].value
for (let x = 1; x <17; x++) {
send("midi", "OSCMIDICONTROL", "/control", x, midiCC, value)
}
return
}
return data
}
}
It's not possible to check a condition the way you did using || (OR operator). You need to check if the address is equal to each one separately, otherwise it will always evaluate to true.
It should look like this:
@ClelsonLopes Don't mean to keep asking you things, have really appreciated all the help you have provided. Would you have any quick info to point me in the direction of including the following feature.
I want to include a button that sends the current value of all 4 faders from this post. But when it sends, it needs to be on all channels like how the faders send.
I've set up a button with address: /sendAllMics but I'm a bit lost in how to script this.
Would I need to store the values somehow or is there a simpler solution?