[SLOVED] Cubase / Transpose module

I am making a controller from the template @DMDComposer JoeHidden posted on Vicontrol, but some of the functions do not work properly.

I've seen a similar post in the community before.
It was two years ago, and I recently learned about OSC and have been trying to fix it from there, but it's not working, so I thought I'd ask a question.

Here is the code.

var oscHost = '127.0.0.1';
var oscPort = '8080';
// Variables for Transpose Module
var transposeInterval = 0;
var transposeCopy = false;

module.exports = {
	
    oscInFilter:function(data)
	{
        var {address,args,host,port} = data
	
			if (address === '/transpose') {
				
				console.log( '/control')
	
				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: 'OSCtoDAW' });
						} else {
							sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 0 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'OSCtoDAW' });
						}
						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: 'OSCtoDAW' });
						} else {
							sendOsc({ address: '/control', args: [{ type: 'i', value: 8 }, { type: 'i', value: 12 + transposeInterval }, { type: 'i', value: 127 }], host: 'midi', port: 'OSCtoDAW' });
						}
						break;
	
				}
				return
			}
	
			if (address === '/transposeInterval') {
				transposeInterval = args[0].value;
				new_label = ["m2", "M2", "m3", "M3", "P4", "TT", "P5", "m6", "M6", "m7", "M7", "P8"];
				receive('/EDIT', 'modal_transpose_interval', { type: 's', value: { 'label': new_label[args[0].value] } });
				receive('/modal_transpose_interval', 0);
				return;
			}
	
			if (address === '/transposeClose') { 
				receive('/modal_transpose_interval', 0); 
				return; 
			}
	
			if (address === '/transposeCopy') { transposeCopy = args[0].value; console.log('Transpose Copy = ' + args[0].value); return; }
	
            return {address, args, host, port}
        }
	}
	



I think the code is working, but the message that comes back from OSC when I click on the interval

(DEBUG, OSC) Out: { address: '/transposeInterval', args: [ { type: 's', value: 2 } ] } To: 127.0.0.1:8000

Then, when you press the button to “/transpose up|down”

(DEBUG, OSC) Out: { address: '/transpose', args: [ { type: 'i', value: NaN } ] } To: 127.0.0.1:8000

I get "Nan" and Cubase doesn't even get the message.
The other functions work fine, so I assume that the MIDI device that is OSCtoDAW is well declared.

I apologize for this amateur question,
Could you tell me where the problem is?

I don't understand why you are using oscInFilter, this function is supposed to filter incoming messages, while it seems what you want to do is to filter outgoing messages (sent by widgets), which is what oscOutFilter is for. Are you making open stage control send all osc messages to itself with the server's send option ? If so it's a very bad practice and it should be avoided.

NaN ("Not a Number") is is probably the result of a widget configured to send integers only that tries to send a string: for example, push_transpose_up has typeTags set to i (as in "integers") and on set to up (which is a string), emptying the typeTags property should fix it.

1 Like

I fixed it and now it works!
I thought OSCInfilter is for messages from the Cubase side of other functions. When I thought about it, I was sure that OutFilter was missing.
Thank you very much for your kind help to an amateur.