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 


Defining a struct

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


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Jul 12, 2003 12:29 pm    Post subject: Defining a struct Reply with quote

I was trying to call a non vds dll wavemix32.dll which mixes the waves in real time and can play audio upto 8 channels simultaneously.
All the steps until the WaveMixPlay return OK flag(0). I think i made some mistake in defining the struct for MIXPLAYPARAMS. It may be a very easy task for those well versed with C/C++. Any ideas ?

Code:


DLL HEADER FILE (cpp)
---------------
relevant parts only

#define WMIX_OPENSINGLE 0 /* open the single channel specified by iChannel */
#define WMIX_OPENALL    1 /* opens all the channels, iChannel ignored */
#define WMIX_OPENCOUNT  2 /* open iChannel Channels (eg. if iChannel = 4 will create channels 0-3) */
UINT    WINAPI WaveMixOpenChannel(HANDLE hMixSession, int iChannel, DWORD dwFlags);
UINT    WINAPI WaveMixPlay(LPMIXPLAYPARAMS lpMixPlayParams);

#define WMIX_ALL      0x0001 /* stops sound on all the channels, iChannel ignored */
#define WMIX_NOREMIX  0x0002 /* prevents the currently submited blocks from being remixed to exclude new channel */
UINT    WINAPI WaveMixFlushChannel(HANDLE hMixSession, int iChannel, DWORD dwFlags);
UINT    WINAPI WaveMixCloseChannel(HANDLE hMixSession, int iChannel, DWORD dwFlags);

#define WMIX_USELRUCHANNEL      0x02
WORD wLoops;  /* 0xFFFF means loop forever */

VB CODE (BAS MODULE)
-------
Type MIXPLAYPARAMS
wSize As Integer
     hMixSession As Integer
     iChannel As Integer
     lpMixWave As Long
     hWndNotify As Integer
     dwFlags As Long
     wLoops As Integer

VDS CODE
--------

DIALOG CREATE,Wavemix,-1,0,240,160,class wavemix,
 DIALOG ADD,BUTTON,BUTTON1,102,12,64,24,BUTTON1
  DIALOG ADD,BUTTON,BUTTON2,100,86,64,24,BUTTON2
  DIALOG ADD,BUTTON,BUTTON3,100,160,64,24,BUTTON3
  DIALOG SHOW
