Old 05-14-2017, 12:00 AM   #1
ljekio
Human being with feelings
 
Join Date: Nov 2009
Posts: 15
Default OSC to MIDI simple script

Hello, Im noob in scripting and almost all examples of scripts for OSCIIbot inaccessible now.
Can I request to help me create simple script what receive one parameter from OSC and translate it to custom MIDI port as CC#100 and midi channel 16?
ljekio is offline   Reply With Quote
Old 05-16-2017, 02:28 AM   #2
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Take a look at the simple "alphatrack.txt" example script bundled with OSCII-bot itself. "sample_script.txt" there should also be helpful. Try them out whilst looking at the associated Midi and OSC traffic in OSCII-bot's console window, or along with a Midi monitor and one can see what they do. Modify these examples one step at a time to gradually become what is wished.


For more complex fully worked script examples that have plenty of explanatory comments see the scripts for the Peavey StudioMix available at http://forum.cockos.com/showpost.php...&postcount=284 or the Akai MIDIMIX at http://forum.cockos.com/showthread.php?t=172908
goldenarpharazon is offline   Reply With Quote
Old 05-16-2017, 10:56 PM   #3
ljekio
Human being with feelings
 
Join Date: Nov 2009
Posts: 15
Default

Thanks, but I did not succeed. I do not know how to write functions correctly to receive the osc parameter that I need.
These examples are too complicated for me, I can not achieve the elementary thing yet.
ljekio is offline   Reply With Quote
Old 05-17-2017, 02:26 AM   #4
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

One needs the correct call to oscmatch(...) in the @oscmsg block of code in the script to detect i.e. match the OSC string and then within oscmatch(...) call the corresponding Midi output.


An example of this can be seen in "alphatrack.txt" where Midi output is done after the "/track/%d/volume" string is detected. The comments in "sample_script.txt" in its oscmatch() also explains how the matching works. The pattern string varieties are set out at http://www.cockos.com/oscii-bot/osci...doc.html#match.


There's also a very simple OSC example here http://forum.cockos.com/showpost.php...7&postcount=75 with hints on how to form different Midi output


What is the OSC string parameter to be detected in your wish, to then go on and create the corresponding matching pattern string for oscmatch(...)?

Last edited by goldenarpharazon; 05-20-2017 at 12:54 PM.
goldenarpharazon is offline   Reply With Quote
Old 05-21-2017, 11:26 PM   #5
ljekio
Human being with feelings
 
Join Date: Nov 2009
Posts: 15
Default

@goldenarpharazon, thank you for your advises.

So, in example wrote this:

