Solved

Using WaveIn* functions to record wav

Posted on 1998-10-01
5
370 Views
Last Modified: 2012-05-04
How to define the callback function in visual basic that is addressed in the WaveInOpen? And how to use pointers in visual basic for memory structures? like when allocating memory for the WAVEHDR structure and assining it to pointer variable in visual basic?.
0
Comment
Question by:karmi
  • 2
  • 2
5 Comments
 
LVL 1

Expert Comment

by:abhinavm
ID: 1437693
i don't know the details about waveInopen Function but you can define call back function by using 'AddressOf' key word. Write a procedure or function to define the callback function. While passing the parameters to WaveInOpen function where address of callback function is required you can write AddressOf(FunctionName) .
    you won't get the pointers in VB actually while passing the parameters VB Passes it thru reference so if you haven't written ByVal keyword while passing parameter VB will Pass Poiter to the variable. So you need not to worry about pointer. Just define Same type Structure in VB(Using Type keyword) and pass the variable of that type to The function. While creating type you have to take care of VB and C Type Mappings.

0
 

Author Comment

by:karmi
ID: 1437694
I am using AddressOf function , and already declared the callback function as it is described at the MSDN documentation but that didnot work, may be because that was written in C, this is why I am asking if something else should be done with Visual Basic.

Sometimes I need to allocate memory using GlobalAlloc, then assign the address to a pointer variable "I do it using Long variable", but the variable is not accepted when calling some APIs because of type missmatch! as an example: allocating memory for WAVEHDR structure, then use the pointer variable in some API calls. I know how to that in C, but I need to know how to do the same thing in VB.

0
 
LVL 1

Expert Comment

by:abhinavm
ID: 1437695
I don't know why your call back function is not working it should work.
   For the second thing storing address in a long variable is OK just you have to change the declare statement there instead of specifying type declare it as ANY and you won't get any type mismatch error.
0
 

Author Comment

by:karmi
ID: 1437696
declaring the callback function as it is described at the msdn documentation was ok for program compilation, but was not at run time, the blue screen and some other windows critical errors appeared after openning the wave file "when expecting a callbac to say file open".

msdn :
void CALLBACK waveInProc( HWAVEIN hwi,UINT uMsg,DWORD wInstance,
                         DWORD dwParam1, DWORD dwParam2 );
 

My VB :
Sub mciCallBack(hWaveIn As Long, hMsg As Integer, dInstance As Long, Par1 As Long, Par2 As Long)


According to set the variable type to Any in the decleration statement, I did but I received an error 87 by GetLasError which is Parameter Error, anyway this is not as important as the above case which I really I do care about.

Thanks for your help
0
 
LVL 1

Accepted Solution

by:
Aikema earned 50 total points
ID: 1437697
On the VB CD that I've got in the
\TOOLS\UNSUPPRT\VOICE\WAVESTRM directory there's
source code for a program that uses the wavein/out
API to record and play wav files.

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now