Old 10-19-2017, 12:09 AM   #1
wyged
Human being with feelings
 
Join Date: May 2017
Posts: 1
Default Toggle OSC values

So i have the following script:

@midimsg

msg1 == 0x90 ? + msg2 == 0x40 ? + msg3 == 0x7f ? oscsend (MQ_OSC,"/flash/1", 1);
msg1 == 0x80 ? + msg2 == 0x40 ? + msg3 == 0x7f ? oscsend (MQ_OSC,"/flash/1", 0);

When I push a key on APC Mini controller i get the OSC message "/flash/1 1.000(float)"

When I release the key, i get the message "/flash/1 0.000(float)".

Question:

How can i make it so that when i first press the key i will get "/flash/1 1.000(float)", and at the second press "/flash/1 0.000(float)" ?

Thanx
wyged is offline   Reply With Quote
Old 10-19-2017, 10:32 AM   #2
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 78
Default

One will need to write some simple code in the @midimsg section that tracks the state of the button using a flag variable in the OSCII-bot (EEL2) code.

Firstly one can just ignore the button release midi message entirely unless the release is wanted for other reasons e.g. to do something with the button's LED state: the release is not of interest since you want successive button presses to act as a toggle.

Then one can just write some code that
- detects the press and sets a "flag" on the (first) press if the flag is not clear
- clears the flag on a press if the flag is already set.

Then if the flag is set it is a first press and if it is clear it is a subsequent press etc etc and you send the corresponding appropriate OSC output value. The flag's value creates the toggle function.

Conventionally flags should have the values 0 and 1 which then makes them easy to use in the EEL2 "if" statement.

It's a shame the APC Mini doesn't come with any editor for its midi mappings to create a toggle but Akai are expecting it will only be mapped to Ableton.
goldenarpharazon is offline   Reply With Quote
Old 12-09-2017, 01:40 AM   #3
fundorin
Human being with feelings
 
fundorin's Avatar
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 310
Default

I'm also sitting on the same task now. The problem with flags is that they should be created for each and every toggle, from the start. If you have a physical button, which function/osc address is changed, based on the current bank selection, one should add flags for each possible osc address, like "\surf\bank9\button1\ 1.0" or "\surf\bank37\button1\ 1.0" and this would be a huge amount of work, while we don't have normal arrays in EEL2.

For example, my controller have "user assignable" mode for all available controls. There are 8 sets of 8 different controls. 16 banks. Which gives us 1024 OSC commands. Add 7 shift buttons, that can be pressed not only one at the time, but also in combinations with each other and the controls themself. You'll end up with more than 262 144 theoretically possible osc commands, that would be generated by the script. That's a huge number, I must say, and it can easily be multiplied with other available controls, like "pages", for example. It would be exhausting, adding flags for all of them. I don't say that so many controls are necessary, but that's not the point of my rant.

Technically, this could be solved with pre-generating empty arrays (not mapped to the particular memory slot range), which would be automatically populated with control's states later, during the actual session in Reaper.

I already have "assignable mode" code working properly, but encountered the very same issue as you did, when one can't map a button on the controller to the fx parameter in Reaper, that is also a button. It's possible, but not for toggling. If one wants that mapped parameter to be turned on, he should keep pressing the corresponding button all the time, which is obviously, not an option.

So, I think that adding "toggle" checkmark or "OSC mode" selector (like that "CC mode" option) to this menu could be the best workaround ever. Or enabling \b and \t OSC prefixes for mapping. For now, only \f or \n are properly working for mappings.
Encoders support would also be nice. Again, different modes are already implemented in "CC mode" list, but not for OSC.



P.S. "fundorin" in the address name isn't for vanity purposes. In fact, letters in the word are modified respectively by 8 shift buttons on the controller, generating that ridiculous amount of possible combinations of commands!

Last edited by fundorin; 12-09-2017 at 02:34 AM.
fundorin is offline   Reply With Quote
Old 12-09-2017, 03:42 AM   #4
fundorin
Human being with feelings
 
fundorin's Avatar
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 310
Default

This, but for OSC:


Truly needed. Configurable options in .ReaperOSC files, maybe?
fundorin is offline   Reply With Quote
Old 12-09-2017, 10:01 AM   #5
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 3,673
Default

Quote:
Originally Posted by fundorin View Post
You'll end up with more than 262 144 theoretically possible osc commands ...
What is the problem with that ?
You can store the states in bits of an array (AFAIK, at up to some 24 Bits per array slot), and you can construct the commands on the fly via sprintf().

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 12-09-2017 at 11:41 AM.
mschnell is offline   Reply With Quote
Old 12-09-2017, 10:13 AM   #6
goldenarpharazon
Human being with feelings
 
