Getting .js/midi remote going

Trying to get this loading…?

// CR Monitor 3dB Step – ready-to-drop, UTF-8 without BOM
var midiremote_api = require(‘midiremote_api_v1’)

// DEVICE DRIVER
var driver = midiremote_api.makeDeviceDriver(
‘Aurasphere’,
‘CR Monitor 3dB Step’,
‘MW’
)

// MIDI INPUT
var midiInput = driver.mPorts.makeMidiInput()
midiInput.setPortName(‘CR_Monitor’)  // Change to your MIDI port

// SURFACE
var surface = driver.mSurface

// Make visible knob
var knob = surface.makeKnob(2, 2, 4, 4)

// Bind knob to MIDI input (relative 2’s complement: 63/65)
knob.mSurfaceValue.mMidiBinding
.setInputPort(midiInput)
.bindToControlChange(0, 21)

// MAPPING
var page = driver.mMapping.makePage(‘Main’)

// Control Room Main Monitor Level
var monitorLevel = page.mHostAccess.mControlRoom.mMainMonitorLevel

// SETTINGS
var minDb = -60
var maxDb = 12
var stepDb = 3
var currentDb = -20

// SYNC FROM CUBASE
monitorLevel.mOnProcessValueChange = function (context, value) {
currentDb = minDb + (value * (maxDb - minDb))
knob.mSurfaceValue.setProcessValue(context, value)
}

// ENCODER HANDLING
knob.mSurfaceValue.mOnProcessValueChange = function (context, value) {
var midiVal = Math.round(value * 127)

if (midiVal === 65)      currentDb += stepDb
else if (midiVal === 63) currentDb -= stepDb
else return

if (currentDb < minDb) currentDb = minDb
if (currentDb > maxDb) currentDb = maxDb

var normalized = (currentDb - minDb) / (maxDb - minDb)

monitorLevel.setProcessValue(context, normalized)
knob.mSurfaceValue.setProcessValue(context, normalized)

}

There are errors here (to be expected since it got from chatGPT), still here is a version you can test:

var midiremote_api = require('midiremote_api_v1')
var deviceDriver = midiremote_api.makeDeviceDriver("Aurasphere","CR Monitor 3dB Step","MW")

var midiInput = deviceDriver.mPorts.makeMidiInput("anInput")
var midiOutput = deviceDriver.mPorts.makeMidiOutput("anOutput")

var detectionUnit=deviceDriver.makeDetectionUnit()
detectionUnit.detectPortPair(midiInput,midiOutput)
   .expectInputNameEquals("Bome MIDI Translator 1")
   .expectOutputNameEquals("Bome MIDI Translator 1")
    
var surface=deviceDriver.mSurface
var mapping=deviceDriver.mMapping

var knobReal=surface.makeCustomValueVariable("knobReal")
knobReal.mMidiBinding
   .setInputPort(midiInput)
   .bindToControlChange(0,21)

var knobShown=surface.makeKnob(0,0,1,1)

var page=mapping.makePage("Main")

var minDb=-60
var maxDb=12
var stepDb=3
var currentDb=-20

var monitorLevel = page.mHostAccess.mControlRoom.mMainChannel.mLevelValue

page.makeValueBinding(knobShown.mSurfaceValue,monitorLevel)

monitorLevel.mOnProcessValueChange=function(activeDevice,activeMapping,value){
   console.log("value="+value)
   currentDb=minDb+(value*(maxDb-minDb))
}

monitorLevel.mOnDisplayValueChange=function(activeDevice,activeMapping,displayValue){
   console.log("displayValue="+displayValue)
}

knobReal.mOnProcessValueChange=function(activeDevice,value,diff){
   
   var midiVal=Math.round(127*value)
   if (midiVal===65){currentDb-=stepDb}
   else if (midiVal===63){currentDb+=stepDb}
   else {return}

   if (currentDb<minDb) currentDb=minDb
   if (currentDb>maxDb) currentDb=maxDb

   var normalized=(currentDb-minDb)/(maxDb-minDb)

   knobShown.mSurfaceValue.setProcessValue(activeDevice,normalized)
   
}

At the line “.expectInputNameEquals(…” place your midi input port name.

I’m not really sure whether the normalisation used is accurate, in fact I think that a map is needed to properly create the 3db, still one step at a time. If the script works, we can go for optimising the values later. For now, note that I’ve placed two events (an mOnProcessValue of the level and the mOnDisplayValueChange). This way, we can get a log into the console so that we can see what value (0→1) represents what db. By the way I’ve changed the part of the code concerning the db change, since I guess we’re talking about 2’s complement, so 65 should yield a decrease. But this is not important right now.

2 Likes

Yeah it was chat as although it has errors to start with, as you become solid in the api framework, its good having something to wrestle with…BS is the most common word I use with it.

Cheers…bedtime in Sydney :-1:

Should just be dynamic/parametric though? But LUT is not the end of the world

Main issue is I can’t get qbase to recognise any script ATM

Cheers

Ok…still not seeing the .js

I renamed the ports

var midiInput = deviceDriver.mPorts.makeMidiInput("anInput")
var midiOutput = deviceDriver.mPorts.makeMidiOutput("anOutput")

var detectionUnit=deviceDriver.makeDetectionUnit()
detectionUnit.detectPortPair(midiInput,midiOutput)
   .expectInputNameEquals("CR_To")
   .expectOutputNameEquals("CR_From")

It is located here and named as per your suggestion

However GUI based surfaces load fine eg

Ideas? :slight_smile:

EDIT: Ok, its so finicky as it totally relies on folder reconstitution in file name
Aurasphere_Test.js worked…if it helps anyone else.

Just to be clear, my suggestion was based on your folder structure as shared here:

I see that now you’ve altered the structure.

Yes…I opened up a working one eg example company and then all you had said made sense so I just copied that structure/naming and it loaded
Now the issue is that the CC7, channel 1, relative is not being recognised…so Im onto that atm.
Thanks so much for your help btw
Flow charts for coding are so helpful and there are a couple for a fresh startup they are a bit esoteric. I did a lot of SOP and startup charts…soooo valuable

Whats so weird, is that a pro DAW, alive for so long, spending all the resource to get Control Room, which is amazing but then leave out stepped monitoring which is 101 for pro mixing/mastering is just strange…really strange.

@m.c So you are absolutely correct about needing an LUT because its not a logarithmic taper…something proprietary it seems. So I just want to type the values inito the CR mon and have it output the 0-1 FP for each step…but you cant copy paste in the console window and js is sandboxed so you cant simply write to a file…wow why is it so hard to do basic stuff. I dont want to use 14bit so would be fine to step through LUT indexes using a relative CC

Got it all going…I use +12 headroom…just used the console output and typed the 3db steps. worked fine.
Thanks so much for your help…got me up and going

1 Like

True. For such cases, where we really need the console output, I’ve created an html page for handling this. We need a virtual port to send our text to, and this page to receive it.

Great tool! Full of surprises

In the end I just screenshot the console output and got chat to compile it into an indexed table

I understood that :slight_smile: However, this won’t work very well when we have huge logs. For example, at the time I created this tool, I had to log nearly 20000 objects/parameters in CBs structure. Still, this is irrelevant to CB12, so no worries :slight_smile:

1 Like

A lot of gems like this tool but not always easy to find!