Ive managed to get everything working (common controls, envelopes, device controls, pages access with buttons) excepts the macros
As you can see in my code, ive just replicated the approach i used for above for the macros, but im getting the following error in the bitwig console:
TypeError: Cannot find function set in object com.bitwig.flt.control_surface.intention.sections
Here is my code, any help much appreciated
midimix.control.js
Code: Select all
// by Duncan MacLennan
loadAPI(1);
host.defineController("Akai", "Midimix", "1.0", "80c4f150-32c7-11e6-bdf4-0800200c9a66");
host.defineMidiPorts(1, 1);
host.addDeviceNameBasedDiscoveryPair(["MIDI mix"], ["MIDI mix"]);
//load externals
load("midimix.functions.js")
//define the range of CCs
var CC_RANGE_HI = 120;
var CC_RANGE_LO = 100;
var parameterIds = [];
//------------------------------------ Init -----------------------------------//
function init()
{
//-------- Set MIDI callbacks / port
host.getMidiInPort(0).setMidiCallback(onMidiPort1);
//Sends Notes to Bitwig, with no input filters.
noteIn = host.getMidiInPort(0).createNoteInput("Notes");
noteIn.setShouldConsumeEvents(false);
//Creates an array of user controls with the proper amount of CC#s
//Creating a view onto the selected device
cursorDevice = host.createEditorCursorDevice(2);
parameters.update();
}
function onMidiPort1(status, data1, data2)
{
//Checks if the MIDI data is a CC
if (isChannelController(status))
{
//if it is, check if the CC is within our range
if (data1 >= CC_RANGE_LO && data1 <= CC_RANGE_HI)
{
//if it is, get the index of the CC in our userControls
//And set the value of the control to the value of our CC
}else{
//Running our control Functions
parameters.control(data1,data2)
parameters.envelope(data1,data2)
parameters.common(data1, data2)
parameters.macro(data1,data2)
parameters.pageScroll(data1, data2);
}
//Note Data
}else{
parameters.pageScroll(data1, data2);
}
}
function exit()
{
println("exit")
}
Code: Select all
// functions.js
var parameters = {
offset: 25
,
control: function(data1, data2)
{
if(data1 >= this.offset && data1 < this.offset + 8 ){
cursorDevice.getParameter(data1 - this.offset).set(data2,128);
}
},
envelope: function(data1, data2)
{
if(data1 >= this.offset - 8 && data1 < this.offset){
cursorDevice.getEnvelopeParameter(data1 - (this.offset - 8)).set(data2,128);
}
},
common: function(data1, data2)
{
if(data1 >= this.offset - 16 && data1 < this.offset -8){
cursorDevice.getCommonParameter(data1 - (this.offset - 16)).set(data2,128);
}
},
macro: function(data1, data2)
{
if(data1 >= this.offset + 32 && data1 < this.offset + 40){
cursorDevice.getMacro(data1 - (this.offset +32)).set(data2,128);
}
},
pageScroll: function(data1, data2)
{
if(data1 == 33 && data2 != 0){
cursorDevice.setParameterPage(0);
}else if(data1 ==34 && data2 != 0){
cursorDevice.setParameterPage(1);
}else if(data1 ==35 && data2 != 0){
cursorDevice.setParameterPage(2);
}else if(data1 ==36 && data2 != 0){
cursorDevice.setParameterPage(3);
}else if(data1 ==37 && data2 != 0){
cursorDevice.setParameterPage(4);
}else if(data1 ==38 && data2 != 0){
cursorDevice.setParameterPage(5);
}else if(data1 ==39 && data2 != 0){
cursorDevice.setParameterPage(6);
}else if(data1 ==40 && data2 != 0){
cursorDevice.setParameterPage(7);
}else if(data1 ==49 && data2 != 0){
cursorDevice.setParameterPage(8);
}else if(data1 ==50 && data2 != 0){
cursorDevice.setParameterPage(9);
}else if(data1 ==51 && data2 != 0){
cursorDevice.setParameterPage(10);
}else if(data1 ==52 && data2 != 0){
cursorDevice.setParameterPage(11);
}else if(data1 ==53 && data2 != 0){
cursorDevice.setParameterPage(12);
}else if(data1 ==54 && data2 != 0){
cursorDevice.setParameterPage(13);
}else if(data1 ==55 && data2 != 0){
cursorDevice.setParameterPage(14);
}else if(data1 ==56 && data2 != 0){
cursorDevice.setParameterPage(15);
}
},
update: function()
{
for(var p = 0; p <8; p ++)
{
cursorDevice.getParameter(p).setIndication(true)
}
}
}
