Solved

Using WaveIn* functions to record wav

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

20 Experts available now in Live!

Get 1:1 Help Now