Jump to content

Scaling encoders from a look up table.


levon
 Share

Recommended Posts

since my original post wasnt getting any replys ive changed the title and tried to clarify my questions. was originaly few q's about controlling different messages with one knob and scalling

Read second post.

Few more questions from me, while im planning my interface for my G9.2tt midi controller HERE

So what i plan to do is have 4 knobs lets call them K1 K2 K3 and K4

i want to scale knob one to send 0-14 (00h-0Eh) and deppending on what k1 is, the other 3 Knobs will have different ranges.

so when K1 = 0..... k2, k3, k4 will have a minimum of 00h, but maxium will be 14h, 3Fh, 3Fh respectively

when K1= 1.... K2, K3, K4 will have min= 00h, max= 01h 16h, 2Fh respectively.

and so forth .

and i want to do this for about 11 groups of knobs which means that ill be running 11 if loops for different knobs, will this slow my midibox down too much

ill post psedocode for what i want to do, is this right?

Knobx(address,min,max)
if 0x00 = 0 #if knob 1 of the first group of knobs equals 1
  K2(0x01,00,14)
  K3(0x02,00,3F)
  K3(0x03,00,3F)
elseif 0x00 = 1
  K2(0x01,00,01)
  K3(0x02,00,16)
  K3(0x03,00,2F)
etc etc

Now if i have a list of 14 elseif for for k1, and then i have say 11 different groups (A1-K1) is that going to impact on the performance of my midibox. all of this will be sending midi sysex.... of 7 bits, so with 11 groups of an average of 15 elseif situations per group, each with 3 variables its controlling..

now to state it a bit clearer...

at any time, there will be 11 'if' loops running at a time, scaling 3 variables each, that are sent out as midi SysEx the input ill most likely be digital encoders.

hmm, my eyes have gone cross eyed, if anyone cant understand that ill try and explain it better.

thanks :)

Link to comment
Share on other sites

So ive been reading the MIOS code examples and tried hacking together a few bits a pieces, and had a thought about what im trying to do.

i want to have 1 digital encoder that effects the limits of 3 others.

so when you change 2, 3, or 4 it will check the state of 1. and if the values of 2, 3, or 4 try to go above the set range, it will bring them back down to the maximum.

so ill make a look up table, and then when the value is  over that, it will scale it back down to the maximum.

const unsigned char Enc_event_map[4][3] = {
//   k2   k3   k4 ... max depending on what k1 is.
  {0x10, 0x00, 0x0f}, // k1 =00
  {0x11, 0x00, 0x1f}, // k1 =01
  {0x12, 0x00, 0x2f}, // k1 =02
  {0x13, 0x00, 0x3f}, // k1 =03
etc...
  };
in void 'ENC_NotifyChange('  something like:
// overrun check: if new value is higher then the maximum allowed, scale down.
    if( new_value >= enc_event_map[k1][pin] +1 )
      new_value = pot_event_map[k1][pin];  

the code is quite rough.. but is that the general direction i should be going in?

Link to comment
Share on other sites

Sorry bud I have been meaning to reply to this... Life is hectic in strydland right now.

First off, I should clarify...

if the values of 2, 3, or 4 try to go above the set range, it will bring them back down to the maximum.

That's limiting, not scaling... Is that what you want to do? Or did you want to stick with the original idea of having a min and max?

Anyway... As with most things, there's more than one way to do this... Personally, I would do something like this:

You use three pairs of variables. These would be K1min, K1max, K2min, K2max, K3min, K3max.

When you move K1, it should set these variables as required.

When you move K2,3 or 4, it always does the same thing: calls a function which scales the value according to the preloaded min and max, and sends it.

Nice and simple :)

Link to comment
Share on other sites

sorry... im still considering weather to use encoders or pots.. so with encoders its limiting, pots its scalling, both methods would use the same variables, but process them differently. so for now i guess i will go for Encoders, and later down the track if i need to re write the code for pots i will.

i know that the min of every parameter is 0, so i dont need a minimum value.

but deppending on what K1 is equal to, i want K2,K3,K4's max to change

ie

when K1=0 ,the max of K2, K3, K4 are 01,1A,64 respectivley

K1=1 ,the max of K2, K3, K4 are 6A,14,32 respectivley

and so on and so on till K1=14

So it would be better having 1 list(array) of all the variables in a look up table, right? like this

//  k2    k3    k4 ... max depending on what k1 is.
  {0x01, 0x1A, 0x64}, // max when k1 =0
  {0x6A, 0x14, 0x32}, // max when k1 =1
etc...
  {0x13, 0x00, 0x3f}, // max when k1 =14
  

and i also want about 11 sets for the different effects that i will be controlling.

which would mean i would need 3 x 11 x 14 variables for the maximum values.

A2,A3,A4 when A1=0-14

B2,B3,B4 when B1=0-14

...

K2,K3,K4 when K1=0-14

which is a stupid amount of variables.

Instead i could have 1 table per effect, and then if i want to find the value of effect bank A, knob 2, when A1 =5 i just have to look up enc_table_A[4][0].

or am i missing something?

Link to comment
Share on other sites

sorry... im still considering weather to use encoders or pots.. so with encoders its limiting, pots its scalling,

Hmm not necessarily... Let me demonstrate the difference:

Scaling:

Min = 0, max = 16 for example

In=0  Out=0

