sde Posted March 10, 2004 Posted March 10, 2004 I have this hex number: &H99 The method I need to send it too needs it as a byte. How do I convert this? Quote codenewbie
Denaes Posted March 11, 2004 Posted March 11, 2004 Easy Answer: Open up Calculator and make sure its on Scientific mode. Make sure Hex is clicked (just under the display). Punch in 99, click on binary and you get 10011001. Complex Answer: Google it. Its an annoying MOD math... basically Hex is a base16 number system. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. Decimal (the common number system) is base10 (deci, get it?). Binary is base2 (bi). Binary only has 0 and 1. 8 digits in a byte. theres a conversion forumla. Its been a year since I've used it, so I wouldn't trust my memory. Google for Base16 to Base2 conversions and you should find it. Maybe someone here is into Assembler and knows it well. Quote
Administrators PlausiblyDamp Posted March 11, 2004 Administrators Posted March 11, 2004 Not sure what you mean by this? Is your hex number stored as a string with the '&H' bit included or just as a number type? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sde Posted March 11, 2004 Author Posted March 11, 2004 thanks, but i meant how do i convert it within .net. sorry i wasn't completely clear. maybe this will help make more sense. i'm porting over a visualbasic.net midi class to c#. Here is how the method in vb: Public Sub SendMsg(ByVal Status As Byte, Data1 As Byte, Data2 As Byte) ... and here is how it is called: Midi.SendMsg(&H99, 38, 127) I'm trying to figure out how to call it the same way in c#. in peticular the &H99 part. Quote codenewbie
Administrators PlausiblyDamp Posted March 11, 2004 Administrators Posted March 11, 2004 IIRC, If you have the function declared correctly in C# then you should be able to call it like Midi.SendMsg(0x99, 38, 127) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sde Posted March 11, 2004 Author Posted March 11, 2004 ty plausibly =) i am now making MIDI music with form buttons... w00t!! ;) Quote codenewbie
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.