Old 07-10-2020, 07:22 AM   #1
Florian.S
Human being with feelings
 
Florian.S's Avatar
 
Join Date: Jul 2020
Location: Ger
Posts: 8
Default Reaper OSC to Companion

Hi,

trying to get reaper marker names into companion.
Reaper sends out names like "s/marker/@/name" but labeling a button direkt in companion expects "/style/text/page/button string"

Is there a way to do this.
I'm not getting how OSCII Bot scripts working right now.
My first thought would be something like:

@input DAW_Reaper OSC „localhost:9001“ //9001 osc out port reaper
@output Companion OSC „localhost:12321“ //12321 osc in port companion

@init

@oscmsg
page = 2
mystring = s/marker/@/name
/style/text/page/@/ mystring

Would be nice if somebody could guide me. Thanks.
Florian.S is offline   Reply With Quote
Old 07-11-2020, 01:03 AM   #2
kram0
Human being with feelings
 
Join Date: Mar 2015
Posts: 40
Default

Hi Florian
You just need to catch the OSC command and translate it to what you require.

This example will trigger when the OSC command begins with 's/marker/' and ends with '/name':

oscmatch("s/marker/*/name") ? (
(do something here...);
);



So see if this works as a test. I'm not sure what the exact syntax your device is expecting but have a play with it. When the script is launched it should immediately send "Test String" to "page 1". I hope it makes sense!



@input DAW_Reaper OSC „localhost:9001“ //9001 osc out port reaper
@output Companion OSC „localhost:12321“ //12321 osc in port companion

@init
sendcommand = "/style/text/page/1/";
sendvalue = "Test String";

//The following line sends the OSC command to your device
oscsend(Companion, sendcommand, sendvalue);

@oscmsg
kram0 is offline   Reply With Quote
Old 07-16-2020, 01:14 PM   #3
Florian.S
Human being with feelings
 
Florian.S's Avatar
 
Join Date: Jul 2020
Location: Ger
Posts: 8
Default

Hi kram0,

i only get the following in OSCII-bot

Error listening for '„localhost:9001“'
0 inputs, 0 outputs, 1 bidirectional

Total: 1 scripts, 0 inputs 0 outputs 1 bidirectional

I managed to get the osc massage out when script is loaded.

Only thing i need is to resolve the Error mentioned above and i need to store the string wich contains the name of the marker and the number if this marker so i can push it out to different buttons.

sendstring = ( name of the marker)
sendnumber = ( number of the marker )
sendcommand = " s/style/text/1/sendnumber"

So i could come up with something like

oscmatch("s/marker/*/name") ?
(oscsend(Companion, sendcommand, sendstring));

Sry, but i don't get the syntax of this language. I searched a lot but i don't get the initial spark.
Florian.S is offline   Reply With Quote
Old 07-21-2020, 06:56 AM   #4
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default Getting code going

Florian. There are good code examples to follow in [user] Banned's Peavey Studio Mix (thread and script code) and the Akai MidiMix control surface script and in kram0's control signal routing.

There are also simple but terse code examples included with OSCII-bot that work and can be incrementally extended for a chosen use.

The OSCII-bot code reference web page gives information on string handling but it is not a tutorial.

To make help easier for a specific syntax or functionality questions then please post sufficiently complete & readable OSCII-bot script code using the [code] BB code formatting.
goldenarpharazon is offline   Reply With Quote
Old 08-28-2020, 08:18 AM   #5
Florian.S
Human being with feelings
 
Florian.S's Avatar
 
Join Date: Jul 2020
Location: Ger
Posts: 8
Default

After a lot of try and error i came this far.
My Problem is, that in the part where "lastmarker/number/str" is triggered to get the number of the marker as a string both variables "MarkerName" and "MarkerNr" are overwritten and both have the same value/string. I don't get why this is happening.

Is there a easier way to get the value(name) of a marker than doing it char by char?

Finished output should look like "s/style/text/2/[String of MarkerNr]" and the String out of "MarkerName" should be sended.
I'm able to build the strings via "strcat(#str,"srcstr")"

Thank you guys.

Code:
@input DAW_Reaper OSC „localhost:9001“ //9001 osc out port reaper
@output Companion OSC „localhost:12321“ //12321 osc in port companion

@init
SendCommand = "s/style/text/2/3"; 		//Test Command
SendVal = "Test"; 				//Test String

//The following line sends the OSC command to Companion
oscsend(Companion, SendCommand, SendVal); 	//Test to try connectivity 


