Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Pre-Release Discussion

Reply
 
Thread Tools Display Modes
Old 02-19-2015, 02:32 AM   #1
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default Getting any incoming MIDI/OSC messages in ReaScript?

Is it right that it's not possible to get any information about MIDI/OSC messages arriving into Reaper in ReaScript unless the script has been assigned to be started from a MIDI or OSC message? And even if a script action has been assigned a MIDI or OSC message, it seems the get_action_context API only returns the message values relating to that particular message...

This seems like a needless limitation which still prevents creating custom MIDI/OSC mapping solutions inside Reaper itself. (I know Osciibot exists but it's not the most convenient solution, being an external application, the scripting based on Eel and so on...)

So, I'd like to be able to write ReaScripts that can receive and handle any MIDI or OSC messages coming into Reaper. But currently this does not seem to be possible unless I am missing some way which doesn't involve writing a C++ extension plugin.
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 02-19-2015, 03:30 AM   #2
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Xenakios View Post
Is it right that it's not possible to get any information about MIDI/OSC messages arriving into Reaper in ReaScript unless the script has been assigned to be started from a MIDI or OSC message? And even if a script action has been assigned a MIDI or OSC message, it seems the get_action_context API only returns the message values relating to that particular message...
Yes, I think that's more or less correct - it's actually even slightly worse: get_action_context can not get all message values: it can't receive strings, nor can it receive messages with multiple values. And then there's the fact that REAPER converts the values to 14-bit integer values, so you can't even get float values at their full resolution. All in all, it's really not very useful to me at all as it currently stands.
Quote:
Originally Posted by Xenakios View Post
This seems like a needless limitation which still prevents creating custom MIDI/OSC mapping solutions inside Reaper itself. (I know Osciibot exists but it's not the most convenient solution, being an external application, the scripting based on Eel and so on...)

So, I'd like to be able to write ReaScripts that can receive and handle any MIDI or OSC messages coming into Reaper. But currently this does not seem to be possible unless I am missing some way which doesn't involve writing a C++ extension plugin.
+1. Being able to use ReaScript with OSC I/O would sure have one major advantage over using OSCII-bot: the ability to use REAPER's API functions.

But I'm not sure if that would be ideal for creating custom MIDI/OSC mapping solutions inside Reaper itself either; OSCII-bot coupled with an OSC Control Surface setup may still be better suited for creating custom MIDI/OSC mapping solutions for large numbers of parameters that support high resolution and provide feedback.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 02-19-2015, 06:28 AM   #3
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 417
Default

Quote:
Originally Posted by Banned View Post
All in all, it's really not very useful to me at all as it currently stands.
Absolutely agree with this.

I got really excited when get_action_context() first made it's appearance but that excitement quickly faded when I discovered that an incoming OSC message could only be assigned to one variable for practical purposes that is. I mean if you had a bunch of variables that where of the bool variety or their value range was small, then you could control multiple variables by splitting the incoming message into ranges. However if a person has a script that has multiple variables that each require a float range of 0.0-1.0 then it just won't work.

I do recall Justin mentioning when OSCII-bot was first being developed that he might look at incorporating it natively into REAPER, so let's keep our collective fingers crossed.

With the power that ReaScript provides just now starting to be realized by all the wonderful scripts popping up, I think now would be a good time for the devs to look into a solution.

Last edited by NextLevel; 02-19-2015 at 07:22 AM.
NextLevel is offline   Reply With Quote
Old 02-19-2015, 01:10 PM   #4
Teddy
Human being with feelings
 
Join Date: Sep 2011
Posts: 198
Default

You are correct, Xenakios. And it would be great to have OSC i/o in reascript that isn't limited the way get_action_context is.
Teddy is offline   Reply With Quote
Old 02-19-2015, 03:22 PM   #5
vinx
Human being with feelings
 
Join Date: May 2007
Location: France
Posts: 727
Default

+1
We need some more osc power.
vinx is offline   Reply With Quote
Old 02-27-2015, 03:27 AM   #6
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Looks like there's a misunderstanding here...

The new function get_action_context() just allows you making your own "OSC/MIDI CC" actions, I mean just like the native (or SWS) ones you can see in the action list, with exactly the same accuracy, resolution, relative modes support, etc.
Also, it gives you a way to fix scripts bound to continuous controllers (because you don't have the choice sometimes) that were unusable in v4: REAPER stuck while moving the controller.

Things can be improved in the future, of course, but these new features are not meant to replace an OSC client/server or process MIDI feeds. OSCII-bot, JSFX are the way to go ATM. Integrating ~OSCII-bot would be nice
Jeffos is offline   Reply With Quote
Old 02-27-2015, 06:09 PM   #7
Ozymandias
Human being with feelings
 
Join Date: Apr 2011
Posts: 144
Default

Quote:
Originally Posted by Jeffos View Post
OSCII-bot, JSFX are the way to go ATM.
Using the tcp_recv/tcp_listen/etc. functions, do you mean? I wish there was a simple script example showing how to go about that... I didn't get very far with them.
Ozymandias is offline   Reply With Quote
Old 02-27-2015, 07:31 PM   #8
NextLevel
Human being with feelings
 
Join Date: Dec 2014
Posts: 417
Default

Quote:
Originally Posted by Ozymandias View Post
Using the tcp_recv/tcp_listen/etc. functions, do you mean? I wish there was a simple script example showing how to go about that... I didn't get very far with them.
Same here, if anyone has an example, please post.
NextLevel is offline   Reply With Quote
Old 03-05-2015, 03:45 PM   #9
tomotello
Human being with feelings
 
Join Date: Feb 2012
Posts: 4
Default

Quote:
Originally Posted by NextLevel View Post
Same here, if anyone has an example, please post.
Might be my use case goes into the same direction?

I'm actually trying to reverse engineer MM4 - Midi Maestro's unique transport control features (Cue to cue performance with support for vamps, caesuras, fermatas, skips and cola voce sections - where the conductor follows a soloist) see: http://www.midimaestro.com/2.html
Such type of transport controls for ad libitum passages are not only useful for classical/opera back track creations but for any type of teather, broadcast live productions (Samplitude/Sequoia has this as cue mode, resp. formerly O-Tone feature)

Currently I'm trying to achieve this with protoplug lua scripting VSTi ( http://www.osar.fr/protoplug/ )
Reaper transport could than be controlled indirectly from the protoplug instrument plugin via Midi CC's sent to Reaper and managed by an action script (preferrably lua in my case).

However, might be there are or will be features with the Reaper integrated scripting for consuming Midi input streams on a track and drive Reaper dynamically for live performances?
With lua it would open a new world of interactive capabilities, for example using a Myo Armband with the Lua Myo SDK to conduct Reaper interactivly by hand movements ( https://developer.thalmic.com/docs/a...g-started.html )

Last edited by tomotello; 03-05-2015 at 03:50 PM.
tomotello is offline   Reply With Quote
Old 03-05-2015, 10:44 PM   #10
Melvin J.
Human being with feelings
 
Melvin J.'s Avatar
 
Join Date: Apr 2010
Location: South West Michigan
Posts: 256
Default

Wow, Tomatello. That sounds really awesome. Really interesting ideas.
__________________
ADK Laptop Intel i7 2860QM, 8 GB RAM, Avid MBOX Pro 3 (BLA Modified), Novation Remote SL37, DSI Mopho, DSI Tempest, Trilian, Aether 1.5.1, Valhalla, Nerve, Komplete 7
Melvin J. is offline   Reply With Quote
Old 03-06-2015, 11:43 AM   #11
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Jeffos View Post
The new function get_action_context() just allows you making your own "OSC/MIDI CC" actions, I mean just like the native (or SWS) ones you can see in the action list, with exactly the same accuracy, resolution, relative modes support, etc.
Well, to be honest, imho it doesn't even suffice for that simple task, because the accuracy / resolution seems to be seriously frustrated by rounding issues.

If you use e.g. OSCII-bot to send 14-bit values as float values (as happens, for example, in 'our' MIDI2OSC-II script), the float values get truncated to 6 fractional digits. Normally, I would figure this to be sufficient for transmitting a 14-bit value, but that doesn't seem to be the case here. To get REAPER to respond as expected, I have to do something like adding 0.5 to the integer 14-bit value before dividing it by 16383. For example, in the linked script, this line:
Code:
oscsend(destdevice, osc_ccpair, buf[idx]/div14bit);
would have to be changed to something like this:
Code:
oscsend(destdevice, osc_ccpair, (buf[idx]+0.5)/div14bit);
If you would simply send the 14-bit value divided by 16383, the results that get_action_context() gives are not accurate enough:





Given these results, it seems to me that REAPER should really round off values better than it currently does when converting float values to a 14-bit integer range, rather than having OSC clients jump through hoops.

More fundamentally, while 14-bit resolution may be sufficient for most use cases, I really don't like the fact that REAPER converts floating point values to a lower resolution. I'd *much* rather just get the float value as is, without converting it to 14-bit integer range (it's easy enough to do that in a script yourself, where needed).

And even more fundamentally, to trigger an action using MIDI CC#s with 14-bit resolution, it seems *incredibly* convoluted that we have to convert 14-bit MIDI to OSC floating point format first, using external tools like OSCII-bot. Why not simply allow 'learned' bindings to use 14-bit MIDI?
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 03-06-2015, 11:50 AM   #12
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by tomotello View Post
Might be my use case goes into the same direction?

I'm actually trying to reverse engineer MM4 - Midi Maestro's unique transport control features (Cue to cue performance with support for vamps, caesuras, fermatas, skips and cola voce sections - where the conductor follows a soloist) see: http://www.midimaestro.com/2.html
Such type of transport controls for ad libitum passages are not only useful for classical/opera back track creations but for any type of teather, broadcast live productions (Samplitude/Sequoia has this as cue mode, resp. formerly O-Tone feature)

Currently I'm trying to achieve this with protoplug lua scripting VSTi ( http://www.osar.fr/protoplug/ )
Reaper transport could than be controlled indirectly from the protoplug instrument plugin via Midi CC's sent to Reaper and managed by an action script (preferrably lua in my case).

However, might be there are or will be features with the Reaper integrated scripting for consuming Midi input streams on a track and drive Reaper dynamically for live performances?
With lua it would open a new world of interactive capabilities, for example using a Myo Armband with the Lua Myo SDK to conduct Reaper interactivly by hand movements ( https://developer.thalmic.com/docs/a...g-started.html )
Sounds like a cool project indeed! However, I would warn you that controlling REAPER's tempo 'live' is bound to fail miserably, courtesy of some (apparently quite fundamental) design flaws in REAPER's sequencing features (see here).
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 03-06-2015, 02:16 PM   #13
Claudiohbsantos
Human being with feelings
 
Join Date: Aug 2014
Location: New York
Posts: 135
Default

Better reascript options for midi controllers would definitely be useful, even if without feedback on a first moment. I have been using a BCF2000 pretty much purely as an action controller, but being able to write my own scripts for it would turn it into a very powerful time saving tool.
__________________
My Reapack Repo - Reapack Extension
Claudiohbsantos is offline   Reply With Quote
Old 03-06-2015, 02:31 PM   #14
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

Quote:
Originally Posted by Jeffos View Post
OSCII-bot, JSFX are the way to go ATM.
Well, I suspected as much. Too bad. Either can't access the Reaper API and I am not sure if a C++ extension plugin could do anything with those together with ReaScript, either.

(Obviously I know that a custom C++ extension plugin to deal with MIDI and OSC messages could be written, but that is the kind of stuff I wouldn't want to use C++ for. My interest is not in coding fixed support for some particular controller device, but rather to be able to experiment with remote control devices mapping, even during live performances...And I'd like to be able to access everything in Reaper : track/item properties, envelopes, actions etc...)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 03-10-2015, 03:36 AM   #15
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Quote:
Originally Posted by Banned View Post
If you use e.g. OSCII-bot to send 14-bit values as float values (as happens, for example, in 'our' MIDI2OSC-II script), the float values get truncated to 6 fractional digits.
That's true, of course, but can you honestly make a 0.000001 movement by hand on, say, an ipad?
^ THAT is the main use-case for "MIDI CC/OSC" actions, and this resolution was good enough in my own experience but, yeah... may be not for some more advanced/programmatic use-cases (like a bot sending OSC messages).

EDIT: oops, scratch that ^ I misunderstood your post, looks like there's something to improve here, indeed!

About your "fundamental" remarks: just for the record, REAPER can handle better resolutions internally, of course... Again, this 14-bit resolution only applies to *action learn* (not to fx param etc). I totally agree with the need of "direct 14-bit learn" though -- if I was about about to post something I shouldn't post, I'd say "I'm confident it should happen at some point in the future"

Quote:
Originally Posted by tomotello View Post
However, might be there are or will be features with the Reaper integrated scripting for consuming Midi input streams on a track and drive Reaper dynamically for live performances?
That's exactly why I made MIDItoReaControlPath (to control REAPER from MIDI feeds, for live performances too!).

Tech. details: this plugin is very safe because it ensures everything is performed from the main thread (vs MIDI being processed in the audio thread) but at the cost of latency: up to ~30ms in the worst case. So, for live perf., it should good enough most of the time, e.g. to bypass plugins live, switch MIDI channels/intruments, etc but it is not sample accurate (and that's why it isn't bundled with REAPER -- just in case you wonder why!).

Quote:
Originally Posted by Claudiohbsantos View Post
Better reascript options for midi controllers would definitely be useful, even if without feedback on a first moment. I have been using a BCF2000 pretty much purely as an action controller, but being able to write my own scripts for it would turn it into a very powerful time saving tool.
Unless I misunderstand, this is exactly the kind of thing you can do now: write your own BCR "MIDI/OSC" scripts using get_action_context().

Last edited by Jeffos; 03-10-2015 at 04:20 AM. Reason: scratch that!
Jeffos is offline   Reply With Quote
Old 03-10-2015, 04:39 AM   #16
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Jeffos View Post
That's true, of course, but can you honestly make a 0.000001 movement by hand on, say, an ipad?
^ THAT is the main use-case for "MIDI CC/OSC" actions, and this resolution was good enough in my own experience but, yeah... may be not for some more advanced/programmatic use-cases (like a bot sending OSC messages).
Well, yes, I actually can do that - it depends entirely on what parameter value range is used (which could e.g. be restricted to 0-0.000001), and how the GUI is configured (e.g. circular movement has *much* more precision than horizontal and/or vertical movement). But I would typically use the OSC Control Surface feature if I want to send OSC to REAPER.

My point isn't so much about needing better resolution from OSCII-bot, as it is about get_action_context() failing to support 14-bit MIDI input in this (convoluted) manner - and it is *very* easy to increment/decrement e.g. a rotary encoder on a BCR-2000 by 1. It's simply quite frustrating to see get_action_context()'s conversion to 14-bit is off by one in so many cases, and I would guess that almost every user trying to use this function is going to fall into this trap. So, even though this inaccuracy can be prevented on the client's end, I think it would be much better if get_action_context() would round off values better in its conversion from float to 14-bit integer.
Quote:
Originally Posted by Jeffos View Post
About your "fundamental" remarks: just for the record, REAPER can handle better resolutions internally, of course... Again, this 14-bit resolution only applies to *action learn* (not to fx param etc). I totally agree with the need of "direct 14-bit learn" though -- if I was about about to post something I shouldn't post, I'd say "I'm confident it should happen at some point in the future"
That's good to hear, even if you didn't say it! I hope you feel similar about the need for feedback for 'learned' MIDI bindings?
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 03-10-2015, 04:53 AM   #17
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Quote:
Originally Posted by Jeffos View Post
Unless I misunderstand, this is exactly the kind of thing you can do now: write your own BCR "MIDI/OSC" scripts using get_action_context().
Well, yes, but if I understand correctly, you would have to write a separate script for every single control element. I would need to make over 100 scripts for just one BCR-2000 *preset* and bind these scripts to their corresponding individual control elements, which means that it would be a complete PITA to manage, and very cumbersome (if at all possible) to implement 'global' functions (e.g. use one button as a modifier to change the function of several other control elements).

And then you still don't get feedback - so what Claudio suggests is something that I definitely would (and actually do) use OSCII-bot for, much rather than get_action_context().

@Claudio: have you tried this approach using OSCII-bot already? I'd be happy to show you how to do this sort of thing.
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 03-10-2015, 05:55 AM   #18
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Quote:
Originally Posted by Banned View Post
My point isn't so much about needing better resolution
May be you didn't see my "EDIT" but, yes, I totally misunderstood your post... Fixing, thanks for the report!
Jeffos is offline   Reply With Quote
Old 03-10-2015, 06:01 AM   #19
Banned
Human being with feelings
 
Banned's Avatar
 
Join Date: Mar 2008
Location: Unwired (probably in the proximity of Amsterdam)
Posts: 4,868
Default

Yeah, I hadn't seen your edit when I replied. Thanks in advance for fixing!
__________________
˙lɐd 'ʎɐʍ ƃuoɹʍ ǝɥʇ ǝɔıʌǝp ʇɐɥʇ ƃuıploɥ ǝɹ,noʎ
Banned is offline   Reply With Quote
Old 03-10-2015, 06:21 PM   #20
Claudiohbsantos
Human being with feelings
 
Join Date: Aug 2014
Location: New York
Posts: 135
Default

Quote:
Originally Posted by Jeffos View Post
Unless I misunderstand, this is exactly the kind of thing you can do now: write your own BCR "MIDI/OSC" scripts using get_action_context().
Ops, I will be honest and admit that when I posted I had just about started to check the API on the pre-release and had so far failed miserably in getting the function to work. On that note, thanks for this already, great addition since Reaper 4!

Quote:
Originally Posted by Banned
@Claudio: have you tried this approach using OSCII-bot already? I'd be happy to show you how to do this sort of thing.
I hadn't actually heard of OSCII-bot before this thread, but now I'll definitely check it out. And thanks for the offer, I might come for help once everything starts to go wrong.
__________________
My Reapack Repo - Reapack Extension
Claudiohbsantos is offline   Reply With Quote
Old 05-19-2015, 12:10 PM   #21
RuudErmers
Human being with feelings
 
Join Date: May 2015
Posts: 8
Default

Quote:
Originally Posted by NextLevel View Post
Same here, if anyone has an example, please post.
I made an example last week. The code is below.
Note that it is pretty ugly. It was the first or second day I played with Reaper and EEL is not so well documented, especially for beginners.
(I am still quite puzzled on some things like space for buffers...)
However, the example code works / worked with a server application (Delphi) I also wrote myself with a simple protocol. Note that you always have to define some protocol in Networking, so to get everything working together sometimes is pretty painful. Anyway, if you're really interested in diving deeper in the code you can do so and if you have questions...let me know.

(BTW maybe this has allready been discussed before. As said, I am new to this, and all forums together with JSFX, SWS, OSC, etcetera, etcetera are pretty overwhelming!

The programs sends the program number of track 0 as string when the program changes. It reacts on the command
PRG~17# and changes to preset 17 on track 0 if that is received.
Note that the ~ and # are delimiters and are not optional!

Socket connection is on port 1200 on localhost.

Here's the code!

prg=0;
connection = 0;

function ToConsole(s)
(
(1) ? (
ShowConsoleMsg(s);
);
);

function checkConnection()
(
(connection == 0) ? (
connection = tcp_connect("127.0.0.1",1200,0); // non blocking connection
);
);

function sendString(s)
(
checkConnection();
(connection>0) ? (
ToConsole("send");
tcp_send(connection,s);
(tcp_send(connection,"#") <= 0) ? ( connection = 0; );
);
);

receiveBuffer = "";

function receiveString() local(s,i,l,c)
(
checkConnection();
(connection>0) ? (
bytes = tcp_recv(connection,s); // ? -> s must not have a value before this
(bytes>0) ? receiveBuffer = sprintf(#,"%s%s",receiveBuffer,s);
);
i = 0;
l = strlen(receiveBuffer);
while(i<l)
( c = str_getchar(receiveBuffer,i);
(c == '#') ?
( s = strncpy(#,receiveBuffer,i);
receiveBuffer = strcpy_from(#,receiveBuffer,i+1);
i=l;
);
i=i+1;
);
s; // this is the return value, I think
);

function atoi(s) local(c,i,l,tot)
(
l = strlen(s);
(l>4) ? l=4;
tot=0;
i=0;
while (i<l)
(
c=str_getchar(s,i);
(c>='0' && c <='9') ? tot = 10*tot+c - '0';
i+=1;
);
tot;
);


function parseString(s,arg) local(i,l,s,c,pstart,pend,argc)
(
i=0;
l = strlen(s);
argc = 0;
arg[0]=0;
while (i<l)
( c = str_getchar(s,i);
(c == '~') ?
(
t = strcpy_substr(#,s,0,i);
(argc==0) ? (strcpy(sarg,t)) : (arg[argc-1]=atoi(t));
s = strcpy_from(#,s,i+1);
l = strlen(s);
i=0;
argc=argc+1;
) : i+=1;
);
(argc==0) ? (strcpy(sarg,s)) : (arg[argc-1]=atoi(s));
sarg;
);

function setProgram(prgm, dummy)
(
TrackFX_SetPresetByIndex(GetTrack(0,0),0,prgm);
);

function checkCommand()
(
checkConnection();
(connection>0) ? (
s=receiveString();
(strcmp(s,"") !=0) ?
(
s=parseString(s,arg);
(strcmp(s,"PRG")==0) ? ( setProgram(arg[0],arg[1]); );
)
);
);

function checkPrgChanges()
(
prgNew = TrackFX_GetPresetIndex(GetTrack(0,0),0,#dum);
(prg != prgNew) ?
(
prg= prgNew;
ToConsole("change");
sendString(sprintf(#, "%d", prg));
);
);

function setup()
(
checkConnection();
);

function loop()
(
checkPrgChanges();
checkCommand();
);

////////////////////////////////////////////////////////////////////////


function _loop()
(
loop();
defer("_loop()");
);

function main()
(
ToConsole("");
setup();
_loop();
);

main();
RuudErmers is offline   Reply With Quote
Old 05-22-2015, 10:13 AM   #22
Teddy
Human being with feelings
 
Join Date: Sep 2011
Posts: 198
Default

Great effort, Ruud. I'm doing something similar as well...
Teddy is offline   Reply With Quote
Old 05-23-2015, 02:16 PM   #23
RuudErmers
Human being with feelings
 
Join Date: May 2015
Posts: 8
Default Tcp Example now complete

Hi , a few days ago I mentioned I wrote an TCP example (with some ugly code)
I have updated it into a complete example, with a Delphi server (included as .exe) and Reaper client (as Reascript).
I will tune it the coming days (because I need it for myself), but if you're interested just get a peek at:

https://github.com/RuudErmers/JSFXReaScriptBridge
RuudErmers is offline   Reply With Quote
Old 09-18-2021, 03:05 PM   #24
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

Thanks Ruud!!

MIDI and OSC into reascript would be really good natively +1 (4)!
daniellumertz is online now   Reply With Quote
Old 10-24-2021, 06:10 AM   #25
binbinhfr
Human being with feelings
 
binbinhfr's Avatar
 
Join Date: Oct 2021
Location: France
Posts: 363
Default

Quote:
Originally Posted by daniellumertz View Post
MIDI and OSC into reascript would be really good natively!
oh yes !!! +1 +1 +1
__________________
Reaper's lunatic
Reapack repository / GitHub / SoundCloud / Donate
binbinhfr is offline   Reply With Quote
Old 10-24-2021, 07:52 AM   #26
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

Ok this thread is a little old And needs a update for the recent events

It is in the dev version now (and maybe soon at a stable version) this function :

reaper.MIDI_GetRecentInputEvent(idx)

With it you can get midi.
More info at https://forums.cockos.com/showthread.php?t=258544

Still no way to get osc tho
daniellumertz is online now   Reply With Quote
Old 10-25-2021, 02:21 PM   #27
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

Please update my knowlage !

You always could receive "Midi events" (i.e. Messages generated by Midi events) on the Control Channel in Reascript, as they fire the script and parameters can be obtained by get_action_context().
OSC generates Control Channel Messages also can trigger scripts, but I was not able to get parameters from OSC messages,

-Michael
mschnell is offline   Reply With Quote
Old 03-22-2024, 03:10 PM   #28
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by mschnell View Post
Please update my knowlage !

You always could receive "Midi events" (i.e. Messages generated by Midi events) on the Control Channel in Reascript, as they fire the script and parameters can be obtained by get_action_context().
OSC generates Control Channel Messages also can trigger scripts, but I was not able to get parameters from OSC messages,

-Michael
How do you trigger a script from an OSC message?
Mr.X is offline   Reply With Quote
Old 03-22-2024, 11:48 PM   #29
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

At action window, you can click add shortcut to a function and trigger a osc to it will learn it. If you need constant tracking of osc inside a script check out my repository example to learn how to use lua sockets and grab a osc module I wrote
daniellumertz is online now   Reply With Quote
Old 03-23-2024, 01:19 AM   #30
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

Scripts automatically are assigned to actions. Search yours, then "add".
mschnell is offline   Reply With Quote
Old 03-23-2024, 09:20 AM   #31
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by mschnell View Post
Scripts automatically are assigned to actions. Search yours, then "add".
I'm actually looking to grab ALL OSC messages. See:
https://forum.cockos.com/showpost.ph...1&postcount=25

Last edited by Mr.X; 03-23-2024 at 09:32 AM.
Mr.X is offline   Reply With Quote
Old 03-23-2024, 11:35 AM   #32
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

ReaLearn can receive and handle OSC messages (I did not test this).
mschnell is offline   Reply With Quote
Old 03-23-2024, 12:02 PM   #33
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by mschnell View Post
ReaLearn can receive and handle OSC messages (I did not test this).
Thank you, but no, I just want to figure out how to do what has been shown in the documenation and in my linked forum post.
Not looking to use ReaLearn (for a lot or reasons, so let's not waste time talking about ReaLearn, if you don't mind)

Hopefully SOMEONE knows how to do what's described in the documentation and alluded to in my linked post - basically sending ALL OSC messages to a single script.
Mr.X is offline   Reply With Quote
Old 03-24-2024, 01:07 AM   #34
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

Hmm.

I don't supposed Reaper is crafted to work that way.

When attaching an action to a Midi-CC event (in fact this actually the representation of a Midi CC event in a propriety message on the "Reaper Control Channel"), Reaper decides which action is to fire based on the CC number.
An OSC messages also results in a message on the "Reaper Control Channel". Hence the Reaper algorithm needs to decide which action is to be fired. This is done by checking the first "argument" of the OSC message. I don't suppose this can be deactivated.
mschnell is offline   Reply With Quote
Old 03-24-2024, 05:15 AM   #35
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by mschnell View Post
Hmm.
I don't supposed Reaper is crafted to work that way.
Did you get a chance to look at my links? Here's the meat of them:

One person said:
Quote:
Since REAPER 6.71 (or better 6.77) you can map each controller to single script and the use something like:

Code:
is_new_value,filename,sectionID,cmdID,mode,resolution,val,contextstr = reaper.get_action_context()

map = {
{address='/2/fader1',func = function() reaper.ShowConsoleMsg(os.date()..' fader 1 tweaked'..'\n') end},
{address='/2/fader6',func = function() reaper.ShowConsoleMsg(os.date()..' fader 6 tweaked'..'\n') end},
}

for i = 1, #map do
  if contextstr:match('osc%:('..map[i].address..')%:') then map[i].func() end
end
And in the Reascript docs it says:
Quote:
Action binding
You can query various contextual information about the script, at runtime, using get_action_context()/ reaper.get_action_context() (sorry, no Python support) . You can retrieve MIDI/OSC/mouse-wheel/trackpad input values when the script is bound to MIDI/OSC controllers (both absolute and relative modes are supported), or to the mouse-wheel/trackpad.

Here is a basic Lua example which monitors received MIDI/OSC input values:
Code:
function run()
  is_new,name,sec,cmd,rel,res,val = reaper.get_action_context()
  if is_new then
    reaper.ShowConsoleMsg(name .. "\nrel: " .. rel .. "\nres: " .. res .. "\nval = " .. val .. "\n")
  end
  reaper.defer(run)
end

function onexit()
  reaper.ShowConsoleMsg("<-----\n")
end

reaper.defer(run)
reaper.atexit(onexit)
Mr.X is offline   Reply With Quote
Old 03-24-2024, 10:55 AM   #36
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

look at my `Receive Sockets Demo.lua` example here :

https://github.com/daniellumertz/Dan.../LUA%20Sockets
daniellumertz is online now   Reply With Quote
Old 03-24-2024, 03:19 PM   #37
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by daniellumertz View Post
look at my `Receive Sockets Demo.lua` example here :

https://github.com/daniellumertz/Dan.../LUA%20Sockets
Ty, but Is this related what my links are referring to? I still am not seeing anything that tells me how to connect a single script with incoming OSC messages as is eluded to in my links.
Mr.X is offline   Reply With Quote
Old 03-24-2024, 04:27 PM   #38
daniellumertz
Human being with feelings
 
daniellumertz's Avatar
 
Join Date: Dec 2017
Location: Brazil
Posts: 2,011
Default

If you want to get the incoming osc then it is related, yes. Try out the examples
daniellumertz is online now   Reply With Quote
Old 03-24-2024, 04:47 PM   #39
Mr.X
Human being with feelings
 
Join Date: Jun 2011
Posts: 97
Default

Quote:
Originally Posted by daniellumertz View Post
If you want to get the incoming osc then it is related, yes. Try out the examples
Ok, sorry to be such a newb to this, but how exactly do I "try" them?

I got the impression from my linked info that there was now a "built in" way to map a controller to OSC messages. (see what I highlighted in red)
That's not true?
Mr.X is offline   Reply With Quote
Old 03-25-2024, 01:14 AM   #40
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,784
Default

Seemingly you are about to create a script. hence trying an existing one should not be a problem.

Usually you use the "action" window to load it and fire it.

I suppose these scripts define an association of some action on all OSC events or run recursively to poll for such.
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 09:30 PM.


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