05-14-2017, 12:00 AM | #1 |
Human being with feelings
Join Date: Nov 2009
Posts: 15
|
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? |
05-16-2017, 02:28 AM | #2 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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 |
05-16-2017, 10:56 PM | #3 |
Human being with feelings
Join Date: Nov 2009
Posts: 15
|
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. |
05-17-2017, 02:26 AM | #4 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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. |
05-21-2017, 11:26 PM | #5 |
Human being with feelings
Join Date: Nov 2009
Posts: 15
|
@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); "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. |
05-22-2017, 03:30 AM | #6 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
%d matches any integer so this will match any string like "/track/1/select" and "/track/2/select" etc.
Quote:
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 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. |
|
05-22-2017, 09:35 AM | #7 | |
Human being with feelings
Join Date: Nov 2009
Posts: 15
|
Quote:
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"); ); 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. |
|
05-22-2017, 12:19 PM | #8 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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
|
05-22-2017, 02:49 PM | #9 | ||||
Human being with feelings
Join Date: Nov 2009
Posts: 15
|
Quote:
Quote:
Quote:
Quote:
BF 01 00 (control change message #01 with value 0 and midi channel 16). |
||||
05-24-2017, 11:02 AM | #10 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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:
Code:
msg1 = $xBF; // status byte msg2 = 2; // a value msg3 = 3; // another value midisend(midi_out); 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 |
|
Thread Tools | |
Display Modes | |
|
|