Code:
(oscmatch("/track/%d/select"))  && (oscparm(0,0) > 0)?
(
	msg1 = 176;
	msg2 = 0;
	msg3 = fmt0;
	midisend(bcr2000_in);
What is "/track/%d/select"? If I know name of OSC-host and OSC sending parameter, what I must write at this string?

"msg1 = 176" its first byte (CC number), "msg2 = 0" is second byte (channel) and "msg3 = fmt0" is value from oscmatch, right?

MIDI part is clear for me, but not OSC.
ljekio is offline   Reply With Quote
Old 05-22-2017, 03:30 AM   #6
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by ljekio View Post
What is "/track/%d/select"?
%d matches any integer so this will match any string like "/track/1/select" and "/track/2/select" etc.

Quote:
Originally Posted by ljekio View Post
If I know name of OSC-host and OSC sending parameter, what I must write at this string?
In your example, what is the OSC string being sent from TouchOSC and any parameters or variable parts of the string? This string will be visible in the OSCII-bot console window. This will then be used to determine the corresponding matching format string for oscmatch(...)


The way that format strings are written in EEL2 & OSCII-bot scripts is similar to the widely used "C" programming language so this explanation of format strings (for scanf in "C") might also be helpful https://wpollock.com/CPlus/PrintfRef.htm

Quote:
Originally Posted by ljekio View Post
....and "msg3 = fmt0" is value from oscmatch, right?
Yes that is right. Note that using fmt0 is deprecated but it should still work if your example needs to catch a value for use in the Midi output. The other script examples given in the earlier posts contain examples of the current recommended way of catching the matched value.
goldenarpharazon is offline   Reply With Quote
Old 05-22-2017, 09:35 AM   #7
ljekio
Human being with feelings
 
Join Date: Nov 2009
Posts: 15
Default

Quote:
Originally Posted by goldenarpharazon View Post
In your example, what is the OSC string being sent from TouchOSC and any parameters or variable parts of the string? This string will be visible in the OSCII-bot console window. This will then be used to determine the corresponding matching format string for oscmatch(...)
I see osc2bot begin receive my OSC data, but I haven't yet learned how to pass the correct information.

My setup: knob in Reaktor with OSC send module with name "OSC1". Name of host is "REA".

So, I've wrote for test this:

Code:
(oscmatch("/OSC1"))  && (oscparm(0,0) > 0)?
(
	msg1 = 1;
	msg2 = fmt0;
	msg3 = 0;
	midisend(midi_out);
	
	printf("Track %d selected\n");
);
Now, If I turn knob I've see message "Track 0 selected" at osc2bot and midi monitor showing activity BF 01 00 always.

I checked msg1, msg2 & msg3. The first sends the CC number, the second sends the value. The third one does not send anything and data always has a 16 midi channel (BF).
I did not find a way to change the midi channel, but it's not so important now. The main thing is that I could not translate the value of OSC1 to midi value.
ljekio is offline   Reply With Quote
Old 05-22-2017, 12:19 PM   #8
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

OK, so the code appears to be detecting "/OSC1" and is executing the following code block since the printf statement is executed. Great! That's progress!


Suggest all of the following that together may sort it out and get it working

  • Checking that the OSC data coming in looks something like "/OSC1 17" or "/OSC1 123" in the OSCII-bot console since it's those changing integer parameters i.e. 17 and 123 that should be going into fmt0


  • using a properly formatted printf statement that outputs all of msg1, msg2, msg3 together on a debugging line to make sure that

    - fmt0 really has captured a parameter which varies with the OSC data (lots of examples of how to do this printf in code already mentioned)

    and

    - the three bytes together look like they will be proper Midi


  • checking that midisend() will correctly send any pre-set Midi output to the chosen midi output device
goldenarpharazon is offline   Reply With Quote
Old 05-22-2017, 02:49 PM   #9
ljekio
Human being with feelings
 
Join Date: Nov 2009
Posts: 15
Default

Quote:
Originally Posted by goldenarpharazon View Post
Checking that the OSC data coming in looks something like "/OSC1 17" or "/OSC1 123" in the OSCII-bot console since it's those changing integer parameters i.e. 17 and 123 that should be going into fmt0
I can't get value of osc messages. Confused with this.

Quote:
using a properly formatted printf statement that outputs all of msg1, msg2, msg3 together on a debugging line to make sure that
I made debug line.

Quote:
- the three bytes together look like they will be proper Midi
Change of third byte doesn't cause any changes of output. I tried any static value there.


Quote:
checking that midisend() will correctly send any pre-set Midi output to the chosen midi output device
midisend is correct (because midi-ox received midi from that port).
BF 01 00 (control change message #01 with value 0 and midi channel 16).
ljekio is offline   Reply With Quote
Old 05-24-2017, 11:02 AM   #10
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by ljekio View Post
I can't get value of osc messages. Confused with this.
Look at this example of OSC http://forum.cockos.com/showpost.php...&postcount=323 This OSCII-bot console example from OSCII-bot shows the OSC string sent (in this case from Reaper) and the variable parameters.


You should see something similar, but with /OSC1 in the strings in your own console. Posting the console output might help to help?


Probably you are trying to send something like "/OSC1 100" with /OSC1 as the message pattern and say 100 as the variable parameter. It is this combination of message pattern and variable parameter(s) that forms the basis of matching - see this ebook and its subsequent pages for a simple explanation of OSC message formats.

Quote:
Originally Posted by ljekio View Post
Change of third byte doesn't cause any changes of output. I tried any static value there.
This is strange. Code like the example below should just work and send a midi event defined by the integers in the code provided they are small enough fit in a valid and meaningful Midi byte.

Code:
	msg1 = $xBF;  // status byte
	msg2 = 2;     // a value
	msg3 = 3;     // another value
	midisend(midi_out);
However note that this code below may well not work properly if fmt0 is undefined in value if it has never been set to something by oscmatch();

Code:
	msg1 = $xBF;  // status byte
	msg2 = fmt0;  // danger here if fmt0 value is not correct as a byte value
	msg3 = 3;     // another value
	midisend(midi_out);

Last edited by goldenarpharazon; 06-04-2017 at 02:15 AM. Reason: Correct the code examples to have a valid Midi status byte
goldenarpharazon 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 09:13 PM.


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