Old 01-14-2018, 12:47 AM   #81
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by mschnell View Post
-Michael
IMHO, discussion-wise, it does not make much sense to insert irrelevant info into a post. There's a signature part of the message exists for that type of stuff. Literally. Signature part. For signature. For your signature. Your signature. For the name. For your name. For -Michael. To put it there. Instead of the message's body. Seriously. That simple.
fundorin is offline   Reply With Quote
Old 01-14-2018, 06:03 AM   #82
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

So, this is the only way that worked for me.

code:
Code:
mapa = "abc";
pama = "ak";
sa = sprintf(#, "\*%c\*", str_getchar(pama,0));
sk = sprintf(#, "\*%c\*", str_getchar(pama,1));
printf("---------\n");
printf("mapa = %s, pama - %s, sa = %s, sk = %s\n", mapa, pama, sa, sk);
// match("*?%{tuto}s*?",pama)    ? printf("Found\n");
printf("%s\n", sk);
match(sa,mapa)    ? printf("Found1 - a in abc\n");
match(sk,mapa)    ? printf("Found2 - k in abc\n");
match(sprintf(#, "\*%c\*", str_getchar(pama,0)),mapa)    ? printf("Found3 - a in abc\n");
match(sprintf(#, "\*%c\*", str_getchar(pama,1)),mapa)    ? printf("Found4 - k in abc\n");
Found 1 and 3 would work, while 2 and 4 won't. That's right.
fundorin is offline   Reply With Quote
Old 01-14-2018, 11:04 AM   #83
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I'm having difficulties with storing strings for the third time and I keep forgeting, how my previous solutions worked out.
So, here we have a piece of code:
Code:
    oscmatch("/track/%d/name", trackNumber)            ? (
        oscparm(0,'s',oscTrackName[trackNumber]);
        oscTrackName8[trackNumber] = formatString(oscTrackName[trackNumber],8,1);
        printf("f  %i - %s\n", trackNumber, oscTrackName[trackNumber]);
        printf("r  %i - %s\n", trackNumber, oscTrackName8[trackNumber]);
        printf("f4 %i - %s\n", trackNumber, oscTrackName[4]);
        printf("r4 %i - %s\n", trackNumber, oscTrackName8[4]);
        printf("---\n");
        );
Let's say that formatString function just reduced incoming strings to the length of 8 characters.

And this is the log output:
Code:
f  1 - asdas121415
r  1 - asdas121
f4 1 - Track 4
r4 1 - asdas121
---
f  2 - Track 2
r  2 - Track 2 
f4 2 - Track 4
r4 2 - Track 2 
---
f  3 - Track 3
r  3 - Track 3 
f4 3 - Track 4
r4 3 - Track 3 
---
f  4 - Track 4
r  4 - Track 4 
f4 4 - Track 4
r4 4 - Track 4 
---
f  5 - Track 5
r  5 - Track 5 
f4 5 - Track 4
r4 5 - Track 5 
---
f  6 - Track 6
r  6 - Track 6 
f4 6 - Track 4
r4 6 - Track 6 
---
f  7 - Track 7
r  7 - Track 7 
f4 7 - Track 4
r4 7 - Track 7 
---
f  8 - Track 8
r  8 - Track 8 
f4 8 - Track 4
r4 8 - Track 8
As it can be seen here, full strings, i.e oscTrackName[trackNumber] (f) are stored properly, based of trackNumber = 4 (f4) behavior.
Reduced variables, i.e. oscTrackName8[trackNumber] (r) are all pointing to the same string, as trackNumber = 4 (r4) is showing us.

Here's how those arrays are declared in @init section. Both are declared exactly the same way:
Code:
oscTrackName        = 49*16384;
oscTrackName8        = 61*16384;
mem_set_values(oscTrackName+1,        #,#,#,#,#,#,#,#);
mem_set_values(oscTrackName8+1,        #,#,#,#,#,#,#,#);
So, when displaying track names with oscTrackName we get this:

and with oscTrackNames8 we get this:


And I don't understand, why.
fundorin is offline   Reply With Quote
Old 01-14-2018, 11:29 AM   #84
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

This solves the issue above:

Apparently, this code doesn't work:
Code:
oscTrackName8[trackNumber] = sprintf(#,"%s",oscTrackName[trackNumber]);
but this one works fine:
Code:
sprintf(oscTrackName8[trackNumber],"%s",oscTrackName[trackNumber]);
And I have no clue why.
Maybe, that's because it's not possible to assign literal strings directly in EEL, using "=" operator.
fundorin is offline   Reply With Quote
Old 01-14-2018, 02:18 PM   #85
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,636
Default

See the warning about the short lived temporary string # in the docs.

Quote:
Originally Posted by fundorin View Post
I have no clue
True !. The cause of that fact obviously is that I only provide crap instead of trying to help, so lets give up.

Putting fundorin on the ignore list.
-Michael

Last edited by mschnell; 01-14-2018 at 10:29 PM.
mschnell is offline   Reply With Quote
Old 01-15-2018, 08:35 AM   #86
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,636
Default

If anybody wants a little training with the EEL string handling system (which in fact is very simple, but might be unusual, regarding the ways of other programming language, hire some example code for checking out:
Code:
@init

printf("init\n");

printf("----\n");

#st = "1234";
#su = "9876";
printf("%d: %s\n",#st,#st);
printf("%d: %s\n",#su,#su);
printf("%d: %s\n",st);
printf("%d: %s\n",su);
printf("----\n");

sn = 0;
strcpy(sn, "abcd");

sm = 1;
strcpy(sm, "ABCD");

so = #st;
sp = #su;
printf("%d: %s\n", sn, sn);
printf("%d: %s\n", sm, sm);
printf("%d: %s\n", so, so);
printf("%d: %s\n", sp, sp);
printf("%d: %s\n",  #,  #);
# = "hash";
h = #;
printf("%d: %s\n",  #,  #);
printf("%d: %s\n",  h,  h);
h = # = "hash";
printf("%d: %s\n",  #,  #);
printf("%d: %s\n",  h,  h);

printf("%d: %s\n",  #,  z=#="hash1");
printf("%d: %s\n",  #=#st,  #);
printf("%d: %s\n",  z,  z);

printf("\n-- sprintf --\n");
x = 777;
y = sprintf(x, "//%d//", 3);
printf("%d: %s   %d: %s\n", x, x, y, y);
y = sprintf(#, "//%d//", 3);
printf("%d: %s   %d: %s\n", #, #, y, y);
printf("%d: %s   %d: %s\n", x, x, y, y);
printf("%d: %s   %d: %s\n", #, #, y, y);
y = 3;
y = "three";
y1 = sprintf(y2=#, y3="//%s//", y4=y);
printf("%d: %s   %d: %s   %d: %s   %d: %s\n", y1, y1, y2, y2, y3, y3, y4, y4);


printf("\n-- += --\n");
#f = "f";
#g = "g";
#f += sn;
sm += #g;
printf("+=    %s,   %i,    %s,    %i\n", #f, #f, sm, sm);
#f = #f + sn;
#g = "123" + #f; //+"456";
printf("+     %s,   %s\n", #f, #g);

printf("\n-- Loop --\n");
strcpy(2, #st);
strcpy(3, #su);
i = 0;
loop(4,
  printf("%i: %s\n", i, i);
  i += 1;
);


printf("\n-- match --\n");

z = match ("x", "xyz");
printf ("%d\n", z);
z = match ("xyz", "xyz");
printf ("%d\n", z);

x = "x";
y = "abcdef";
z = match(x, y);
printf("%d: %s   %d: %s\n", x, x, y, y);
printf ("%d\n", z);

x = "cd";
z = match(x, y);
printf("%d: %s   %d: %s\n", x, x, y, y);
printf ("%d\n", z);
z = match(x, "%0s", y);
printf("%d: %s   %d: %s\n", x, x, y, y);
printf ("%d\n", z);


printf("\n-- file --\n");
f = fopen("c:/tmp/xxx.txt", "r");
printf("handle: %i\n", f);
  f ? (
    i = 0;
    x = 100;
    l = -1;
    while (l) (
      l = fgets(f, x);
      l ? (
        str_setlen(x, l-1);
        printf("%i: %i: %s\n", i, l, x);
      );  
      i += 1;
      x += 1;
    );  
    printf("----\n");
    x = 100;
    loop (i-1,
      l = strlen(x);
      printf("%i: %s\n", l, x);
      x += 1;
    )
  );
printf("----\n");
(I did not try the 3rd parameter of match, as I am not at all knowledgeable with RegEx, and hence the documentation is too sparse for me to comprehend.)
-Michael

Last edited by mschnell; 01-15-2018 at 10:19 PM.
mschnell is offline   Reply With Quote
Old 01-15-2018, 10:19 PM   #87
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,636
Default

Quote:
Originally Posted by mschnell View Post
(I did not try the 3rd parameter of match, as I am not at all knowledgeable with RegEx, and hence the documentation is too sparse for me to comprehend.)
OSCII-Bot docu -> "Searches for the first parameter in the second parameter, using a simplified regular expression syntax."
I now seem to understand that the 2nd, the 3rd and more parameters of match() work like sprintf(), and hence the 3rd parameter is not about RegEx, but supposedly the RegEx code will go into the 2nd.
Nonetheless I don't know how this works.

-Michael
mschnell is offline   Reply With Quote
Old 01-16-2018, 02:56 PM   #88
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,636
Default

Ooops.

match() sets the values of parameters 3, ... ?!?!?

So I was totally confused.

-Michael

Last edited by mschnell; 01-16-2018 at 03:05 PM.
mschnell is offline   Reply With Quote
Old 01-16-2018, 03:47 PM   #89
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

So, I've came to the point where single dimension array might not be enough for storing osc data.
I've used only single variable commands before, like
Code:
oscmatch("/track/%{number}d/mute")            ? oscTrackMute[number]            = oscparm(0,0);
for t/track/@/mute/toggle.

Now, it's two variables. What would be a best way to store those?
n/track/@/recv/@/volume
fundorin is offline   Reply With Quote
Old 01-17-2018, 02:59 AM   #90
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I'm still struggling with controlling volume/pan of the device tracks via
TRACK_VOLUME n/track/@/volume
TRACK_PAN n/track/@/pan
with pots or non-mechanical faders.

Controls in Reaper are jumping to the current pot value, regardless of what was the actual vol/pan value in Reaper for that track. Can't come up with a stable soft pickup code for built-in ReaperOSC commands. Any help would be appreciated.
fundorin is offline   Reply With Quote
Old 01-17-2018, 03:25 AM   #91
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I might've found an issue here.
Even if ReaperOSC file have this entry:

TRACK_PAN n/track/pan n/track/@/pan s/track/pan/str s/track/@/pan/str

Reaper doesn't send feedback to the device when /n/track/@/pan is sent from the device:
Quote:
----------------------------------
Incoming OSC...
Message: /track/pan
Value: 0.055000
----------------------------------
Incoming OSC...
Message: /track/pan/str
Value: 89%L
----------------------------------
Incoming OSC...
Message: /track/1/pan/str
Value: 89%L
There's no "/track/1/pan" command above.

When pan is adjusted in Reaper:
Quote:
----------------------------------
Incoming OSC...
Message: /track/1/pan
Value: 0.183000
----------------------------------
Incoming OSC...
Message: /track/1/pan/str
Value: 63%L
And /track/1/pan is the command that my script is tracking, to store pan values for all 8 tracks of the device. Because of this, I can't update feedback values in time to implement soft pickup.
fundorin is offline   Reply With Quote
Old 01-17-2018, 05:20 AM   #92
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I'm trying to use this code for soft pickup of the single pot:
Code:
    msg2 == slP[1] ?(
        (oscTrackPan[1]-0.1 < msg3/127 && msg3/127 < oscTrackPan[1]*127+0.1) ? (
            oscsend(osc_out, "n/track/%d/pan", msg3/127, 1);
            oscTrackPan[1] = msg3/127;
            );
        );
With this code, pot's position only picked up when pot is rotated relatively slow, and if it's twisted fast, Reaper looses it's position.

At the same time, this simple code is rock solid and doesn't loose pot's position at all.
Code:
    msg2 == slP[1] ?(
            oscsend(osc_out, "f/action/%d/cc/soft", msg3/127, 21);
        );
Action 21 is "Track: Set pan for track 01 (MIDI CC/OSC only)".

What is the magic behind that soft pickup action in Reaper?
fundorin is offline   Reply With Quote
Old 01-17-2018, 12:24 PM   #93
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I've spent lots of lost hours on this issue and it seems like there's no other solution, except for devs adding soft takeover for built-in ReaperOSC commands.
One could add extra flag, telling the script that the value was set by Reaper or by physical pot, so it would be possible to soft takeover the value for the pot, that was previously set by Reaper, but, as soon as you'd assign another control to send panorama adjust command, you'll immediately need another flag for it. And another one. And another. The more unique controls you want to use for the same parameter adjustment, the more flags should be implemented into the code.
Otherwise, there's no way to tell the script, is the value was previously adjusted by Reaper or by the same midi control, that just simply jumped too fast and didn't sent each continuous value to the script, despite of it's purpose (CC - continuous control).
So, soft takeover logic should be implemented on the Reaper's side.
fundorin is offline   Reply With Quote
Old 01-19-2018, 06:07 AM   #94
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

After inspecting some csurf plugin's sources, I've realized that there actually IS a flag for each physical knob on the controller, and it's a touch sensor. So, it might be possible to use sensor's state as a trigger for pan/vol actions, like:
if knob wasn't released while panorama value is changing, always consider knob's position as a panorama value. It should solve the issue, when one is twisting pan knob so fast, that it's beginning to pass some midi values. And, because of it, script is starting to think that the value was adjusted by something else, like mouse.
Now, it's time to implement this logic into the script.
Sometimes I feel like a moron and sometimes like a genius. Today is the latter. 🤡
fundorin is offline   Reply With Quote
Old 01-20-2018, 01:19 AM   #95
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Last control's position should be added into the script to make soft pickup work.

Solution:
Code:
function modeMixerP() (
    i=1;
    while(i<=8) (
        msg2 == slP[i] ? (
            lastP[i] < oscTrackPan[i] && midiP[i]/127 >= oscTrackPan[i] ? (
                oscsend(osc_out, reaper_track_pan, midiP[i]/127, i);
                oscTrackPan[i] = midiP[i]/127;
                lastP[i] = midiP[i]/127;    
                );
            lastP[i] > oscTrackPan[i] && midiP[i]/127 <= oscTrackPan[i] ? (
                oscsend(osc_out, reaper_track_pan, midiP[i]/127, i);
                oscTrackPan[i] = midiP[i]/127;
                lastP[i] = midiP[i]/127;
                );
            lastP[i] == oscTrackPan[i] ? (
                oscsend(osc_out, reaper_track_pan, midiP[i]/127, i);
                oscTrackPan[i] = midiP[i]/127;
                lastP[i] = midiP[i]/127;
                );
            );
        i+=1;
        );
    );
fundorin 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 04:24 AM.


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