11-18-2017, 10:09 AM | #81 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
This one works:
Code:
match (msg2, sprintf(#dest, slSlider1)) ? ( Code:
match (msg2, sprintf(#dest, "slSlider%d", 1)) ? ( Last edited by fundorin; 11-18-2017 at 10:31 AM. |
11-18-2017, 11:51 AM | #82 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Ended up using this code, where 16 is the number of the first fader and 23 is the last one:
Code:
16<=msg2<=23 ? ( ccValue = msg2 - 15; send_soft_fader(ccValue); ); |
11-18-2017, 12:29 PM | #83 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
You can set array values in the @init section and use them later. Beware of that in EEL arrays work similar as string slots !!! a[i] is just a shortcut for 0[a+i], meaning there is a single array 0[...] and you need to do something like a=1000; a[0] = 1; a[1] = 11; a[2] = 111; -Michael Last edited by mschnell; 11-18-2017 at 12:40 PM. |
|
11-18-2017, 12:40 PM | #84 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Fundorin
Suggest taking a look at Raymond Radet's advice at https://www.extremraym.com/en/reascript-guidelines and especially the code hierarchy of need at https://www.extremraym.com/en/reascr...rarchy_of_Need before writing too much code all at once. Compact code is beloved of some programmers, but sometimes it is better to be functionally sound and easy to understand, especially when someone else wants to read your code, or even you look back at your own code a few weeks later. There are lots of tutorials there too that may help the EEL2 and scripting learning if wishing for Lua. There's also EEL2 coding examples to learn from in https://github.com/X-Raym/REAPER-ReaScripts. "Good luck" once again and great to see progress now possible for the Novation! Last edited by goldenarpharazon; 11-18-2017 at 01:16 PM. Reason: Better advice given Lua prior knowledge & preference |
11-18-2017, 12:46 PM | #85 | |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
I've tested this method instead of using separate variables for each silder right now. Works, but the way of declaring an array is awful. You can't write something like this: slSlider=10; slSlider[1] = {16,17,18,19,20,21,22,23}; or slSlider[] = {16,17,18,19,20,21,22,23}; or slSlider[] = 16,17,18,19,20,21,22,23; Didn't work for me, at least. Tried many possible combinations to declare an array, using one (two, apparently, cause the offset should be declared too) line of the code. |
|
11-18-2017, 01:17 PM | #86 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
What is the name of this command in .reaperOSC?
I've tried TRACK_MONITOR, but that's not it. Even added toggle method to my custom .reaperOSC. Neither toggle or boolean worked. Code:
TRACK_MONITOR b/track/monitor b/track/@/monitor TRACK_MONITOR t/track/monitor t/track/@/monitor Last edited by fundorin; 11-18-2017 at 02:05 PM. |
11-18-2017, 02:28 PM | #87 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
I would do msg2 == slSlider1 ? ( send_soft_fader(1); ) : msg2 == slSlider2 ? ( ... -Michael |
|
11-18-2017, 02:31 PM | #88 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
Code:
slSlider = 10; // address of list mem_set_values(slSlider, 16, 17, 18, 19, 20, 21, 22, 23); |
|
11-18-2017, 02:32 PM | #89 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
The most convenient (and sustainable) way to do this in OSCII-bot scripts is reading the configuration from a file into appropriate arrays. -Michael |
|
11-18-2017, 02:37 PM | #90 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Great ! Seemingly a new function in 0.4/0,5. ( -> "Undefined behavior if used with more than 32767 variables." )
Does this also work for strings ? mem_set_values(slstrings, "abc", "cde", "fgh"); Lets try.... Yep !!! Great, very handy ! -Michael Last edited by mschnell; 11-18-2017 at 02:44 PM. |
11-18-2017, 02:40 PM | #91 | |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
Code:
// VOLUME SLIDERS slSlider1<=msg2<=slSlider8 ? ( ccValue = msg2 - 15; send_soft_fader(ccValue); ); Code:
slSlider1<=msg2<=slSlider8 ? ( Code:
ccValue = msg2 - 15; Code:
send_soft_fader(ccValue); ); I don't see any flaws in this code. P.S. Thanks, Justin. It seems like memsets will still be needed for my script. Ok. That's fine with me. I wish, though, that there wouldn't be any need of declaring the offset. Does this method also means that one should use "mem_get_values(slSlider[1]" to read value instead of simple "slSlider[1]", for example? Last edited by fundorin; 11-18-2017 at 02:50 PM. |
|
11-18-2017, 02:52 PM | #92 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
I(f it's provided, that all slSlider.. values are different, no problem at all.
-Michael |
11-18-2017, 03:03 PM | #93 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Even if only two variables were declared in the init section (1 and 8), those rest values aren't needed for this code, cause incoming messages will match the declared range between 1 and 8.
Last edited by fundorin; 11-18-2017 at 03:11 PM. |
11-18-2017, 04:48 PM | #94 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Is there a way to run some code on midi port reopen?
I'm running a couple of commands at oscii-bot startup, which are shutting down all LEDs, switching the default mode, displaying text on LCD and other. This all works when oscii-bot is started after the console. But, if the console was turned on while oscii-bot is already running, one needs to active oscii-bot's window and press "script reload" button. I'd prefer that the @init part of the script was executed each time when midi port is reopened. Is it possible? Meanwhile, I'm trying to set the function running when SYSEX is received from the surface. I know which sysex the surface is sending. Tracked it via midi-ox. This is the one - "\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x01\x01\ xF7". When I'm trying to log oscstr contents, this is the symbol that I'm getting: ð With this code in @midimsg section: Code:
printf("%s", oscstr); Last edited by fundorin; 11-18-2017 at 05:11 PM. |
11-19-2017, 01:00 AM | #95 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
This obviously would be viable.
As a workaround it might be possible to do some "ping" communication: Send a message in @timer - say any second - , receive the answer and react by setting some state, and in @time watch and reset that state. -Michael |
11-19-2017, 01:06 AM | #96 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
e.g. (for single bytes containing a value 0..127, as defined here -> http://www.gweep.net/~prefect/eng/re.../midispec.html ): i = 0; x = str_getchar(oscstr, i, 'cu'); ... (In fact I don't know what type 'c' is supposed to do (-64..+64 ???) , as seemingly any SysEX needs to have bit 7 = 0. I also don't know if/how the types larger than one byte will strip off the bits 7 from the multiple bytes ). -Michael Last edited by mschnell; 11-19-2017 at 02:51 AM. |
|
11-19-2017, 04:29 AM | #97 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
Code:
function format_hex(str_in) local(str_out, pos, len) ( strcpy(str_out=#,""); len=strlen(str_in); pos=0; while (pos<len) ( strcat(str_out,sprintf(#,"%02x ",str_getchar(str_in,pos))); pos+=1; ); str_setlen(str_out,strlen(str_out)-1); // returns str_out ); printf("%s\n",format_hex(sysex_message)); |
|
11-19-2017, 04:31 AM | #98 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Hmm yeah that's a good FR -- maybe add a @init_midi section which gets executed after @init, and after any other MIDI device reconnects... Edit: or better yet, a way to query the last open time for a device would be better.
Last edited by Justin; 11-19-2017 at 04:44 AM. |
11-19-2017, 06:38 AM | #99 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Yeah. That would be nice.
Can I also ask for the right click menu of the tray button with the following options: enable/disable oscii-bot log osc in/out log midi in/out reload script run at startup run minimized exit |
11-19-2017, 10:01 AM | #100 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
This is what I get in log window, using Justin's sysex convert function:
And this is the code that I'm using to print the word "sysex", when incoming OSC message is equal to the string from log. The thing is that it doesn't work as it should. What am I missing here, guys? Code:
@midimsg // logMidi(); sysex_message = oscstr; printf("%s\n",format_hex(sysex_message)); format_hex(sysex_message) == "f0 00 20 29 03 03 12 00 02 00 01 01 f7" ? ( // React to this when console is turned on printf("sysex"); // slStartup(); ); |
11-19-2017, 01:59 PM | #101 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
You can't use == for strings (except in certain instances but you shouldn't rely on that), you must use strcmp(#string,"value")==0.
BTW, I've updated https://cockos.com/oscii-bot/ with a git repository of oscii-bot source, with some changes since 0.5 (in case you have a compiler and want to use it before I can put together a release). |
11-19-2017, 03:03 PM | #102 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Could you, please, comment this code for me, cause I want to write an opposite function, which will convert osc string's parameters into hex, which would be then sent to the surface's LCD. I want to write it myself, but don't quite understand what's happening inside the function.
Code:
function format_hex(str_in) local(str_out, pos, len) ( strcpy(str_out=#,""); len=strlen(str_in); pos=0; while (pos<len) ( strcat(str_out,sprintf(#,"%02x ",str_getchar(str_in,pos))); pos+=1; ); str_setlen(str_out,strlen(str_out)-1); // returns str_out ); Code:
strcpy(str_out=#,""); Code:
len=strlen(str_in); Code:
pos=0; Code:
strcat(str_out,sprintf(#,"%02x ",str_getchar(str_in,pos))); Code:
pos+=1; Code:
str_setlen(str_out,strlen(str_out)-1); // returns str_out |
11-19-2017, 04:02 PM | #103 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
To move strings retrieved from OSC to Midi SysEX you don't need Hex. You just need to copy the appropriate bytes. I.e. part of the source string to part of the target string, using strcpy_substr(), strcpy_from() or do a loop with str_getchar() and str_setchar(). -Michael |
|
11-19-2017, 04:20 PM | #104 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
I don't think that I understand you clearly.
For example, I have the following string: "s/track/name" with an argument "Legendary Track". What I need is to construct the following sysex message and feed it to the surface: \xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00 //sysex header \x02\x02\x01 // clear the line of the LCD (not exactly, but, though) \x01\x017\x01 // set cursor position as character 17 \x04 // start text {osc argument in hex} \x00 //end text \xF7 //sysex end I would also need to check if argument's size is less than 8 characters. If more, all vowels and spaces should be removed. If string is still more than 8 characters, first 7 characters and the last one, if it's a number, should be converted to hex and sent to the controller. P.S. Instead of clearing the whole line of the LCD, which is 144 characters long, with sysex command (second part of the message), I would first fill the place where the text should be displayed, with a string of spaces, like this " ", to clear it from the text that was displayed there before and send the actual text right after. Last edited by fundorin; 11-19-2017 at 04:33 PM. |
11-19-2017, 10:41 PM | #105 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
That means that you need to work on each single character.
Hence (as I said in the previous message), you need to do a loop including something like Code:
c = str_getchar(oscstr, i, 'c'); i += 1; ... ... ? ( str_setchar(sysexstr, j, c, 'c'); j += 1; ); |
11-19-2017, 10:47 PM | #106 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Quote:
Of course here str_getchar does not know that it works on SysEX data, but is just a general string function. So the working of the type attribute is obvious ('c' -> -128 ... +127). Hence to extract somthing else then unsigned bytes from SysEX, dedicated user code is needed to be done, handling the always zero upper bits of the bytes. -Michael Last edited by mschnell; 11-20-2017 at 08:36 AM. |
|
11-20-2017, 03:36 AM | #107 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
See 1. https://forum.cockos.com/showthread.php?t=189074 (duplicate of https://forum.cockos.com/showthread.php?t=172325 ) and 2. https://forum.cockos.com/showthread.php?t=172324 |
|
11-20-2017, 07:25 AM | #108 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
First one isn't a bug. It's, actually, a very handy behaviour.
There is tons of software which minimizes to tray via [x] close button. |
11-20-2017, 08:10 AM | #109 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
Last edited by Justin; 11-20-2017 at 08:31 AM. |
|
11-20-2017, 08:34 AM | #110 |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
In v0.6, just released:
Code:
(tmp = get_device_open_time(dev)) > dev_last_time ? ( dev_last_time = tmp; printf("reinitializing dev\n"); // executes on initial open and any subsequent re-opens // ... midisend(dev); ); |
11-20-2017, 08:43 AM | #111 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
It would be nice if minimizing could be triggered in an unattended system, e.g. via a command line parameter or a line in a script.
-Michael |
11-20-2017, 08:53 AM | #112 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
In which section of the script should I put this code?
I want slStartup() function to run on midi port reopen. When placed in to @init section, code run just once, on start of the oscii-bot, or when "script reload" is pressed. Am I wrong, thinking that "dev" variable is an alias for device name? Tried leaving it as dev and renaming to my midi device in alias. Code:
(tmp = get_device_open_time(midi_in)) > dev_last_time ? ( dev_last_time = tmp; printf("reinitializing dev\n"); // executes on initial open and any subsequent re-opens slStartup(); // ... midisend(dev); ); |
11-20-2017, 08:55 AM | #113 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
|
|
11-20-2017, 10:00 AM | #114 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
-del-
|
11-20-2017, 11:42 AM | #115 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
https://forum.cockos.com/showpost.ph...40&postcount=3 One could imagine doing the same with other "windows automation" type tools. |
|
11-20-2017, 02:50 PM | #116 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
I'm running nircmd from oscii-bot's folder with "oscii-bot minimized.cmd".
This is what's inside it: "nircmd.exe exec hide OSCII-bot.exe" Pretty simple trick. |
11-23-2017, 12:03 PM | #117 | |
Human being with feelings
Join Date: Feb 2013
Location: Germany
Posts: 239
|
Quote:
Last edited by zacki; 11-23-2017 at 12:28 PM. Reason: added gif |
|
12-05-2017, 07:50 AM | #118 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,787
|
Great !
The "OSC Dialogue" feature works perfectly for me, too. -Michael |
12-06-2017, 01:20 AM | #119 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
How can one map ranges in EEL2?
My encoder sends values 1-24, when rotated clockwise and values 64-80 for counter clockwise. I need the script to convert 1-24 range to 0.1-1 and 64-80 to minus 0.1-1, so that it would be possible to use acceleration of the encoder. UPD. Solved with a straightforward method: take away 63 from the number in range 64-80, divide the result by 24 and change the sign to minus. Anyway, r/scrub action doesn't support acceleration, and "Transport: Scrub/jog (MIDI CC relative/absolute only)" action isn't reacting properly, though I'm sending the values right. Does this action support values, other than 1? UPD2. The following settings solved my issue with r/scrub action sensitivity. Though the jog function is absent, I can now simply divide value by greater numbers to get the needed sensitivity for the jog mode of the encoder. https://i.imgur.com/XiZ7Uxa.png UPD3. Aaaand it doesn't work like it should. I don't understand the behavior. It seems like faster rotation of the encoder gives more precise scrubbing/jogging. According to Reaper's log, lower values move cursor faster. I'm going to read the manual about scrub/jog settings, cause this logic doesn't seem right to me. UPD4. Seems like this scrub issue is more than three years old - https://forum.cockos.com/showthread.php?t=139051 Another issue from 2012 (post #33) - https://forum.cockos.com/showthread.php?t=98673 Last edited by fundorin; 12-06-2017 at 01:55 PM. |
12-07-2017, 05:49 AM | #120 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Anything to be learnt from Banned's Peavey StudioMix script or its users?
Banned tries a scrub approach in EEL2 code that maybe wasn't functionally what was wanted (perhaps the issues you are finding or similar?) then "avoiding the scrubbing function altogether, using a set of REAPER actions to move the playback cursor" |
Thread Tools | |
Display Modes | |
|
|