Join Date: Feb 2016
Posts: 78
Default

With a good understanding of the quantity of bank states to be determined and their fixed nesting structure (which you have done for the Novation's banks) then it's not too hard to statically encode each button flag as a bit in a look up table of bits (rather than bytes) and then be done by tracking the whole assumed state of the hardware device. The disliked table and its indexing can be hidden or abstracted from most of the code by suitable "lookup" and "set" functions.

It would be nice to move this state tracking into Reaper as suggested though, but the devs then face the same challenge, albeit perhaps dynamically only when a particular OSC string is actually mapped. Doing this could also also give some OSC feedback too to switch on button LEDs etc.

Alternatively one could, in your OSCII-bot script, have some kind of control surface configuration file so that buttons can have a varying pre-set function beyond, say just toggle. This file would be read in as part of the control surface @init section, and this then could give flexibility in a button's set up (ie its intended function) without needing script code changes. Such a config file could also be used to set a common function of a button across banks without repetitive manual learning at the Reaper end.

Last edited by goldenarpharazon; 12-09-2017 at 10:22 AM. Reason: SNAP! Michael came up with similar answer at the same time
goldenarpharazon is offline   Reply With Quote
Old 12-09-2017, 11:23 AM   #7
fundorin
Human being with feelings
 
fundorin's Avatar
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 310
Default

Quote:
Originally Posted by goldenarpharazon View Post
it's not too hard to statically encode each button flag as a bit in a look up table of bits
Could you, please, be so kind an just teach me of how to generate variable names like this "text[1]" and store info in them, like arrays with EEL2?

I don't want to mess with bits at all. One should develop a method to store flags. Ok. Bits. Then, integers need to be stored. Bits won't work. Ok. Let's find some new trick. Then, strings need to be stored. Integers won't work. Now, what?
I want arrays or to use strings as array, without messing with memsets or offsets in memory. Is it possible?
fundorin is offline   Reply With Quote
Old 12-09-2017, 11:53 AM   #8
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 3,673
Default

Quote:
Originally Posted by fundorin View Post
Is it possible?
No problem if you write a new OSCII-Bot program v2.0 .
Right now we need to live with what Justin very kindly provided to us for free.

The ELL language is crafted to be very simple for speed sake. That is why it only has a single data type for variables and array slots, which is floating point so that it can deal with audio samples. (EEL is originally crafted for audio plugins (JSFX) and hard to beat in that discipline.)

Nonetheless I have been able to store as well some 23 bits as 5 bytes in such a variable.

And the handling of strings (all of them being located in slots of an array) might be unfamiliar for users of other languages, but perfectly workable.

-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 12-09-2017 at 12:49 PM.
mschnell is offline   Reply With Quote
Old 12-09-2017, 12:00 PM   #9
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Germany
Posts: 3,673
Default

Quote:
Originally Posted by fundorin View Post
Could you, please, be so kind an just teach me of how to generate variable names like this "text[1]" and store info in them, like arrays with EEL2?
The string slots are accessed just by the numbers that are their addresses. EEL knows them from normal number as they are used as arguments for string functions or by the "#" operator for named strings inhabitating additional slots, or (as a special syntax candy) with the += operator being mapped to strcat(), while the = operator (like any other) simply works on the numbers.

In my OSCII-Bot script I do:

Code:
@init:
l2s           = 0;                        // strings base slot
l22           = 0;                        // array midi CC messages msg2 base


n = 0;

// Main Fader  <-> 0x24
  strcpy(n+l2s,  "/lr/mix/fader");
  l22[n]        = 0x24;
  n += 1;

// Fader 4 <-> 0x1d
  strcpy(n+l2s,  "/ch/04/mix/fader");
  l22[n]        = 0x1d;
  n += 1;
  
// Fader 5 <-> 0x1e
  strcpy(n+l2s,  "/ch/05/mix/fader");
  l22[n]        = 0x1e;
  n += 1;
  
// Fader 6 <-> 0x1f
  strcpy(n+l2s,  "/ch/06/mix/fader");
  l22[n]        = 0x1f;
  n += 1;
...


@timer
!t ? (
t -= 1;
ti ? (
  ti -= 1;		
  l2o[ti] = -1;
  oscsend(XR18, ti+l2s);
  printf("-> %s\n", ti+l2s);
);
-Michael
__________________
www.boa-sorte.de

Last edited by mschnell; 12-09-2017 at 12:50 PM.
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 05:32 AM.


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