@oscmsg /Triggered each time a osc massage is present
oscmatch("/lastmarker/n*",$'s') ? (
oscmatch("/lastmarker/name",$'s') ? (
	x = 0;
	v = 0;
	while(
		fmt0 = oscparm(x,v);
		v == $'s' ? (
		str_offs = 0;
		strcpy(oscparm_val_str, "");
		while(
			fmt0 = oscparm((str_offs<<16) + x, s);
			fmt0 ? str_setlen(oscparm_val_str, str_offs+1);
			str_setchar(oscparm_val_str, str_offs, fmt0);
			str_offs += 1;
			fmt0;
			);
		MarkerName = oscparm_val_str;
		printf("\nMarker1: "); printf(MarkerName);		
		);
	x += 1;
	v;
	);
);

oscmatch("/lastmarker/number/str",$'s') ? (
	x = 0;
	v = 0;
	while(
		fmt0 = oscparm(x,v);
		v == $'s' ? (
		str_offs = 0;
		strcpy(oscparm_val_str, "");
		while(
			fmt0 = oscparm((str_offs<<16) + x, s);
			fmt0 ? str_setlen(oscparm_val_str, str_offs+1);
			str_setchar(oscparm_val_str, str_offs, fmt0);
			str_offs += 1;
			fmt0;
			);
		MarkerNr = oscparm_val_str;
		printf("\nMarker2: "); printf(MarkerNr);
		printf("\nMarker1: "); printf(MarkerName);				
		);
	x += 1;
	v;
	);
);
printf("\n.")					//Print dots to check how often something gets triggered 
);
Florian.S is offline   Reply With Quote
Old 09-01-2020, 07:52 AM   #6
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by Florian.S View Post
both variables "MarkerName" and "MarkerNr" are overwritten and both have the same value/string. I don't get why this is happening.

Is there a easier way to get the value(name) of a marker than doing it char by char?
I think the problem is caused by the lines
Code:
MarkerName = oscparm_val_str; 
...and...
MarkerNr = oscparm_val_str;
where what the code should be doing is using strcpy() rather than an equals = assigment where the = assignment doesn't work for EEL2 strings (except for their initial declaration i.e. first creation).

The code currently overwrites the handle that identifies the string so you don't see the intended output.

This post https://forum.cockos.com/showpost.ph...&postcount=113 may be helpful for the intended string handling along with other items in the thread

Also this editor https://forum.cockos.com/showthread.php?t=142641 will help by using Notepad++ and an EEL2 template to edit the code and especially to keep track of and matching the block start and end brackets like );

To be sure of the code's execution as you develop
1) use a printf freely on every line to make sure key variable and strings have the expected values. This builds confidence and can be commented out when no longer needed.

2) develop difficult or untried or learning code in the @init block to make it easier to see in action and to test or debug, and then move it to @oscmsg when it is OK, to then use varying input data.

Last edited by goldenarpharazon; 09-01-2020 at 08:45 AM. Reason: Made the thread links clearer
goldenarpharazon is offline   Reply With Quote
Old 09-01-2020, 04:06 PM   #7
Florian.S
Human being with feelings
 
Florian.S's Avatar
 
Join Date: Jul 2020
Location: Ger
Posts: 8
Default

Thank you very much.

i'll try strcpy() instead. I'm still trying to figure out how ELL2 is ticking.

Trying new code in the @init block and using printf excessively is already my weapon of choice.
I cleaned the code a bit for not making it more difficult to read and make somebody stumbling across some strange stuff wich was only meant for try and error.
Florian.S is offline   Reply With Quote
Old 10-15-2020, 04:27 AM   #8
Florian.S
Human being with feelings
 
Florian.S's Avatar
 
Join Date: Jul 2020
Location: Ger
Posts: 8
Default

I've managed to get it working.

Probably it is not a good written Script. But maybe someone is willing to help me clean it up and do it "the right" way.
Code:
@input DAW_Reaper OSC „localhost:9001“ //9001 osc out port from reaper
@output Reaper OSC    "127.0.0.1:9000" // 9000 osc in port to reaper
@output Companion OSC „localhost:12321“ //12321 osc in port to companion


@init
//Setup:
send2page2 = "s/style/text/2/";
send2page3 = "s/style/text/3/";
last_t =time;
time_w = 10;
marker_count = 24;
printf("Reaper to Companion Markername transition script");

@oscmsg

oscmatch("/oscii/refresh/",$'s') ? ( 				// If Osc Input String matches "/oscii/refresh/"
	printf("oscii/refresh/");
	oscsend(Reaper, "i/device/marker/count", 0); 		// Setting Marker Count of Reaper to 0
	sleep(1);
	oscsend(Reaper, "i/device/marker/count", marker_count);	// Setting Marker Count of Reaper to specified marker amount. 
);

oscmatch("/marker/*",$'s') ? (	
	strcpy(send2page2, "s/style/text/2/"); 			// Resetting the string of "send2pagexy" for not getting broken later in the script 
	strcpy(send2page3, "s/style/text/3/");
	oscmatch("/marker/*/name",$'s') ? (
	val = null; #string = null;
			oscparm(idx,type);
			type=='s' ? (
				oscparm(0,'s',#string);
				strcpy(#a, #string);
			);
		);

	oscmatch("/marker/*/number/str",$'s') ? (
		val = null; #string = null;
			oscparm(idx,type);
			type=='s' ? (
				oscparm(0,'s',#string);
				strcpy(#b, #string);
			);
			strcat(send2page2,#b);
			strcat(send2page3,#b);
			oscsend(Companion, send2page2, #a);
			oscsend(Companion, send2page3, #a);
		);
	);
@timer
time >= last_t + time_w ? (					// Making Reaper reaper resend the marker names	regularly 					oscsend(Reaper, "i/device/marker/count", 0); 			// Setting Marker Count of Reaper to 0
sleep(1);
oscsend(Reaper, "i/device/marker/count", marker_count);		// // Setting Marker Count of Reaper to specified marker amount. 
last_t += time_w;
);
Florian.S is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.