Search:
Submit Search


28-bit integer???

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

28-bit integer???

Postby dcaton » Mon Oct 23, 2017 12:00 pm

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
dcaton
Member
 
Posts: 59
Joined: Sun Jan 29, 2017 2:12 pm
Location: Lighthouse Point, Florida

Re: 28-bit integer???

Postby HeAu » Mon Oct 23, 2017 12:18 pm

Couldn't it be a typo, meaning 128 bit?
Rgds
Heau
HeAu
Member
 
Posts: 89
Joined: Sat May 21, 2005 2:33 pm
Location: Austria, Salzburg

Re: 28-bit integer???

Postby dcaton » Mon Oct 23, 2017 12:23 pm

4 bytes = 32 bits
dcaton
Member
 
Posts: 59
Joined: Sun Jan 29, 2017 2:12 pm
Location: Lighthouse Point, Florida

Re: 28-bit integer???

Postby dcaton » Mon Oct 23, 2017 12:27 pm

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?
dcaton
Member
 
Posts: 59
Joined: Sun Jan 29, 2017 2:12 pm
Location: Lighthouse Point, Florida

Re: 28-bit integer???

Postby mdyde » Mon Oct 23, 2017 1: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.

[Please use email or the Contact page if you need to contact us privately, rather than private forum messages.]

Image
User avatar
mdyde
Moderator
 
Posts: 10644
Joined: Fri Mar 14, 2003 2:19 pm
Location: UK


Return to Technical support

Who is online

Users browsing this forum: No registered users and 1 guest