01-10-2018, 07:59 AM | #41 | |
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,746
|
Quote:
|
|
01-10-2018, 08:41 AM | #42 | |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
num1 = sprintf(#,"\\x%02X", position); 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. |
|
01-10-2018, 09:58 PM | #43 | |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
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. |
|
01-11-2018, 12:33 AM | #44 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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 |
01-11-2018, 03:02 AM | #45 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Sure!
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. |
01-11-2018, 05:37 AM | #46 | ||
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
So, it's time to figure out strings in EEL.
This is what Justin wrote: Quote:
Quote:
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 Code:
786433, Last edited by fundorin; 01-11-2018 at 06:09 AM. |
||
01-11-2018, 06:39 AM | #47 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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: |
01-11-2018, 06:59 AM | #48 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Last edited by mschnell; 01-11-2018 at 07:08 AM. |
01-11-2018, 08:20 AM | #49 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
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] 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... |
|
01-11-2018, 10:47 AM | #50 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
|
01-12-2018, 12:52 AM | #51 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
This is more OSC related stuff, but, still: why sending
Code:
DEVICE_PREV_TRACK t/device/track/- DEVICE_NEXT_TRACK t/device/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. |
01-12-2018, 06:31 AM | #52 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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. |
01-12-2018, 12:51 PM | #53 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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)))); |
01-12-2018, 03:08 PM | #54 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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;); ); Code:
int_out = floor(value * 12); |
01-13-2018, 01:53 AM | #55 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
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 |
01-13-2018, 02:58 AM | #56 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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. |
01-13-2018, 04:28 AM | #57 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
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 |
|
01-13-2018, 05:10 AM | #58 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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: |
01-13-2018, 08:08 AM | #59 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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); ); ); ); 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. |
01-13-2018, 09:57 AM | #60 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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] 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. |
01-13-2018, 10:25 AM | #61 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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]); ); |
01-13-2018, 10:35 AM | #62 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
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 |
|
01-13-2018, 10:48 AM | #63 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
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 |
|
01-13-2018, 11:01 AM | #64 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
You're right. No need to convert text strings from Reaper. Cool!
|
01-13-2018, 11:26 AM | #65 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
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. |
01-13-2018, 11:43 AM | #66 |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
|
01-13-2018, 11:57 AM | #67 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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? |
01-13-2018, 12:14 PM | #68 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
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 |
|
01-13-2018, 01:25 PM | #69 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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? |
01-13-2018, 02:32 PM | #70 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
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. |
|
01-13-2018, 02:39 PM | #71 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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|\-|'", "");? |
01-13-2018, 02:46 PM | #72 |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Sometimes it might be really nice to have regex library functions available in EEL
-Michael |
01-13-2018, 02:55 PM | #73 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
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) ? ( |
01-13-2018, 03:29 PM | #74 | ||
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
Quote:
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. |
||
01-13-2018, 03:39 PM | #75 | |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
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"); |
|
01-13-2018, 04:08 PM | #76 | |
Human being with feelings
Join Date: Feb 2016
Posts: 189
|
Quote:
So what is correlation between that string and the 15 digit hex number shown as "=2470141C33C0202" ? |
|
01-13-2018, 06:15 PM | #77 | |
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
then the statement just is something like Code:
allowstring = "000000000000000000000000000000011111111 .... str_getchar(allowstring, str_getchar(str_in,pos) == 0x31 ? .... -Michael Last edited by mschnell; 01-13-2018 at 06:24 PM. |
|
01-13-2018, 11:39 PM | #78 | ||
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Quote:
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:
Pretty please? I'm tired of deleting this from every quote. Put it in your signature, where the web address is sitting. |
||
01-14-2018, 12:33 AM | #79 | ||
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,789
|
Quote:
Quote:
-Michael Last edited by mschnell; 01-14-2018 at 02:11 PM. |
||
01-14-2018, 12:40 AM | #80 |
Banned
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
|
Experimenting:
PHP Code:
Code:
--------- 0 - a 1 - k Found 3 - correct Found 5 - incorrect Found 6 - incorrect Found 7 - incorrect Found 8 - incorrect |
Thread Tools | |
Display Modes | |
|
|