%%file1 = @path(%0)1.WAV
%%file2 = @path(%0)2.WAV
%%file3 = @path(%0)3.WAV
%%file4 = @path(%0)4.WAV
%%file5 = @path(%0)5.WAV
%%file6 = @path(%0)6.WAV
LOADLIB @path(%0)WAVMIX32.dll
 %I = @lib(WAVMIX32,WaveMixInit,INT:)
 %J = @lib(WAVMIX32,WaveMixOpenChannel,INT:,%I,1,1)
 %K = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file1,,
 # the closing bracket at the end has been intentionally removed to
 # prevent it entering the variable %K 3434) for example.
 %L = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file2,,
 %M = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file3,,
 %N = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file4,,
 %O = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file5,,
 %P = @lib(WAVMIX32,WaveMixOpenWave,INT:,%I,STR:%%file6,,
 %Q = @lib(WAVMIX32,WaveMixActivate,INT:,%I,BOOL:TRUE)
    else
    ERROR -1
  end
  END
REM INFO %K | %L | %M | %N | %O | %P !
REM INFO ABOVE SHOWS THE POINTERS TO INTERNAL STRUCTURE IN THE FORM OF VALUES Successfully

:EVLOOP
wait event
goto @event()

:BUTTON1BUTTON
#CREATE STRUCT OF MIXPLAYPARAMS %S HOLDS THIS

%%hMixSession = %I
%%iChannel = 1
%%lpMixWave = %K
%%hWndNotify = """"

%T = @BINARY(word,0)%%hMixSession%%iChannel%%lpMixWave%%hWndNotify@BINARY(dword,WMIX_USELRUCHANNEL)@BINARY(word,1)
%S = @BINARY(word,@LEN(%T))%%hMixSession%%iChannel%%lpMixWave%%hWndNotify@BINARY(dword,WMIX_USELRUCHANNEL)@BINARY(word,1)
rem HERE STARTS THE PROBLEM APP CRASHES

%R = @lib(WAVMIX32,WaveMixPlay,INT:,%S)
 INFO %R
goto EVLOOP

:BUTTON2BUTTON

goto EVLOOP

:BUTTON3BUTTON

goto EVLOOP

:close

%J = @lib(WAVEMIX32,WaveMixCloseChannel,INT:,%I,1,1)
INFO %J !
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%K)
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%L)
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%M)
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%N)
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%O)
%J = @lib(WAVMIX32,WaveMixFreeWave,INT:,%I,%P)
%J = @lib(WAVEMIX32,WaveMixCloseSession,INT:,%I)
FREELIB @path(%0)WAVMIX32.dll
exit



Quote:

FROM THE WAVEMIX DLL HELP FILE:
WaveMixPlay() stores audio data in the queue of a channel and starts playback of that channel (if desired).

Syntax:
UINT WaveMixPlay(LPMIXPLAYPARAMS lpMixPlayParams)
lpMixPlayParams
a pointer to a MIXPLAYPARAMS structure, see below.
Returns:
Returns zero if the function was successful. Otherwise, it returns an error number. Possible error returns are:
MMSYSERR_INVALHANDLE
The specified channel has not been opened or the parameter lpMixWave was invalid.
MMSYSERR_NOMEM
WaveMix has run out of internal memory to queue up waves. Wait until some sounds complete and then try again.
MMSYSERR_ALLOCATED
The wave out device has not been allocated by this session. This can be done with WaveMixActivate().
Notes:
The MIXPLAYPARAMS structure has the following fields:
wSize
(WORD) Must be set to sizeof(MIXPLAYPARAMS).
hMixSession
(HANDLE) Handle that was returned by WaveMixInit().
iChannel
(int) The channel on which the wave should be played. This value is ignored if the WMIX_USELRUCHANNEL flag was set (see below).
lpMixWave
(LPMIXWAVE) A wave which was opened using WaveMixOpenWave().
hWndNotify
(HWND) a window handle to receive the MM_WOM_DONE message when the wave completes. If this value is set to NULL then the message will not be posted.
When sent, the MM_WOM_DONE message contains the channel number in wParam and a pointer to the LPMIXWAVE structure in the lParam. You can use the pointer in lParam in the call to WaveMixFreeWave().
Note: the value of MM_WOM_DONE is 0x3BD (hexadecimal).
dwFlags
(DWORD) A combination of the following:
WMIX_QUEUEWAVE
The wave will be placed on the specified channel and played after all waves which are currently waiting to play on that channel.
WMIX_CLEARQUEUE
This wave will pre-empt all waves currently playing on the specified channel. Notification messages will not be sent for any waves that get dumped. This message should not be combined with WMIX_QUEUEWAVE.
WMIX_HIGHPRIORITY
Play this wave immediately. This flag will interrupt the data buffered in the wave driver and remix the sound. If this flag is not set you could experience up to a half second delay before sound is played. Note: if WMIX_QUEUEWAVE is set with this flag then a sound playing on the channel will not be pre-empted, but it will begin immediately after the previous sound finishes. If no sound is currently playing on this channel then a remix will occur.
WMIX_USELRUCHANNEL
The wave should be played on any available channel or played on the channel that was least recently used. This flag should be combined with WMIX_QUEUEWAVE or WMIX_CLEARQUEUE.
WMIX_WAIT
Setting this flag cause WaveMixPlay() to put the play information on a "waiting list" to play. When WaveMixPlay() is called without this flag set it will process the calls in the order they were received. This is useful if you want to play multiple sounds simultaneously. Note 1: This flag is not a "pause". Waves that are playing will continue to play regardless of how many files are on the wait list. Note 2: Since the waves that are submitted with this flag set are not checked until WaveMixPlay is called without the flag set you should be careful about using other API calls before playing the sounds. For example, WaveMixFlushChannel() and WaveMixCloseChannel do not process the wait list.
wLoops
(WORD) The number of times the wave should be repeated. If wLoops is set to 0xFFFF the wave will loop until the channel it is on is flushed, pre-empted, or closed.

_________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Sat Jul 12, 2003 4:03 pm    Post subject: Reply with quote

This is another way i found of defining the required structure in VB
Code:
Public Type MIXPLAYPARAMS
    Size         As Integer
    MixSessionLo As Integer
    MixSessionHi As Integer
    ChannelLo    As Integer
    ChannelHi    As Integer
    MixWaveLo   As Integer
    MixWaveHi   As Integer
    hWndNotifyLo  As Integer
    hWndNotifyHi  As Integer
    FlagsLo     As Integer
    FlagsHi     As Integer
    wLoops        As Integer
End Type
-----------------------------------------------------------
Function HighWord(ByVal Value As Long) As Integer
    Value = Value \ &H10000
    HighWord = Val("&H" & Hex$(Value))
End Function


Function LowerWord(ByVal Value As Long) As Integer
    Value = Value And &HFFFF&
    LowerWord = Val("&H" & Hex$(Value))
End Function


In VDS

I could reach here

%%hWndNotifyHi = @VAL($@HEX(@DIV(%U,$10000)))

BUT

%%hWndNotifyLo = @VAL($@HEX(@AND(%U,$FFFF)))
I have put @AND just to show what is needed.
Is there a AND function equivalent in VDS - that performs an AND - bitwise comparision of 2 variables ?

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Jul 14, 2003 8:32 am    Post subject: Reply with quote

Nobody ?? No clue Crying or Very sad
I know its difficult

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
FreezingFire
Admin Team


Joined: 23 Jun 2002
Posts: 3508

PostPosted: Mon Jul 14, 2003 12:29 pm    Post subject: Reply with quote

I really wish I could help but I can't. Sad
_________________
FreezingFire
VDSWORLD.com
Site Admin Team
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


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

PostPosted: Mon Jul 14, 2003 12:57 pm    Post subject: Reply with quote

CodeScript wrote:
This is another way i found of defining the required structure in VB
Code:
Public Type MIXPLAYPARAMS
    Size         As Integer
    MixSessionLo As Integer
    MixSessionHi As Integer
    ChannelLo    As Integer
    ChannelHi    As Integer
    MixWaveLo   As Integer
    MixWaveHi   As Integer
    hWndNotifyLo  As Integer
    hWndNotifyHi  As Integer
    FlagsLo     As Integer
    FlagsHi     As Integer
    wLoops        As Integer
End Type
-----------------------------------------------------------
Function HighWord(ByVal Value As Long) As Integer
    Value = Value \ &H10000
    HighWord = Val("&H" & Hex$(Value))
End Function


Function LowerWord(ByVal Value As Long) As Integer
    Value = Value And &HFFFF&
    LowerWord = Val("&H" & Hex$(Value))
End Function


In VDS

I could reach here

%%hWndNotifyHi = @VAL($@HEX(@DIV(%U,$10000)))

BUT

%%hWndNotifyLo = @VAL($@HEX(@AND(%U,$FFFF)))
I have put @AND just to show what is needed.
Is there a AND function equivalent in VDS - that performs an AND - bitwise comparision of 2 variables ?


Hi CodeScript,
The only thing I can tell you as far as the bitwise AND goes is you can use my Gadget.dll to achieve this.. It has a function called @Gadget(And,<FirstNumber>,<SecondNum>,...) that will do the ands for you It also has functions for LoWord and HiWord built in. Take a look see at the link in my sig... As for building structures with VDS 5. I find it to be a little harder and requires more steps than most languages. It's very difficult to express a structure as a string. Take a look at the @binary() function in VDS.
Also for all those out there I am working on an Article for the News Letter that will be titled "The art of API programming with VDS 5" Wink This should help explain somethings and give a few hints and tips about programming with the Win32 API and VDS 5.

_________________
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
vdsalchemist
Admin Team


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

PostPosted: Mon Jul 14, 2003 1:36 pm    Post subject: Reply with quote

Oops Embarassed I just remembered something that I seen onetime that you can use to get the HiWord and LoWord of a 32bit number.

Code:
%%Hiword = @div(%%My32Num,65536)
%%Loword = @diff(%%My32Num,@prod(%%Hiword,65536))


Try it and let me know Wink
Below should be the structure you asked for in VDS format
Code:

rem Public Type MIXPLAYPARAMS
rem    Size         As Integer
rem    MixSessionLo As Integer
rem    MixSessionHi As Integer
rem    ChannelLo    As Integer
rem    ChannelHi    As Integer
rem    MixWaveLo   As Integer
rem    MixWaveHi   As Integer
rem    hWndNotifyLo  As Integer
rem    hWndNotifyHi  As Integer
rem    FlagsLo     As Integer
rem    FlagsHi     As Integer
rem    wLoops        As Integer
rem End Type
%M = @binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)@binary(dword,0)
%%Size = @val(@SubStr(%M,1,4))
%%MixSessionLo = @val(@SubStr(%M,5,8))
%%MixSessionHi = @val(@SubStr(%M,9,12))
%%ChannelLo = @val(@SubStr(%M,13,16))
%%ChannelHi = @val(@SubStr(%M,17,20))
%%MixWaveLo = @val(@SubStr(%M,21,24))
%%MixWaveHi = @val(@SubStr(%M,25,28))
%%hWndNotifyLo = @val(@SubStr(%M,29,32))
%%hWndNotifyHi = @val(@SubStr(%M,33,36))
%%FlagsLo = @val(@SubStr(%M,37,40))
%%FlagsHi = @val(@SubStr(%M,41,44))
%%wLoops = @val(@SubStr(%M,45,48))


This assumes that the variable types are correct in the VB structure. But looking at the names of the member variables it seems that some of these should be WORD values of 2 bytes each and not Interger values of 4 bytes each... Please check the documentation for this DLL to make sure or you may not get the desired results and you could crash your application or PC.
Also note that all members for the structure have been initialized to the number 0... If you need different vaules then change the apporpriate @binary() function in the local variable %M for the member that needs to be initialized to something else before using this structure.

_________________
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
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Jul 14, 2003 2:51 pm    Post subject: Reply with quote

Thanx very much. I know U R the one who can answer these questions and also I think U r very busy.

i am Embarassed by the fact that VDs has no fns like ANS OR XOR etc particularly AND many API s also need that. and it is a simple CPU instruction i think - so difficult to implement as a function ? I wonder.

I will try Ur suggested script once i reach home - not to crash this comp Smile
just in case

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


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

PostPosted: Mon Jul 14, 2003 3:19 pm    Post subject: Reply with quote

CodeScript wrote:
Thanx very much. I know U R the one who can answer these questions and also I think U r very busy.

i am Embarassed by the fact that VDs has no fns like ANS OR XOR etc particularly AND many API s also need that. and it is a simple CPU instruction i think - so difficult to implement as a function ? I wonder.

I will try Ur suggested script once i reach home - not to crash this comp Smile
just in case


Well actually I realized that all you really needed was the Hiword and Loword of a value. These are just mathematical equations that take the maximum of a word value and dividing the dword or integer value into their seperate word values. Other languages use macros to achieve the answer but they do the same thing. As for building sturctures with VDS 5 I really think this could have been made easier but never the less the principle is the same no matter what language you use. Take the size of each member variable and add them together to make a block of memory the total size of all the sizes of the members in the structure. Then to retrieve the values parse out each member variable at the offset of the size of that member. You can think of a structure as a single record in a database that have different field types. So if you have 4 dword values in a structure you would have 4 @binary(dword,0)'s assigned to a VDS local variable. Then just use the combination of @val and @substr to parse the contents of the structure 4 bytes or characters at a time until you get all the values from the structure. I don't know if this makes a lot of sense to you but my up and comming article will make more sense because it will have better illustrations Wink
As for crashing your PC don't worry you will not break anything permenantly it may blue screen the PC but a reboot will fix that. It will not damage the hardware. Under 32bit versions of Windows the hardware is protected in Ring 0 so there is usually no way to actually damage the hardware with software. Usually mind you Wink But writting into memory that your program does not own will not cause a permenant hardware failure but will prob. require a reboot because of the corruption that you created. I usually have to reboot my system several times a day because of stupid mistakes like this Embarassed I just told on myself Wink
Also I am not the only one on this message board that can answer API questions. Everyone has their fortiet when it comes to programming. Some of the users here are better in some areas than others and no I don't know everything about the Win32 API I am still learning like everyone else Wink But thank you for saying so... The person that really knows is Jules Wink He's the man!

_________________
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
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Mon Jul 14, 2003 3:52 pm    Post subject: Reply with quote

Mindpower thanx for Ur detailed answer about variables and parsing them.
I was afraid of need to reboot this computer should that arise - Very rare indeed.
I would be happy to see a BSOD in Xp(joking) - indeed rare - it usually crashes without BSOD while 98's BSOD's have even inspired people make bsod mocking screen savers!
I know what big privilges this VDS application working at ring 3 can have after all Wink
I think working with C/C++ a debugging session can get lot of reboots for reasons what later appear to be silly mistakes typos etc as U said.
Computers and programming are not at all my fields but this is what i feel.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Thu Jul 17, 2003 1:03 pm    Post subject: Reply with quote

Code:

IN VB 6
======================================
*************************************************
======================================
Relevent Module code:

Public Type MIXPLAYPARAMS
    Size         As Integer
    MixSessionLo As Integer
    MixSessionHi As Integer
    ChannelLo    As Integer
    ChannelHi    As Integer
    MixWaveLo   As Integer
    MixWaveHi   As Integer
    hWndNotifyLo  As Integer
    hWndNotifyHi  As Integer
    FlagsLo     As Integer
    FlagsHi     As Integer
    wLoops        As Integer
End Type


Relevent Form code:
' NB: All variables are LONG

Private Sub cmdPlayOne_Click()
Dim SoundTypeOne As MIXPLAYPARAMS

'Define the structure
With SoundTypeOne
    .Size = Len(SoundTypeOne)
    .ChannelHi = HighWord(0)
    .ChannelLo = LowerWord(0)
    .hWndNotifyHi = HighWord(0)
    .hWndNotifyLo = LowerWord(0)
    .MixSessionHi = HighWord(Session)
    .MixSessionLo = LowerWord(Session)
    .FlagsLo = HighWord(WMIX_CLEARQUEUE Or WMIX_HIGHPRIORITY)
    .FlagsHi = LowerWord(WMIX_CLEARQUEUE Or WMIX_HIGHPRIORITY)
    .MixWaveHi = HighWord(SoundOne)
    .MixWaveLo = LowerWord(SoundOne)
    .wLoops = 0

End With
 
'Start Playing
WaveMixPlay SoundTypeOne

End Sub

'This plays the wave very well !
=====================================================================================
*************************************************************************************
=====================================================================================

In VDS:
--------

%%ChannelHi = 0
%%ChannelLo = 1
%%hWndNotifyHi = 0
%%hWndNotifyLo = 0
%%MixSessionHi = @div(%I,65536)
%%MixSessionLo = @diff(%I,@prod(%%MixSessionHi,65536))
%%FlagsHi = 0
%%FlagsLo = 5
%%MixWaveHi = @div(%M,65536)
%%MixWaveLo = @diff(%M,@prod(%%MixSessionHi,65536))
REM BUT ABOVE GIVES WRONG VALUES
%%wLoops = 0

%U = @binary(dword,0)@binary(dword,%%ChannelHi)@binary(dword,%%ChannelLo)@binary(dword,%%hWndNotifyHi)@binary(dword,%%hWndNotifyLo)@binary(dword,%%MixSessionHi)@binary(dword,%%MixSessionLo)@binary(dword,%%FlagsHi)@binary(dword,%%FlagsLo)@binary(dword,%%MixWaveHi)@binary(dword,%%MixWaveLo)@binary(dword,%%wLoops)
%T = @binary(dword,@LEN(%U))@binary(dword,%%ChannelHi)@binary(dword,%%ChannelLo)@binary(dword,%%hWndNotifyHi)@binary(dword,%%hWndNotifyLo)@binary(dword,%%MixSessionHi)@binary(dword,%%MixSessionLo)@binary(dword,%%FlagsHi)@binary(dword,%%FlagsLo)@binary(dword,%%MixWaveHi)@binary(dword,%%MixWaveLo)@binary(dword,%%wLoops)

%%Size = @val(@SubStr(%T,1,4))
%%ChannelHi = @val(@SubStr(%T,5,8))
%%ChannelLo = @val(@SubStr(%T,9,12))
%%hWndNotifyHi = @val(@SubStr(%T,13,16))
%%hWndNotifyLo = @val(@SubStr(%T,17,20))
%%MixSessionHi = @val(@SubStr(%T,21,24))
%%MixSessionLo = @val(@SubStr(%T,25,28))
%%FlagsHi = @val(@SubStr(%T,29,32))
%%FlagsLo = @val(@SubStr(%T,33,36))
%%MixWaveHi = @val(@SubStr(%T,37,40))
%%MixWaveLo = @val(@SubStr(%T,41,44))
%%wLoops = @val(@SubStr(%T,45,48))

%%lpMixPlayParams = %%Size%%ChannelHi%%ChannelLo%%hWndNotifyHi%%hWndNotifyLo%%MixSessionHi%%MixSessionLo%%FlagsHi%%FlagsLo%%MixWaveHi%%MixWaveLo%%wLoops

%R = @lib(WAVMIX32,WaveMixPlay,INT:,%%lpMixPlayParams)




Now there are a few problems i found:
If I am feeding %%lpMixPlayParams to the dll it makes no sense of the %%Size I obtained because it was the size in dword format(Actual value 4Cool and now %%lpMixPlayParams contains Integers and its length is 23. corresponding length in VB is 24.
So I think the correct length would be 23.
However when I run it by feeding the dll %%lpMixPlayParams app simply crashes without notification Crying or Very sad
ON THE OTHER HAND if feed it %T that contains all binaries it wont crash but retuns an error message that device handle is invalid or wavefile error. first one is not possible since it has already confirmed by giving OK flag and a device handle. So I think that the file pointer is invalid more so because of problems in calculating lo word:

Lo word = @diff(%I,@prod(%%MixSessionHi,65536)) doesnot always return correct values with this formula I think:
session 1795064 Hi 27 lo 25592 -both VB and VDS
session 1777560 hi 27 lo 8088 -both VB and VDS


Wave 1814192 Hi 27 lo -20816 -VB
Wave 1814192 Hi 27 lo 44720 -VDS


Wave 1872296 Hi 28 lo -28248 -VB
Wave 1872296 Hi 28 lo 37288 -VDS

In the last two examples the value returned by VB is negative and different and probably correct because in the next step it plays the file succesfully. Could it be that the formula applies only till or above certain values etc ?

Is is there any alternative formulae to derive the loword in such a case(without another dll) ?

Another question is what should I pass to the dll ?
The binary conatining string %T or the one converted by @VAL() ie %%lpMixPlayParams ?

OR Is it that I try write a dll that interfaces between the Wavemix32 dll and VDS and that also does the lo/Hi word stuff the only way ? (as I want it to be a freeware for all)

Mindpower I hope I have not written too much Smile
I tried to do all possible research before troubling you.
________________________________________________________________________________________________________________

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
vdsalchemist
Admin Team


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

PostPosted: Thu Jul 17, 2003 1:48 pm    Post subject: Reply with quote

CodeScript,
It seems to me that you really should make all the variables a word variable type. If you don't reserve the memory right then you will have problems. See the code below.

Code:
%T = @binary(word,24)@binary(word,%%ChannelHi)@binary(word,%%ChannelLo)@binary(word,%%hWndNotifyHi)@binary(word,%%hWndNotifyLo)@binary(word,%%MixSessionHi)@binary(word,%%MixSessionLo)@binary(word,%%FlagsHi)@binary(word,%%FlagsLo)@binary(word,%%MixWaveHi)@binary(word,%%MixWaveLo)@binary(word,%%wLoops)


Also if you know the exact size of the structure then there really is no reason to make 2 variables of the same. Just put the correct size in the Size member. Also did this come with code for C/C++ or Delphi? C/C++ or Delphi code tend to be more exact with variable definitions. Some VB programmers have are hard time translating from those languages. If you have a *.h file for this it would help a lot to get the structure defined properly.
When translating code from C/C++ most C/C++ programmers use a form of reverse polish notation when specifying a variable name. If you noticed some of the variable names have a w or lp infront of them The w is for Word variable types and the lp is for Long Pointer variable types...
Also I think this thread would be better suited on the DLL developers Forum in the section for using the Win32 API with VDS...

_________________
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
vdsalchemist
Admin Team


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

PostPosted: Thu Jul 17, 2003 2:02 pm    Post subject: Reply with quote

CodeScript wrote:
Code:

%T = @binary(dword,@LEN(%U))@binary(dword,%%ChannelHi)@binary(dword,%%ChannelLo)@binary(dword,%%hWndNotifyHi)@binary(dword,%%hWndNotifyLo)@binary(dword,%%MixSessionHi)@binary(dword,%%MixSessionLo)@binary(dword,%%FlagsHi)@binary(dword,%%FlagsLo)@binary(dword,%%MixWaveHi)@binary(dword,%%MixWaveLo)@binary(dword,%%wLoops)

%%Size = @val(@SubStr(%T,1,4))
%%ChannelHi = @val(@SubStr(%T,5,8))
%%ChannelLo = @val(@SubStr(%T,9,12))
%%hWndNotifyHi = @val(@SubStr(%T,13,16))
%%hWndNotifyLo = @val(@SubStr(%T,17,20))
%%MixSessionHi = @val(@SubStr(%T,21,24))
%%MixSessionLo = @val(@SubStr(%T,25,28))
%%FlagsHi = @val(@SubStr(%T,29,32))
%%FlagsLo = @val(@SubStr(%T,33,36))
%%MixWaveHi = @val(@SubStr(%T,37,40))
%%MixWaveLo = @val(@SubStr(%T,41,44))
%%wLoops = @val(@SubStr(%T,45,48))

%%lpMixPlayParams = %%Size%%ChannelHi%%ChannelLo%%hWndNotifyHi%%hWndNotifyLo%%MixSessionHi%%MixSessionLo%%FlagsHi%%FlagsLo%%MixWaveHi%%MixWaveLo%%wLoops

%R = @lib(WAVMIX32,WaveMixPlay,INT:,%%lpMixPlayParams)




Also I found another thing that is not right. The above code is wrong and needs a little tweaking...

Code:
rem
Rem Define and initialize your structure to the proper size and number
rem of member variables.
rem
%T = @binary(word,24)@binary(word,%%ChannelHi)@binary(word,%%ChannelLo)@binary(word,%%hWndNotifyHi)@binary(word,%%hWndNotifyLo)@binary(word,%%MixSessionHi)@binary(word,%%MixSessionLo)@binary(word,%%FlagsHi)@binary(word,%%FlagsLo)@binary(word,%%MixWaveHi)@binary(word,%%MixWaveLo)@binary(word,%%wLoops)
rem
Rem Call the function and pass the Memory Address of the structure to
rem the function
rem
%R = @lib(WAVMIX32,WaveMixPlay,INT:,@addr("%T"))
rem
Rem Retrieve the values for each member variable of the structure
rem after the call to the function.
rem
%%Size = @val(@SubStr(%T,1,2))
%%ChannelHi = @val(@SubStr(%T,3,4))
%%ChannelLo = @val(@SubStr(%T,5,6))
%%hWndNotifyHi = @val(@SubStr(%T,7,8))
%%hWndNotifyLo = @val(@SubStr(%T,9,10))
%%MixSessionHi = @val(@SubStr(%T,11,12))
%%MixSessionLo = @val(@SubStr(%T,13,14))
%%FlagsHi = @val(@SubStr(%T,15,16))
%%FlagsLo = @val(@SubStr(%T,17,18))
%%MixWaveHi = @val(@SubStr(%T,19,20))
%%MixWaveLo = @val(@SubStr(%T,21,22))
%%wLoops = @val(@SubStr(%T,23,24))
rem
Rem Now have fun using the member variables.
rem


Now I am still not sure if this works or not because I have not see all of the documentation for the DLL but from what I could get from your prev. posts this should work just fine.

Also just to let you know the @len() function is for normal strings. So if you use it to get the length of a binary type variable then you should always use @Succ(@len(%U)) or @Sum(@len(%U),1) to get the correct size. The @len() function does not include the null terminating character @chr(0) as part of the length of the string or variable so it will always return 1 byte less then the true size.

_________________
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
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Thu Jul 17, 2003 4:21 pm    Post subject: Reply with quote

Thanx mindpower
I will try.
BTW
I will post in the same named thread in developers forum further.

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
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