OSC receive to change rack spaces via reaper region numbers

Hi,

I am new with GPscripting too , so pleeease be gentle with me.

I am simply trying to receive OSC command strings from reaper ( laptop windows machine ) to my
GP live keys machine.
So simply put, allowing switching of rack spaces via OSC .
I could not see in forum about how to do this , so I created a new thread.
I apologise if there is such info and I missed it .

First a little about the reaper OSC output and monitoring ( for correctness )
Ok , reaper is set up to send OSC commands , with an edited file.ReaperOSC
I deleted all default commands from the default file and created a simple file to only send one thing ,
which is the following:
LAST_REGION_NUMBER s/lastregion/number

I edited the ‘/’ out as GP script might have trouble reading this in the receiver.

so it looks only like :
LAST_REGION_NUMBER s/lastregionnumber

( FYI… the capital letters are reapers identifier command to send region number X when the cursor passes of that region number out to OSC land . )

Repaer now will send out ‘lastregionnumber’ with an integer attached to it

So the purpose here, is to use 16 regions , with each song set to a region. Useful for a live set list of songs.
I wrote a script in python ( on a seperate raspberry pi unit ) to receive OSC script commands to receive this reaper OSC command.
With the dispatching map set to read in the specific incoming OSC string of , ‘lastregionnumber’.

So this generates the integer value of 3 in my python script, perfect ! ( when region 3 is played that is )
It send these values , and is exactly what I need.
Keeping in mind, I can send multiple OSC commands / ports / IPs from reaper from the region marker command .

So, how can I receive this same command in GP ?
I only want to change rack spaces according to the integer number i receive.
lastregionnumber/1 = rack space 1
lastregionnumber/2 = rack space 2
lastregionnumber/3 = rack space 3
lastregionnumber/4 = rack space 4 and so on…

( 16 rack spaces allocated to each region number )

I am looking at the OSCMessageReceived (m: OSCMessage)

It just does not quite make sense to me yet. The docs have confused me a bit more. lol
Can anyone suggest a push in right direction ?

Are you on Mac?

Hi Pianopaul,
The GP machine is a windows pro 10 machine version 20H2,
The reaper machine is a windows 7 machine,
The OSC monitor is a raspberry pi 3B+,
The version of GP is 3.8.1,
The version of reaper is 5.9.6,
The switch is a D-link , 1 G ,
I think that should cover the set up. :wink:
Cheers

Ok let ne think.
Can cou configure the osc messages sent den Reaper?

I don’t use OSC a lot, so bear that in mind.
However I was able to get GP to detect the lastregion messages from Reaper. I did not edit Reaper’s Default.ReaperOSC file at all.

This was just with Reaper and GP on my laptop. So after setting the IP/Ports, this script was extracting the region number (as a string).

// Called when a specific osc message is received
On OSCMessageReceived(m : OSCMessage) Matching "/lastregion/number/str"
    Var region : string
    region = OSC_GetArgAsString(m, 0)
    Print("Region " + region)
    If region == "1" Then SwitchToRack(0,0)
        elsif region == "2" Then SwitchToRack(1,0)
        elsif region == "3" Then SwitchToRack(2,0)
        // Extend for additional rackspaces as required.
    End
End

I needed to use an if/then/else to check the region number and switch rackspaces, as I don’t know of another way to convert the OSC string to an integer directly.
The cumbersome thing is that the script would need to exist on all rackspaces.

1 Like

It also works well using Markers to indicate when to move to the next Variation (if you use them). A similar approach could be used to move through songs/song parts.

// Called when a specific osc message is received
On OSCMessageReceived(m : OSCMessage) Matching "/lastmarker/number/str"
   SwitchToNextVariation()
End

Ah ok , I am starting to get it, will try this.
One thing I did see is , command ’ GetArgAsInteger ( )’
i wopuld assume this would convert the string argument into an integer value instead
??

I know about the OSC set up page, and edited in the 'Show script editor ’
Is there any other tricks that I need to know ?

Reaper is not the issue, I am runnning OSC out of reaper without any dramas, just the GP end I am still trying to figure out.

I tried GetArgAsInteger() but it didn’t work. I assume it comes through with quotes or something (not sure). It wasn’t too much of a pain to do the if/then/else, so I didn’t bother looking into it further.

I did attempt to modify the ReaperOSC file to change lastregion to send an integer (following the format I saw for other integer parameters) but it didn’t work. So maybe if you want to communicate directly from Reaper to GP, put the lastregion syntax in the file back to the original?

My Reaper settings:

My GP settings:

@ rank13, just curious, how does the script you write, get associated to any of the rack spaces ?
I know this may seem obvious to you , but scratching my head here

Each rackspace has it’s own script. So if you change rackspaces and open the script editor again, it will initially be blank. You would need to do this for each rackspace and paste in the same script.

I am curious why the integer command does not work, but anyways, this is fine
// Called when a specific osc message is received
On OSCMessageReceived(m : OSCMessage) Matching "/lastregionnumber"
    Var region : string
    region = OSC_GetArgAsString(m, 0)
    If region == "1" Then SwitchToRack(0,0)
        elsif region == "2" Then SwitchToRack(1,0)
    End
End

Thanks a million rank13 !!!
Going to try all these other commands too !!

1 Like

Now I completely understand your frustration Rank13 .
Copying each script inside each rackspace.
Yes, a bit of a pain in butt ! But i can live with that ! ( copy & paste here we go… )

Maybe there should be a global script to affect all rackspaces. Mmmmm

Yes, that would definitely make this much easier to manage!

I didn’t implement this for stuff coming in as strings as I was concerned about efficiency and the risk that the incoming string wasn’t actually containing an integer value. I guess I could add this for the next release

Would a more general StringToInt() be a more flexible option?

To chime in:
Found this
To use an OSC device for more than basic action shortcuts and FX parameter learn, you will need to configure either REAPER or the device to define the OSC messages that will be used for communication.

"The pattern config file (.ReaperOSC) is how REAPER defines the OSC messages it understands. In order to use REAPER with any OSC device, you can either create a custom pattern config file so that REAPER sends and receives messages the OSC device understands, or configure the OSC device to send and receive messages that REAPER understands, or both.

To open the default pattern config file folder, select “open config directory” under “pattern config” in the OSC control surface settings dialog. The best way to create a new pattern config is to make a copy of the included Default.ReaperOSC file, rename the copy, and change the patterns defined in the file. Please see the extensive comments in Default.ReaperOSC for more detail about how messages are formed, and what the messages mean. "

This way is seems to be possible to define the OSC messages Repaper should send.
Gig Performer reacts on specific OSC Messages to switch rackspaces.
Why not set that message in Reaper - no scripting necessary.

What do you think about?

This function was intended to convert a floating point number. Note that OSC arguments are “typed”. I don’t know anything about Reaper but I’m surprised you can’t get it to send out an OSC message with an integer value rather than a string value.

In any case, for a future version, we’ll improve GetArgAsInteger to handle incoming string values and we’ll also provide a StringToInt function

1 Like

Another option could by GlovePie (Similar to OSCULATOR on Mac).

Maybe it is possible to send OSC messages from Reaper to GlovePie and then replace the messages by the messages Gig Performer recognizes.