Go Back   Cockos Incorporated Forums > REAPER Forums > MIDI Hardware, Control Surfaces, and OSC

Reply
 
Thread Tools Display Modes
Old 05-12-2020, 03:30 PM   #1
jasoncrystal
Human being with feelings
 
Join Date: Jul 2015
Posts: 14
Default Triggering a ReaScript with OSC with parameters

Hello all!

I've written a functional ReaScript (Python, but irrelevant).

I'd like to:

1. Trigger the script to run as a result of a MIDI or OSC trigger.

2. Have the script incorporate a variable (incoming parameter). That parameter could be part of the OSC string, or perhaps the velocity on a MIDI note.

How can I get parameters into a ReaScript when it's called?

Thanks!

-Jason
jasoncrystal is offline   Reply With Quote
Old 05-20-2020, 11:14 PM   #2
pljones
Human being with feelings
 
pljones's Avatar
 
Join Date: Aug 2007
Location: London, UK
Posts: 767
Default

See
https://forum.cockos.com/showthread.php?t=202734
for what I did.
__________________
Quote:
Originally Posted by Tony Williams
...Playing fast around the drums is one thing. But to play with people for others, to listen to, that's something else. That's a whole other world.
pljones is online now   Reply With Quote
Old 05-21-2020, 03:40 AM   #3
jasoncrystal
Human being with feelings
 
Join Date: Jul 2015
Posts: 14
Default

Creative! Thanks!

I ended up including a MySQL connector in my Python script, which finds out "what to do" based on database values. Slightly hacky, but works consistently.
jasoncrystal is offline   Reply With Quote
Old 05-21-2020, 05:33 AM   #4
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
Default

Regarding Midi, a script can be triggered by a CC#/Channel combination and read the CC value. I suppose for OSC something similar holds.
-Michael
mschnell is offline   Reply With Quote
Old 05-21-2020, 07:04 AM   #5
jasoncrystal
Human being with feelings
 
Join Date: Jul 2015
Posts: 14
Default

Thanks mschnel. The script-triggering is no problem. My challenge is passing variables TO the script at the time of execution.

e.g. "Trigger this script, but this time, let n = 10", or whatever.
jasoncrystal is offline   Reply With Quote
Old 12-14-2022, 10:46 AM   #6
John Allsup
Human being with feelings
 
Join Date: Apr 2010
Posts: 59
Default

What I'm after, and I think the thread above is about, is that if I send e.g.
/do/something/with 45 5.6 "hello"
as an OSC message to reaper, with /do/something/with bound to a .lua reascript,

how does my script access the 45 5.6 "hello" parameters in the OSC message?
__________________
John
John Allsup is offline   Reply With Quote
Old 12-15-2022, 11:37 AM   #7
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
Default

AFAIU, a very recent version of Reaper's in fact did implement fetching OSC parameters (similar to Midi CC parameters, which always worked) by a script using the get_action_context() API.

I did not yet check this, so please let us know what you find.

-Michael

Last edited by mschnell; 12-15-2022 at 11:45 AM.
mschnell is offline   Reply With Quote
Old 01-06-2024, 07:54 AM   #8
John Allsup
Human being with feelings
 
Join Date: Apr 2010
Posts: 59
Default

Thanks. Yes, contextstr returns the parameter. But you can only send one parameter this way. If you want to send more, you have to send something as a string, and parse it inside Lua. For example you can send

/hello/world "1,2,3"

But you can't send an OSC message with three parameters. Also you must send numbers as floats (reaper discards integers).

Anyway, it's a little better knowing this. Having arbitrary parameters as a Lua table would of course be nicer.
__________________
John
John Allsup is offline   Reply With Quote
Old 01-08-2024, 11:02 AM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
Default

Thanks for testing this !
mschnell 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 06:14 AM.


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