It is currently Fri Mar 29, 2024 9:46 am


28-bit integer???

Hauptwerk software technical support only. Please make sure you have read the manual, tutorials and FAQ pages before requesting support.
  • Author
  • Message
Offline

dcaton

Member

  • Posts: 76
  • Joined: Sun Jan 29, 2017 1:12 pm
  • Location: Lighthouse Point, Florida

28-bit integer???

PostMon Oct 23, 2017 11:00 am

Martin:

Could you please explain the 28-bit signed integer format, listed on pg. 222?

A search in this forum came up empty, and I can't find any reference to such an animal on Google, except for some obscure Norsk Data computer that was crippled down to 28 bits to get around some export restrictions, but that was decades ago. I'm not aware of any operating system or language that uses anything other than multiples of 8-bits for integers.

In any case, bits 2 and 3, plus the 7 MSB's in byte 1 and the 7 LSB's in byte 4 add up to 30 bits. What am I missing here?

Thanks.
Don
Offline

HeAu

Member

  • Posts: 105
  • Joined: Sat May 21, 2005 1:33 pm
  • Location: Austria, Salzburg

Re: 28-bit integer???

PostMon Oct 23, 2017 11:18 am

Couldn't it be a typo, meaning 128 bit?
Rgds
Heau
Offline

dcaton

Member

  • Posts: 76
  • Joined: Sun Jan 29, 2017 1:12 pm
  • Location: Lighthouse Point, Florida

Re: 28-bit integer???

PostMon Oct 23, 2017 11:23 am

4 bytes = 32 bits
Offline

dcaton

Member

  • Posts: 76
  • Joined: Sun Jan 29, 2017 1:12 pm
  • Location: Lighthouse Point, Florida

Re: 28-bit integer???

PostMon Oct 23, 2017 11:27 am

Ah, it seems that data bytes in MIDI always have the MSB set to 0, which only leaves 7 bits for data and 7 *4 = 28.

But that doesn't explain why byte 5 (value byte 1) says 7 most significant bits. Typo?
Offline
User avatar

mdyde

Moderator

  • Posts: 15446
  • Joined: Fri Mar 14, 2003 1:19 pm
  • Location: UK

Re: 28-bit integer???

PostMon Oct 23, 2017 12:48 pm

Hello Don,

The documentation is actually correct:

28-bit signed integer variable status sys-ex message format:
- Byte 1: 0xf0 - system exclusive start.
- Byte 2: 0x7d - fixed manufacturer ID.
- Byte 3: 0x1a - message type code for Hauptwerk 28-bit signed integer variable status message.
- Byte 4: variable ID (see list below).
- Byte 5: variable value byte 1 (most significant 7 bits).
- Byte 6: variable value byte 2.
- Byte 7: variable value byte 3.
- Byte 8: variable value byte 4 (least significant 7 bits).
- Byte 9: 0xf7 - end of system exclusive message.


As you realised, only 7 bits of any given MIDI byte can be used for data, hence four MIDI bytes can hold a maximum of 7x4 = 28 bits in total.

The maximum value range of a 28-bit signed integer is -134217727 to 134217727. To determine the bytes that would be sent for any given value within that range you simply need to take the least 7 significant bits of your value and put them in byte 8, then take the next least significant 7 bits and put them in byte 7, etc., i.e.:

Byte 4 = ( [28-bit integer value] >> 21 ) & 0x7f
Byte 5 = ( [28-bit integer value] >> 14 ) & 0x7f
Byte 6 = ( [28-bit integer value] >> 7 ) & 0x7f
Byte 7 = ( [28-bit integer value] >> 0 ) & 0x7f

Do the inverse if you want to convert it to the other way, i.e. multiply by 0x7f and shift left 7 bits more for each consecutive MIDI byte (starting with the least significant), summing the result.
Best regards, Martin.
Hauptwerk software designer/developer, Milan Digital Audio.

Return to Technical support

Who is online

Users browsing this forum: No registered users and 8 guests

cron