Old 01-10-2018, 07:59 AM   #41
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,716
Default

Quote:
Originally Posted by fundorin View Post
We have dec int position with value 11. Printed as double.
We write position into num1 in hex format as a string, adding "\x" in front and making it two characters, minimum. Printed as a string.
We write num1 into num2 in string format as a string. Printed as a string.
We assign "\x0B" text string as a value to num3. Cannot be printed as a string. Why?!
If we convert it into string with a function, then it can be printed as a string.
How come that direct assignment makes that "\x0B" string a hex value for oscii-bot?
I think the key here is that num1 and num2 refer to strings that are 4 bytes long ("\", "x", "0", and "B"), and num3 refers to a 1 byte string with the value of 11. If you want it to be a 4 byte string, you could use "\\x0B" instead of "\x0B". Does that help?
Justin is offline   Reply With Quote
Old 01-10-2018, 08:41 AM   #42
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by goldenarpharazon View Post
If one uses "\\x0B" instead, then it has an \ escape character to escape the escape character \x so probably produces the string expected
This is the line from my previous message. It already has an escape character before backslash:

num1 = sprintf(#,"\\x%02X", position);

Quote:
Originally Posted by Justin View Post
I think the key here is that num1 and num2 refer to strings that are 4 bytes long ("", "x", "0", and "B"), and num3 refers to a 1 byte string with the value of 11. If you want it to be a 4 byte string, you could use "\\x0B" instead of "\x0B". Does that help?
I actually need the opposite. I want to to convert track number from Reaper's osc message into 1 byte string, so it could be used as a part of sysex message.
fundorin is offline   Reply With Quote
Old 01-10-2018, 09:58 PM   #43
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by Veto View Post
"\x##" also specifies a single ASCII character within a string.
Maybe I'm misunderstanding but if this is what your device needs than you can do
PHP Code:
pos=0x0B// pos=11printf("ASCII %d: %c\n",pos,pos); 
There's no pos=0x0B in my original code. Only position = 11 (or some other decimal, between 0-255), which I need to convert into 1 byte string "0x0B", in case of 11. Or "0x0C", if position = 12.


P.S. Also trying to use mask, to get single byte string with (position & 0xFF). Still doesn't work.

num = sprintf(#,"%X", position & 0xFF);
or
num = position & 0xFF;

P.P.S. num = sprintf(#,"%X", (11 >> 0) & 0xFF); outputs single byte 42, while I need it to be 0B

There are tons of different conversion functions in other languages, like Convert.ToByte or byte a = position. Can't find a proper method in EEL2, though.

Last edited by fundorin; 01-10-2018 at 11:38 PM.
fundorin is offline   Reply With Quote
Old 01-11-2018, 12:33 AM   #44
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I've decided to write a simple script, so that anyone could run it on their system.
The task is to convert variable position value into num2 value at line 23, so it would be displayed in oscii-bot's log as 0B and nothing else.
Code:
@init    

function hex2str(str_in) local(str_out, pos, len) (            // Formatting HEX values to strings 
    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
    );

function lcdFeedback(pos) local (lcdTrackName lcdTrackName2 num1 num2) (    
    strcpy(lcdTrackName1=#,"");
    strcpy(lcdTrackName2=#,"");

    start    = "\x66";
    end        = "\x77";


    num1 = "\x0B";
    num2 = pos;                                                    // task: change this line so the output would be "\x0B" in log

    strcat(lcdTrackName1,sprintf(#,"%s%s%s",start,num1,end));    // 66 0B 77    
    strcat(lcdTrackName2,sprintf(#,"%s%s%s",start,num2,end));    // 66 xx 77

    printf("num1 - %s\n", num1);
    printf("num2 - %s\n", num2);

    printf("out1 - %s\n", hex2str(lcdTrackName1));            // 66 0B 77
    printf("out2 - %s\n", hex2str(lcdTrackName2));            // 66 xx 77 - should also be 0B

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

@timer

position = 11;
lcdFeedback(position);

@oscmsg     
@midimsg
Link to the script - https://www.dropbox.com/s/hif9xexs1gwkotx/test.txt?dl=0
fundorin is offline   Reply With Quote
Old 01-11-2018, 03:02 AM   #45
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by Veto View Post
you do try out examples of people trying to help you, right?
Sure!

Quote:
Originally Posted by Veto View Post
I love you, man! Seriously! I've tried all types of data format, but with sprintf or str_getchar functions. Thanks a lot!

upd:

Last edited by fundorin; 01-11-2018 at 03:13 AM.
fundorin is offline   Reply With Quote
Old 01-11-2018, 05:37 AM   #46
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

So, it's time to figure out strings in EEL.

This is what Justin wrote:
Quote:
If you want to do it purely programmatically, you could assign the pointers to the values 0..1023 which are the user strings that you can use.
From reference
Quote:
Literal strings are mutable in OSCII-bot, and you can also have other named strings:You can use the fixed values of 0-1023:
Does this mean that one can only use 1024 strings in the whole script?

This is my related code and how I suppose it should work:
Code:
@init
oscTrackName = 51*16384; // set pointer position
mem_set_values(oscTrackName+1, #,#,#,#,#,#,#,#); // allocate 8 strings

@oscmsg
oscmatch("/track/%{trackNumber}d/name") ? oscparm(0,'s',oscTrackName+trackNumber); // write track 1-8 names as values for corresponding variables

@timer
printf("%d, %s\n", oscTrackName+1, oscTrackName+1); // Should print out Track 1 position and name
But, this is printf output:
Code:
786433,
Why doesn't it print track name?

Last edited by fundorin; 01-11-2018 at 06:09 AM.
fundorin is offline   Reply With Quote
Old 01-11-2018, 06:39 AM   #47
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I've decided to declare all eight strings for all types of parameters (name, vol, pan) by now. Can't wait till I'll start writing FX param part of the script, where could be hundreds parameters for each plugin.

Anyways, slowly moving towards the end result:
fundorin is offline   Reply With Quote
Old 01-11-2018, 06:59 AM   #48
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
Anyways, slowly moving
Good for you !

-Michael

Last edited by mschnell; 01-11-2018 at 07:08 AM.
mschnell is offline   Reply With Quote
Old 01-11-2018, 08:20 AM   #49
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by fundorin View Post
So, it's time to figure out strings in EEL.

This is what Justin wrote:
From reference Does this mean that one can only use 1024 strings in the whole script?
Thrilled to see our names in flashing lights: that means some code works!

Having decided to go the string rather than memory array implementation path, please help us to help efficiently, by reading and absorbing what is clearly said about string storage under strings here.
http://cockos.com/oscii-bot/oscii-bot-doc.html
and
string functions here
https://www.reaper.fm/sdk/js/strings...s_string_funcs

Repeat after us
"I promise faithfully that I Fundorin have read this, and remembered the advice that exists in it, however cryptic and albeit still learning how it all works on my device...."
[please choose friendly emoticon to suit]

Quote:
Originally Posted by fundorin View Post
Why doesn't it print track name?
Please walk then run. It really makes it hard combining two new concepts when either alone may confuse a learner.

1. Use a statically allocated string to begin with (easy: no pointer confusion)
2. Get oscmatch() working
3. Do a separate experiment with string buffers (if that is really needed in the design...)
4. Combine string buffers and oscmatch() - Wunderbar!

To debug oscmatch() then look at the debug printf() in the MIDIMIX code and adapt that idea. Use it by comparing (by sight) the strings actually seen in the OSCII-bot console.

One has to work this way since the OSC output from Reaper is a secret known only to the devs or those that try and unlock the OSC secrets

Once again good luck!

Last edited by goldenarpharazon; 01-11-2018 at 09:27 AM. Reason: Two pieces of advice for the price of one...
goldenarpharazon is offline   Reply With Quote
Old 01-11-2018, 10:47 AM   #50
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by Veto View Post
Can you really do this in OsciiBot?
Like this.
Code:
strcat(spam="foo","bar");  // spam=="foobar" ?  
printf("%s\n", spam);
fundorin is offline   Reply With Quote
Old 01-12-2018, 12:52 AM   #51
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

This is more OSC related stuff, but, still: why sending

Code:
DEVICE_PREV_TRACK t/device/track/-
DEVICE_NEXT_TRACK t/device/track/+
commands to Reaper doesn't switch device's bank, so it would always display the bank of the currently selected track?
For now, if one calls "track+" enough times to select track that isn't in the current bank, device doesn't automatically switch to the next/prev bank.

I've made a small video about it, showing that scrolling through tracks with an encoder would indicate currently selected track with LED button, but as soon as selected track is within range of the current bank, you have no clue, what track it is.


Notice how I'm forced to switch banks with my right hand to find the bank, in which the track was selected.
I've even lost it's position, during filming, because track selector jumped to the first track in the project, when the end of the track list was reached.

Last edited by fundorin; 01-12-2018 at 04:23 AM.
fundorin is offline   Reply With Quote
Old 01-12-2018, 06:31 AM   #52
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Sadly, no Reaper API commands are possible via OSC. Only commands from Default.ReaperOSC configuration file could be used.
I'm dreaming about the moment, when it would be possible to access midi ports directly from LUA scripts.

Track banks are dynamic and based on overall project's tracks amount, divided by number, that's declared in .ReaperOSC file.
DEVICE_TRACK_COUNT 8

One can only switch between banks, using "bank-/bank+" or choosing banks directly. In the last case, though, it's impossible to discover the last bank's number.

Last edited by fundorin; 01-12-2018 at 06:38 AM.
fundorin is offline   Reply With Quote
Old 01-12-2018, 12:51 PM   #53
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Am I constraining the value to 0-1 range correctly, or is there a better way?
I've invented this method myself. 🤠

Code:
oscTrackVolume[i] = max(0,min(1,(oscTrackVolume[i]+encoderRemap(msg3))));
fundorin is offline   Reply With Quote
Old 01-12-2018, 03:08 PM   #54
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Dealing with encoder rings.



What is the best way to convert 0-1 range into 0-12? Some log curve would also be a nice addition to that conversion.
For now, I did a straightforward conversion, which isn't very elegant:
Code:
function ledRings(value) local (int_out)(
    value == 0 ? (int_out = 0;):
    0 < value <= 0.01 ? (int_out = 1;):
    0.01 < value <= 0.1 ? (int_out = 2;):
    0.1 < value <= 0.2 ? (int_out = 3;):
    0.2 < value <= 0.3 ? (int_out = 4;):
    0.3 < value <= 0.4 ? (int_out = 5;):
    0.4 < value <= 0.5 ? (int_out = 6;):
    0.5 < value <= 0.6 ? (int_out = 7;):
    0.6 < value <= 0.7 ? (int_out = 8;):
    0.7 < value <= 0.8 ? (int_out = 9;):
    0.8 < value <= 0.9 ? (int_out = 10;):
    0.9 < value <= 1 ? (int_out = 11;):
    value == 1 ? (int_out = 12;);
    );
This might be better, though:
Code:
int_out = floor(value * 12);
fundorin is offline   Reply With Quote
Old 01-13-2018, 01:53 AM   #55
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Dear Fundorin,

From the code snippets you posted, I have the impression that you convert received binary values to hexadecimal and then back to binary.

While this of course is not forbidden, I suppose that's a not really viable left over from some legacy version of your code, trying to deal with printable strings in between.

If you want to check or manipulate the values, it of course is better to leave them in their binary form all the time.

-Michael
mschnell is offline   Reply With Quote
Old 01-13-2018, 02:58 AM   #56
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

To which part of the code are you referring, exactly, Michael?
The last one? If it's true, then, there're no hex values there.
Variable value is an argument of the "/track/@/volume" OSC command from Reaper, which is a float number within 0-1 range.

LED rings respond to midi values 0-12 (no LEDs - all 11 LEDs), so the code is simply converting 0-1 float into 0-12 integer. No hex involved.
I'm trying to avoid hex values in my script as much as I can, for better readability, since EEL doesn't make a difference between hex and dec values.

Last edited by fundorin; 01-13-2018 at 03:45 AM.
fundorin is offline   Reply With Quote
Old 01-13-2018, 04:28 AM   #57
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
To which part of the code are you referring, exactly, Michael? The last one?
Nope this was just a general comment.

In fact I don't see why any hex conversion to and/or fro would be necessary (other than for a temporary visualization for debugging purpose), as neither the OSC nor the midi / sysex protocol uses hex code on the line.

-Michael
mschnell is offline   Reply With Quote
Old 01-13-2018, 05:10 AM   #58
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I'm trying to use hex for LCD sysex commands only, since that's how they're represented in SLMKII MIDI Programmers Reference.
Once I'll become familiar with sysex commands, I might change hex to dec in my code.
I must mention, though, that simple midi commands are also represented as hex (most of the time) in the manual, but since I'm used to dec numbers for СCs, I'm using them, instead of hex.

from reference:
fundorin is offline   Reply With Quote
Old 01-13-2018, 08:08 AM   #59
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Why to get rid of the issues with skipping fast changing values from midi?

For example:
Code:
    msg1 == 0xBF ? (
        i=1;
        while(i<=8) (
            msg2 == Fader[i] ? (
                    printf("%i\n", msg3);
                    );
            );
        );
Now, let's move fader from the bottom to the top with an extreme speed (0-127):

oscii-bot log output:



midi-ox log output:



So, I was trying to add to implement soft pickup for faders and pot, but,obviously, this isn't working because midi controller itself sends only a small portion of the 0-127 range and oscii-bot can register even smaller amount of values.
I understand that it happens because of "while" function and when those values are transmitted by the controller, oscii-bot is busy, polling the rest 7 faders (and doing other stuff), but I'm interested in how to fix this issue.
fundorin is offline   Reply With Quote
Old 01-13-2018, 09:57 AM   #60
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

There shouldn't be any loss of Midi data and OSCII-bot has a Midi buffer.

Most likely explanation in the mystery code fragment is
Code:
msg2 == Fader[i]
line does not always evaluate to true depending on the value of i.

Please just write simple code that detects the midi values as expected with nothing else in it. Then add to it with richer control flows etc. That way solid code works quicker and it saves forum questions because the problem appeared in an incremental step so the developer just saw it and fixed it.

Is there any option in the Novation SL programming manual that changes the Midi responsiveness and verbosity of the pots/faders? Is it ever likely to move that fast in real music production life?

To resolve one could imagine interpolating enough extra values to trick Reaper into takeover nicely at the crossover value.
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 10:25 AM   #61
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

This is just a pointer to midi cc number. Nothing mysterious here

Fader = 3*16384;
mem_set_values(Fader+1, 16, 17, 18, 19, 20, 21, 22, 23); // Faders

That was already a simplified example. My original code looks like this, FYI:
Code:
			// VOLUME FADERS
			msg2 == slF[i] ? (
				oscTrackVolume[i] - sPickTol <= midiF[i]/127 && midiF[i]/127 <= oscTrackVolume[i] +sPickTol ? (
					oscsend(osc_out, reaper_track_volume, midiF[i]/127, i);
					// printf("1 - %i", midiF[i]);
					);
				oscTrackVolume[i] = midiF[i]/127;
				// printf(" 2 - %i\n", midiF[i]);
				);
fundorin is offline   Reply With Quote
Old 01-13-2018, 10:35 AM   #62
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
I must mention, though, that simple midi commands are also represented as hex (most of the time) in the manual, but since I'm used to dec numbers for СCs,
Yep they are displayed as hex for human readability. technically they always are binary (as are the parameters transferred via OSC).

Hence for sending e.g. text strings (characters = 7 bit binary numbers) received by OSC to midi via SysEx, no cenversion at all is necessary.

With continuous parameters (e.g. Midi CCs), a conversion needs to be done, as OSC usually uses (binary) floating point (0.0 .., 1,0), while Midi usually 7 bit Integer (0 ... 127). But all of this does not involve any hex (or decimal) (human reeadable) string encoding.

-Michael
mschnell is offline   Reply With Quote
Old 01-13-2018, 10:48 AM   #63
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by goldenarpharazon View Post
There shouldn't be any loss of Midi data and OSCII-bot has a Midi buffer.
I also see such data loss. I did not yet try to find out at which point this happens.

My setup is:

Midi controller with motor faders
<- (Midi via USB) ->
Reaper
<- (Midi via Loop device) ->
OSCII-Bot
<- (OSC via WLan) ->
Mixer Box (XR18) (can service up to 4 OSC Clients)
<- (OSC via WLan) ->
Laptop showing the GUI for the Mixer

- I can move a Fader in the the Mixer GUI and the Motor Fader in the Controller box follows.

- I can move a Motor Fader in the Controller box and the Fader in the the Mixer GUI follows.

But only if I do this slowly. When I do a fast move, the fasders disagree, especially when movin to Zero or to max.

-Michael
mschnell is offline   Reply With Quote
Old 01-13-2018, 11:01 AM   #64
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

You're right. No need to convert text strings from Reaper. Cool!
fundorin is offline   Reply With Quote
Old 01-13-2018, 11:26 AM   #65
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

On the Akai MIDIMIX->Midi-OX USB input path (ie no OSCII-bot or Reaper at all) Midi-OX reliably shows 0 and 127 Data 2 end point bytes being sent, with the fastest time I can throw the fader (that's 77mS according to Midi-OX timestamp whilst fast-fingers Fundorin's example is 59mS)

There are few lost Midi values - eg sequence goes 72, 75, 78

Functionally when hooked up to OSCII-bot everything works fine and one would not notice any issue.

I guess one could imagine some sort of Midi bus saturation, but again look for positive working behaviour on simplest code first.

Last edited by goldenarpharazon; 01-13-2018 at 11:40 AM.
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 11:43 AM   #66
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by fundorin View Post
You're right. No need to convert text strings from Reaper. Cool!
Wunderbar! Thank you Michael.
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 11:57 AM   #67
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I can easily convert separate numbers, like
header = 240;
instead of
header = "\xF0";
and replace %s with %c in sprintf.

But, how would one replace this string:
"\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02"
with dec numbers line?
fundorin is offline   Reply With Quote
Old 01-13-2018, 12:14 PM   #68
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by fundorin View Post
I can easily convert separate numbers, like
header = 240;
instead of
header = "\xF0";
and replace %s with %c in sprintf.

But, how would one replace this string:
"\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02"
with dec numbers line?
Then assuming header is supposed to contain a number to store a byte, let the compiler do the work and the programmer still see the hex value.

Write
header = $xF0;

What you have written is already a clear way of storing the bytes of the SYSEX header in a string. They are binary values without meaningful character equivalents. Decimal values simply confuse since the Novation programmer manual uses hex.

Put a // comment alongside it in the code to make it clear that it is SYSEX header.

Last edited by goldenarpharazon; 01-13-2018 at 12:41 PM. Reason: Oops $ : then worked out it is SYSEX header
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 01:25 PM   #69
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I don't think that you understand the issue right.

"\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02"
=
2470141C33C0202

?

How would oscii-bot or midi controller understand that 247 is a number and not a sequence of numbers 2, 4 and 7?
fundorin is offline   Reply With Quote
Old 01-13-2018, 02:32 PM   #70
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
I can easily convert separate numbers, like
header = 240;
instead of
header = "\xF0";
and replace %s with %c in sprintf.

But, how would one replace this string:
"\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02"
with dec numbers line?

Seemingly even C does not feature a notation for decimal character definition (which logically would be "\d240"), but only octal ("\360") and hexadecimal. As EEL inherits from C supposedly this is similar, here.

Otherwise you could do something like e.g:
string = sprintf("%c%c%c%c%c%c%c%c%c%c%c%c", 240, 0, 32, 41, 3, 3, 18, 0, 2, 0, 2);


-Michael

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

Yep. That's why having them as hex values seems easier to me.

Is it possible to operate with strings, using regular expressions in EEL, like strValue = Regex.Replace(strValue, @"\s|\-|'", "");?
fundorin is offline   Reply With Quote
Old 01-13-2018, 02:46 PM   #72
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Sometimes it might be really nice to have regex library functions available in EEL

-Michael
mschnell is offline   Reply With Quote
Old 01-13-2018, 02:55 PM   #73
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

I've used an ugly line for now, that only allows letters and numbers:
Code:
(47 < str_getchar(str_in,pos) && str_getchar(str_in,pos) < 58) || (64 < str_getchar(str_in,pos) && str_getchar(str_in,pos) < 91) || (96 < str_getchar(str_in,pos) && str_getchar(str_in,pos) < 123) ? (
fundorin is offline   Reply With Quote
Old 01-13-2018, 03:29 PM   #74
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by fundorin View Post
I don't think that you understand the issue right.

"\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02"
=
2470141C33C0202

?
How and where did this 15 digit printed hex number come from? Show the code that produced it along with the assignment statement and then it might be possible to answer the next question. It's just possibly the pointer to the string.

Quote:
Originally Posted by fundorin View Post
How would oscii-bot or midi controller understand that 247 is a number and not a sequence of numbers 2, 4 and 7?
If its a pointer value then OSCII-bot or the midi controller won't need to use the pointer directly. The pointer just tells the EEL run time system where to find the actual bytes that make the string.

Please spend some time researching how mutable and/or immutable strings can be stored in a computer's memory and data structures for more common programming language than (arcane) EEL. Try this https://www.interviewcake.com/articl...ding-interview? Look at computer science learning stuff, youtube? Find material that suits your learning style beyond reading text?

Try and understand the difference and yet inter-connected relationships between characters, bytes in memory, strings and pointers.

The majority of high level languages in common use today hide pointers from programmers. But EEL has a C/C++ like heritage and it is still using pointers for strings and in the programmer's use of arrays.

Last edited by goldenarpharazon; 01-13-2018 at 03:46 PM.
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 03:39 PM   #75
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by goldenarpharazon View Post
How and where did this 15 digit printed hex number come from?
This variable is a part of what would be the constructed sysex message later in the script.


P.S. What is a proper way to detect if character "b" from the string "abcd" is present in the string "tofu"?
I'm trying different variations of the following code and it's either always prints "Found" or doesn't print anything.
Code:
pama = "abcd";
match("*?%c*","tofu", str_getchar(pama,1)) ? printf("Found\n");
fundorin is offline   Reply With Quote
Old 01-13-2018, 04:08 PM   #76
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 189
Default

Quote:
Originally Posted by fundorin View Post
This variable is a part of what would be the constructed sysex message later in the script.
The image shows 10 bytes that should be represented internally in the computer memory in EEL either as a string, or as an array.

So what is correlation between that string and the 15 digit hex number shown as "=2470141C33C0202" ?
goldenarpharazon is offline   Reply With Quote
Old 01-13-2018, 06:15 PM   #77
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
I've used an ugly line for now, that only allows letters and numbers:
To make such a statement nicer you could do a string that contains 128 characters just 0 and 1: 1 meaning to use the code represented by the position in the string, 0 meaning not to use it.

then the statement just is something like

Code:
allowstring = "000000000000000000000000000000011111111   ....

str_getchar(allowstring, str_getchar(str_in,pos) == 0x31 ? ....
Or you use match with a string containing the allowed characters. (BTW.: (re your other post), the second parameter of match needs to be a string, not a character (which is a number), and here you can use regular expressions (re yet another of your posts) !!! e.g. to match just a single character of a string ).

-Michael

Last edited by mschnell; 01-13-2018 at 06:24 PM.
mschnell is offline   Reply With Quote
Old 01-13-2018, 11:39 PM   #78
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Quote:
Originally Posted by goldenarpharazon View Post
The image shows 10 bytes that should be represented internally in the computer memory in EEL either as a string, or as an array.

So what is correlation between that string and the 15 digit hex number shown as "=2470141C33C0202" ?
That image is not related to EEL. It's a sysex header template from Novation SL programmer's manual.
This one is a real header for my controller - "\xF0\x00\x20\x29\x03\x03\x12\x00\x02\x00\x02\x02\ x01\xF7";
And 2470141C33C0202 is a direct conversion of hex string above, which is, obviously, won't work as a substitute in EEL for that hex string.

Quote:
Originally Posted by mschnell View Post
To make such a statement nicer you could do a string that contains 128 characters just 0 and 1: 1 meaning to use the code represented by the position in the string, 0 meaning not to use it.

then the statement just is something like

Code:
allowstring = "000000000000000000000000000000011111111   ....

str_getchar(allowstring, str_getchar(str_in,pos) == 0x31 ? ....
Or you use match with a string containing the allowed characters. (BTW.: (re your other post), the second parameter of match needs to be a string, not a character (which is a number), and here you can use regular expressions (re yet another of your posts) !!! e.g. to match just a single character of a string ).
So, what should my code look like, to get it working? To find if "b" is in "tofu"?

Quote:
Originally Posted by mschnell View Post
-Michael
Pretty please? I'm tired of deleting this from every quote. Put it in your signature, where the web address is sitting.
fundorin is offline   Reply With Quote
Old 01-14-2018, 12:33 AM   #79
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,634
Default

Quote:
Originally Posted by fundorin View Post
So, what should my code look like, to get it working? To find if "b" is in "tofu"?
I am not accustomed with using RegEx, so I can't help. It was you requesting the use of RegEx in EEL, and with "match" here you are..
Quote:
Originally Posted by fundorin View Post
Pretty please? I'm tired of deleting this from every quote. Put it in your signature, where the web address is sitting.
IMHO, discussion-wise, it does not make much sense to quote the complete content of a post, but only quote the very relevant part that exactly the part of the answer you are just writing is referring to.

-Michael

Last edited by mschnell; 01-14-2018 at 02:11 PM.
mschnell is offline   Reply With Quote
Old 01-14-2018, 12:40 AM   #80
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Experimenting:
PHP Code:
pama "ak";
printf("---------\n");
printf("0 - %c\n"str_getchar(pama,0));
printf("1 - %c\n"str_getchar(pama,1));
match("a","abcdefg") ? printf("Found 1\n");
match("k","abcdefg") ? printf("Found 2\n");
match("*a*","abcdefg") ? printf("Found 3 - correct\n");
match("*k*","abcdefg") ? printf("Found 4\n");
match("*%s*","abcdefg",str_getchar(pama,0)) ? printf("Found 5 - incorrect\n");
match("*%s*","abcdefg",str_getchar(pama,1)) ? printf("Found 6 - incorrect\n");
match("*%{str_getchar(pama,0)}c*","abcdefg") ? printf("Found 7 - incorrect\n");
match("*%{str_getchar(pama,1)}c*","abcdefg") ? printf("Found 8 - incorrect\n"); 
output:
Code:
---------
0 - a
1 - k
Found 3 - correct
Found 5 - incorrect
Found 6 - incorrect
Found 7 - incorrect
Found 8 - incorrect
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 11:35 PM.


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