Help needed with bytes (4 Bytes)

For general discussion related FlowStone
Post Reply
Etgo23
Posts: 9
Joined: Fri Apr 19, 2013 5:57 am

Help needed with bytes (4 Bytes)

Post 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.
User avatar
tiffy
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Help needed with bytes (4 Bytes)

Post by tiffy »

Don't know if this is the 'best' way but sure this is an easy way from what you supplied:
Attachments
Decimal to Binary or Hex Conversion (Ruby) v2.fsm
(43.6 KiB) Downloaded 987 times
Decimal to Binary or Hex Conversion.fsm
(42.87 KiB) Downloaded 983 times
User avatar
tiffy
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Help needed with bytes (4 Bytes)

Post by tiffy »

You can also do it like this then the output gives only the required/necessary number of digits:
Attachments
Decimal to Binary or Hex Conversion (Ruby) v3.fsm
(43.64 KiB) Downloaded 974 times
Etgo23
Posts: 9
Joined: Fri Apr 19, 2013 5:57 am

Re: Help needed with bytes (4 Bytes)

Post 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 ? :)
User avatar
tiffy
Posts: 400
Joined: Wed May 08, 2013 12:14 pm

Re: Help needed with bytes (4 Bytes)

Post 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.
Etgo23
Posts: 9
Joined: Fri Apr 19, 2013 5:57 am

Re: Help needed with bytes (4 Bytes)

Post by Etgo23 »

Yeah i'm working with midi. Thanks you anyway. your schematics helped me with few other things.
tulamide
Posts: 2714
Joined: Sat Jun 21, 2014 2:48 pm
Location: Germany

Re: Help needed with bytes (4 Bytes)

Post 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)
"There lies the dog buried" (German saying translated literally)
User avatar
DaveyBoy
Posts: 131
Joined: Wed May 11, 2016 9:18 pm
Location: Leeds UK

Re: Help needed with bytes (4 Bytes)

Post by DaveyBoy »

Here's how I would do it

Very similar to what Tula is suggesting

Image

Divmod.fsm
(254.35 KiB) Downloaded 1017 times


Hope this helps :D
ChrisHooker
Posts: 55
Joined: Tue Jul 13, 2010 10:02 pm

Re: Help needed with bytes (4 Bytes)

Post by ChrisHooker »

...Or in only green prims:
Integer to Split-Hex.fsm
(54.49 KiB) Downloaded 1028 times
Etgo23
Posts: 9
Joined: Fri Apr 19, 2013 5:57 am

Re: Help needed with bytes (4 Bytes)

Post 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!
Post Reply