User Forum    :: Powered by YaBB
  « MIDI-OX User Forum - How to reencode to 32bit »
Welcome, Guest. Please Login or Register.
May 9th, 2025, 1:20am


Home Home Help Help Search Search Members Members Login Login Register Register


   MIDI-OX User Forum
   MIDI-OX
   Scripting Questions
(Moderator: Jamie OConnell)
   How to reencode to 32bit
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   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 Quote Modify 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
*****






   
WWW Email

Gender: male
Posts: 2027
Re: How to reencode to 32bit
« Reply #1 on: Jul 22nd, 2008, 2:33am »
Quote Quote Modify 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 Quote Modify 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
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »


MIDI-OX User Forum » Powered by YaBB 1 Gold - SP 1.3.1!
YaBB © 2000-2003. All Rights Reserved.