Solved

Using WaveIn* functions to record wav

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

808 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