Solved

Using WaveIn* functions to record wav

Posted on 1998-10-01
5
374 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

807 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