Page 1 of 1

Help needed with bytes (4 Bytes)

PostPosted: Thu Jan 10, 2019 9:12 pm
by Etgo23
Hey!
I have an problem that i have not figured out yet!
I'm creating editor for Roland Jd-xi and some parameters uses 4 bytes.
When i move knob to value 15 then parameter value is 0F.
As seen in the picture.
Image
What i'm trying to do is when i move knob over 15. Lets say for 16. I want parameter value look like "0101" and so on
What is the best way to this?
hopefully I explained clearly.

Re: Help needed with bytes (4 Bytes)

PostPosted: Thu Jan 10, 2019 11:52 pm
by tiffy
Don't know if this is the 'best' way but sure this is an easy way from what you supplied:

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 1:15 am
by tiffy
You can also do it like this then the output gives only the required/necessary number of digits:

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 8:53 am
by Etgo23
Hey thanks!
That gave some ideas what i can use.
Im sorryu that i didnt explain it clearly enough. Hopefully this time i explain.

This is the sysex string for delay level "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 00 39 F7"
If i move knob to value 15. String looks "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 0F 39 F7".
But if i move knob to value 16. String is "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 10 39 F7" which is wrong value.
What im trying to achieve is when the knob value is 16 the sysex string should look like this"F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 01 00 39 F7" and so on.

So after every 15 steps knob have to add hex to "00 -> 01" and reset the knob to value 00.

Is this clear enough ? :)

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 10:16 am
by tiffy
Etgo23 wrote:Hey thanks!
That gave some ideas what i can use.
Im sorryu that i didnt explain it clearly enough. Hopefully this time i explain.

This is the sysex string for delay level "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 00 39 F7"
If i move knob to value 15. String looks "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 0F 39 F7".
But if i move knob to value 16. String is "F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 00 10 39 F7" which is wrong value.
What im trying to achieve is when the knob value is 16 the sysex string should look like this"F0 41 10 00 00 00 0E 12 18 00 06 20 08 00 01 00 39 F7" and so on.

So after every 15 steps knob have to add hex to "00 -> 01" and reset the knob to value 00.

Is this clear enough ? :)


It appears to me you are working on a Midi schematic? Sorry, but I do not have any experience with Midi, maybe someone else can help out there.

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 11:08 am
by Etgo23
Yeah i'm working with midi. Thanks you anyway. your schematics helped me with few other things.

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 6:35 pm
by tulamide
There are a few things that confuse me from your description. For example, you talk about 4 bytes, but the example is about 2 bytes. You talk about 15 steps, when it actually is 16 steps (Hex 00 to 0F). But I can give you a general tip.

Use modulus! The result of a modulo division will be the integer remainder. The higher number can then be generated with normal integer division ("floor" rounded).

Code: Select all
Example:
knob value is 14
14 % 16 = 14 (hex 0E)
14 / 16 = 0 (hex 00)

knob value is 17
17 % 16 = 1 (hex 01)
17 / 16 = 1 (hex 01)

knob value is 29
29 % 16 = 13 (hex 0D)
29 / 16 = 1 (hex 01)

Re: Help needed with bytes (4 Bytes)

PostPosted: Fri Jan 11, 2019 11:15 pm
by DaveyBoy
Here's how I would do it

Very similar to what Tula is suggesting

Image

Divmod.fsm
(254.35 KiB) Downloaded 78 times


Hope this helps :D

Re: Help needed with bytes (4 Bytes)

PostPosted: Sat Jan 12, 2019 3:04 am
by ChrisHooker
...Or in only green prims:
Integer to Split-Hex.fsm
(54.49 KiB) Downloaded 78 times

Re: Help needed with bytes (4 Bytes)

PostPosted: Sat Jan 12, 2019 9:19 am
by Etgo23
Hey!
Hahah! Sorry to confuse you tulamide. Maybe i should drink more coffee before starting topics like this.

Hmm. interesting ideas. I'll will try these methods. Thanks guys!