Author |
Topic: How to reencode to 32bit (Read 1809 times) |
|
Image_Engine
New Member

 MIDI-OX Rules!
Posts: 5
|
 |
How to reencode to 32bit
« on: Jul 7th, 2008, 4:40pm » |
Quote Modify
|
Hi I want to compare the raw midi with some values I have and do the comparison based on the 32bit number for speed sake. How do I compose my stat, dat1 and dat2 back into 32bit? Cheers Mark
|
|
IP Logged |
|
|
|
Jamie OConnell
Administrator
    


Gender: 
Posts: 2027
|
 |
Re: How to reencode to 32bit
« Reply #1 on: Jul 22nd, 2008, 2:33am » |
Quote Modify
|
Windows encodes the 32 bits sort of backwards, but it makes it easier to pull them apart. the Status Byte is first followed by Data1 and then Data2. All end up in the low 24 bits of the message. Here's a pseudo code formula you can use : DWORD dwVal = Status + (256 * Dat1) + (65536 * Dat2) 65536 = 256 * 256, effectively shifting the bytes into place. in C and C++ you can use: DWORD dwVal = Status + (Dat1 << 8) + (Dat2 << 16)
|
« Last Edit: Jul 22nd, 2008, 2:34am by Jamie OConnell » |
IP Logged |
--Jamie Music is its own reward.
|
|
|
Image_Engine
New Member

 MIDI-OX Rules!
Posts: 5
|
 |
Re: How to reencode to 32bit
« Reply #2 on: Jul 22nd, 2008, 4:34am » |
Quote Modify
|
Thanks Jamie Im only coding in VBScript to control ableton live (after running out of steam in Midi Translator) so I was just going to use 'case select' for efficient comparison (a lot easier to read too!) but also branch to a loop from the sink but it worked out a lot better just using an activex timer. I also wanted to make a html 'feedback panel' that gave visual feedback on current patch selected etc and set it just above Live window. That info helps a lot. Also, I sent a PM a little while back because I thought the forum had died ie no action on it for quite a while. Cheers Mark
|
|
IP Logged |
|
|
|
|