In=1  Out=0

In=2  Out=0

...

In=8  Out=1

In=9  Out=1

...

In=16 Out=2

In=17 Out=2

...

In=24 Out=3

...

In=32 Out=4

...

In=127 Out=16

Limiting:

Min = 0, max = 16 for example

In=0  Out=0

In=1  Out=1

In=2  Out=2

...

In=8  Out=8

In=9  Out=9

...

In=16 Out=16

In=17 Out=16

...

In=24 Out=16

...

In=32 Out=16

...

In=127 Out=16

Whether the 'In' value comes from a variable which is altered by an encoder, or is the direct result of ADC from a pot, makes no difference. Whether you're limiting or scaling has a great deal of difference with respect to the application though...I think that maybe you should take a step back, and figure out what you're trying to do exactly..

i know that the min of every parameter is 0, so i dont need a minimum value.

My method would still work.

when K1=0 ,the max of K2, K3, K4 are 01,1A,64 respectivley

K1=1 ,the max of K2, K3, K4 are 6A,14,32 respectivley

and so on and so on till K1=14

Is there supposed to be a pattern there or is it just arbitrary?

and i also want about 11 sets for the different effects that i will be controlling.

which would mean i would need 3 x 11 x 14 variables for the maximum values.

...which is a stupid amount of variables.

Sounds like bankstick territory...

Link to comment
Share on other sites

Hmm not necessarily... Let me demonstrate the difference:

Scaling:

Min = 0, max = 16 for example

In=0  Out=0

In=1  Out=0

In=2  Out=0

...

...........

Whether the 'In' value comes from a variable which is altered by an encoder, or is the direct result of ADC from a pot, makes no difference. Whether you're limiting or scaling has a great deal of difference with respect to the application though...I think that maybe you should take a step back, and figure out what you're trying to do exactly..

ok i see what your saying. read below...

My method would still work.

ok cool im just concered that having that many variables would take up more space, or slow the processor down.. but what ever you think is the smarter way of doing it i will do.

Is there supposed to be a pattern there or is it just arbitrary?

my G9.2tt uses midi system exclusive data to change any setting on the pedal. so lets say i want to change the efx1 block

i would send the message F0 51 42 31 01 01 01 00 F7 to change it to the auto wah effect

or F0 51 42 31 01 01 02 00 F7 to change it to the booster effect.

so i have come to F0 51 42 31 AA BB CC DD F7

where AA is the Effects block (ranging from 01 to 09) then other functions use up to 19

BB is the parameter being changed

and CC and DD is the value, DD only used when CC gets higher then 7F (only on the delay times)

sending F0 51 42 31 a01 b01 c01 d00 F7

a01 is the effects block (efx1 in this case)

b01 the parameter (01 is which effect)

c01 is which effect (auto wah)

d00

each effect block has a different number of effects in it.. so a different range.. and then each effect has 4 parameters, each with different ranges.

so the auto wah has 4 parameters.. position, sens, resonance, volume that have a max of 01h, 14h ,1Ah and 64h respectivley

the booster has different max for each parameter.

ive got a list in open office calc(excel) of the max of each effects parameters, and they wont need to change ever. so is it better to remove it from the main application and put that on the bankstick?

and in regards to limiting and scalling.. if i was using a Pot, i would want the full range to go from left at 0 to right at the max of that parameter. for encoders i would want it to max out at the max of the parameter turning clockwise, and bottom out at 0 turning counter clock wise.

Sounds like bankstick territory...

Link to comment
Share on other sites

Ohhh OK! *light goes on*

Wow that's one ugly MF midi implementation! I'm sorry man I've been assuming that the sysex thing you mentioned in that other thread was separate to this and you were just sending CC's here. I've been giving you some bad advice. I have to admit that I was really starting to wonder why you were making things so complex, I'm glad that I assumed I was confused  ;)

I'll give it some more thought.... I think you're on the right track mate. It would be cool if I could get a copy of that XLS...

Have you looked at the Midibox UC?

Link to comment
Share on other sites

Hey Stryd_one, yes the midi implimentation is preaty bad, and zoom wont do anything to fix it. they wouldnt give me a midi sysex implimentation chart as they dont want the end user to be able to use it...so ive had to work it out by monitoring in midi-ox.

ive been a bit overwhelmed by all this midi box stuff, so i probably havent been explaining it so well. ive had a quick look at midibox UC, it looks great, i like the idea of the screens displaying the values in a list like that. though for my midibox i dont want to have any menus, i want every controll available from the knobs, ill have a better look through it over the weekend, but it looks like it will save me coding alot of stuff that is already done,

ill clean up the xls and finish filling in all the values on the weekend... and send it to you PM

thanks, Levon

Link to comment
Share on other sites

hey Stryd, did you make sense of the file i sent you? it is a bit of a mess.

Kinda. Sorta. Not really ::) I don't think it's your fault. I think I can safely say that in over 25 years as a musician that is the worst implementation I have ever seen of any instrument. Probably the worst seen by anyone, ever. Obviously it's intentional by zoom >:(

any better idea of how it can be done now?

Nah man, the way you are doing it seems to be the right direction. It's all over the place, but I just don't see any way around it :(

Edit: Man I am really sorry for delaying you. I honestly thought that you were confused or something and I was trying to help... I never suspected what it was really like :(

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...