forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C Arrays [Solved]

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Aug 06, 2009 10:58 am    Post subject: C Arrays [Solved] Reply with quote

Hi

Can anyone tell me how to do the following in VDS. I'm trying to create an array of char's(bytes) but I don't want the members converted to binary. This is for a Windows API call.

The C code is this:
Code:
unsigned char  sysEx[] = {0xF0, 0x7F, 0x7F, 0x01, 0x02, 0xF7};

If I do this:
Code:
%s = @binary(byte,$F0)@binary(byte,$7F)@binary(byte,$7F)@binary(byte,1)@binary(byte,2)@binary(byte,$F7)

Will the contents of each byte be read incorrectly by the API function because they are in binary??

The other C way is this but its even more confusing!!
Code:
unsigned long  buffer[] = { ((unsigned long)MEVT_LONGMSG<<24) | 7, 0x017F7FF0, 0x00F70201};

I've been trying to get this MIDI API to work for months and I'm very close to giving up for the first time ever!!

I really hope someone can help.

Thanks

David.


Last edited by dmonckton on Tue Aug 11, 2009 3:26 pm; edited 1 time in total
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Aug 06, 2009 12:33 pm    Post subject: Reply with quote

David,
The first C line and your VDS example are the same. They should give you the same value. Now for the second C line below please post the value for MEVT_LONGMSG which is probably a #define directive. I need this value since the code below is shifting it 24bits to the left then it performs a bitwise OR operation on the result of the left shift. The other two values are additional elements in the array of long called buffer. To create this buffer in VDS you would just need the following VDS code.

Code:

# The next line of code performs the following.
# unsigned long  buffer[] = { ((unsigned long)MEVT_LONGMSG<<24) | 7, 0x017F7FF0, 0x00F70201};
# NOTE: You will need the SSBitwise VDS unit to do this.  You can download it here
# http://forum.vdsworld.com/viewtopic.php?t=1860&start=0&postdays=0&postorder=asc&highlight=ssbitwise

%b = @BINARY(DWORD,@ssbitor(@ssbitlshift(%%MEVT_LONGMSG,24),7))@BINARY(DWORD,$01757550)@BINARY(DWORD,$00F70201)


Notice that you will need the SSBitwise VDS unit to do this. There is also a couple of DLL's that can do the OR and Left Shift operations as well. %b should not be the same as buffer.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Thu Aug 06, 2009 3:02 pm    Post subject: Reply with quote

Hi and thanks so far...

From the mmsystem.h
Code:
const BYTE MEVT_LONGMSG = 0x80;

Ok what I did for...
Code:
((unsigned long)MEVT_LONGMSG<<24) | 7

was
Code:
@binary(byte,7)@binary(byte,0)@binary(byte,0)@binary(byte,$80)

is that wrong?
Back to top
View user's profile Send private message
vdsalchemist
Admin Team


Joined: 23 Oct 2001
Posts: 1448
Location: Florida, USA

PostPosted: Thu Aug 06, 2009 3:28 pm    Post subject: Reply with quote

dmonckton wrote:
Hi and thanks so far...

From the mmsystem.h
Code:
const BYTE MEVT_LONGMSG = 0x80;

Ok what I did for...
Code:
((unsigned long)MEVT_LONGMSG<<24) | 7

was
Code:
@binary(byte,7)@binary(byte,0)@binary(byte,0)@binary(byte,$80)

is that wrong?


No this should be correct... If you do the following you will find that the value is $80000007

Code:

%b = @binary(byte,7)@binary(byte,0)@binary(byte,0)@binary(byte,$80)
Info @Hex(@Val(%b),8)


This is the same value that you would get if you do this with the windows calculator in scientific mode and you perform the operations.

_________________
Home of

Give VDS a new purpose!
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
dmonckton
Contributor
Contributor


Joined: 09 Aug 2002
Posts: 117
Location: Lewes, U.K.

PostPosted: Mon Aug 10, 2009 12:20 pm    Post subject: Reply with quote

Hi

I've finally after months of frustration sent sysex data to my synth. I should be really happy but I'm just p****d o*f its taken me so long. I'll post the solution when I've cleaned it up a bit.

Thanks for all your help.

David.M
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group