473,657 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WaveInOpen API function Problem

Hi All,

I have written following code, but waveInOpen API call gives me error no 32.
Can anyone help me to solve this?
Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Public Const CALLBACK_FUNCTI ON = &H30000

Structure WAVEFORMAT

Dim wFormatTag As Integer

Dim nChannels As Integer

Dim nSamplesPerSec As Integer

Dim nAvgBytesPerSec As Integer

Dim nBlockAlign As Integer

Dim wBitsPerSample As Integer

Dim cbSize As Integer

End Structure

Declare Function waveInOpen Lib "winmm.dll" (ByRef lphWaveIn As IntPtr, _

ByVal uDeviceID As Integer, ByRef lpFormat As WAVEFORMAT, _

ByVal dwCallback As callback, ByVal dwInstance As Integer, _

ByVal dwFlags As Integer) As Integer

Dim Wfmt As WAVEFORMAT

Dim WHdr As WAVEHDR

Dim intWaveIn As IntPtr

Dim intDevID As Integer = 0

Dim intRet As Integer

With Wfmt

..wFormatTag = 1

..nChannels = 1

..nBlockAlign = 1

..nSamplesPerSe c = 8000

..nAvgBytesPerS ec = 8000

..wBitsPerSampl e = 8

..cbSize = 0

End With

Dim Buffer(2048) As Byte

Dim Handle As GCHandle = GCHandle.Alloc( Buffer, GCHandleType.Pi nned)

Dim ptrBuffer As IntPtr = Handle.AddrOfPi nnedObject

intRet = waveInOpen(intW aveIn, intDevID, Wfmt, AddressOf WaveInProc, 0,
CALLBACK_FUNCTI ON)

intRet comes as 32.

Hopes kind help from you.

Thanks & Regards.

Sakharam Phapale
Nov 21 '05 #1
4 4752
I'm not sure if you've tried looking up what that error means - but here's
where you can look up the error messages for the error codes:
http://msdn.microsoft.com/library/de...es__0-499_.asp

error 32 is a sharing violation - so you might want to check whether the
file is opened already by some other process or something like that. I
haven't taken a look at your code but just wanted to make sure you had
looked into the error. If you've already done that then I'll probably go
through the code :)

hope that helps..
Imran.

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi All,

I have written following code, but waveInOpen API call gives me error no 32. Can anyone help me to solve this?
Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Public Const CALLBACK_FUNCTI ON = &H30000

Structure WAVEFORMAT

Dim wFormatTag As Integer

Dim nChannels As Integer

Dim nSamplesPerSec As Integer

Dim nAvgBytesPerSec As Integer

Dim nBlockAlign As Integer

Dim wBitsPerSample As Integer

Dim cbSize As Integer

End Structure

Declare Function waveInOpen Lib "winmm.dll" (ByRef lphWaveIn As IntPtr, _

ByVal uDeviceID As Integer, ByRef lpFormat As WAVEFORMAT, _

ByVal dwCallback As callback, ByVal dwInstance As Integer, _

ByVal dwFlags As Integer) As Integer

Dim Wfmt As WAVEFORMAT

Dim WHdr As WAVEHDR

Dim intWaveIn As IntPtr

Dim intDevID As Integer = 0

Dim intRet As Integer

With Wfmt

.wFormatTag = 1

.nChannels = 1

.nBlockAlign = 1

.nSamplesPerSec = 8000

.nAvgBytesPerSe c = 8000

.wBitsPerSample = 8

.cbSize = 0

End With

Dim Buffer(2048) As Byte

Dim Handle As GCHandle = GCHandle.Alloc( Buffer, GCHandleType.Pi nned)

Dim ptrBuffer As IntPtr = Handle.AddrOfPi nnedObject

intRet = waveInOpen(intW aveIn, intDevID, Wfmt, AddressOf WaveInProc, 0,
CALLBACK_FUNCTI ON)

intRet comes as 32.

Hopes kind help from you.

Thanks & Regards.

Sakharam Phapale

Nov 21 '05 #2
Hi Imran,

Thanks for your reply, but I am not using any file.
I used this function for retrieving wave in device handle.
and this error is related to WAVEFORMAT, and here in code it is right one.

Thanks and Regards
Sakharam Phapale
"Imran Koradia" <no****@microso ft.com> wrote in message
news:uX******** ******@TK2MSFTN GP15.phx.gbl...
I'm not sure if you've tried looking up what that error means - but here's
where you can look up the error messages for the error codes:
http://msdn.microsoft.com/library/de...es__0-499_.asp
error 32 is a sharing violation - so you might want to check whether the
file is opened already by some other process or something like that. I
haven't taken a look at your code but just wanted to make sure you had
looked into the error. If you've already done that then I'll probably go
through the code :)

hope that helps..
Imran.

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi All,

I have written following code, but waveInOpen API call gives me error no

32.
Can anyone help me to solve this?
Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Public Const CALLBACK_FUNCTI ON = &H30000

Structure WAVEFORMAT

Dim wFormatTag As Integer

Dim nChannels As Integer

Dim nSamplesPerSec As Integer

Dim nAvgBytesPerSec As Integer

Dim nBlockAlign As Integer

Dim wBitsPerSample As Integer

Dim cbSize As Integer

End Structure

Declare Function waveInOpen Lib "winmm.dll" (ByRef lphWaveIn As IntPtr, _
ByVal uDeviceID As Integer, ByRef lpFormat As WAVEFORMAT, _

ByVal dwCallback As callback, ByVal dwInstance As Integer, _

ByVal dwFlags As Integer) As Integer

Dim Wfmt As WAVEFORMAT

Dim WHdr As WAVEHDR

Dim intWaveIn As IntPtr

Dim intDevID As Integer = 0

Dim intRet As Integer

With Wfmt

.wFormatTag = 1

.nChannels = 1

.nBlockAlign = 1

.nSamplesPerSec = 8000

.nAvgBytesPerSe c = 8000

.wBitsPerSample = 8

.cbSize = 0

End With

Dim Buffer(2048) As Byte

Dim Handle As GCHandle = GCHandle.Alloc( Buffer, GCHandleType.Pi nned)

Dim ptrBuffer As IntPtr = Handle.AddrOfPi nnedObject

intRet = waveInOpen(intW aveIn, intDevID, Wfmt, AddressOf WaveInProc, 0,
CALLBACK_FUNCTI ON)

intRet comes as 32.

Hopes kind help from you.

Thanks & Regards.

Sakharam Phapale


Nov 21 '05 #3
my apologies - I was looking up the wrong error codes. This one is in
MMsytem.h and it translates to an unsupported waveform-audio format. I'll
look into it. In the meantime, maybe someone else here can come up with a
solution..

Imran.

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:eo******** ******@TK2MSFTN GP14.phx.gbl...
Hi Imran,

Thanks for your reply, but I am not using any file.
I used this function for retrieving wave in device handle.
and this error is related to WAVEFORMAT, and here in code it is right one.

Thanks and Regards
Sakharam Phapale
"Imran Koradia" <no****@microso ft.com> wrote in message
news:uX******** ******@TK2MSFTN GP15.phx.gbl...
I'm not sure if you've tried looking up what that error means - but here's
where you can look up the error messages for the error codes:

http://msdn.microsoft.com/library/de...es__0-499_.asp

error 32 is a sharing violation - so you might want to check whether the
file is opened already by some other process or something like that. I
haven't taken a look at your code but just wanted to make sure you had
looked into the error. If you've already done that then I'll probably go
through the code :)

hope that helps..
Imran.

"Sakharam Phapale" <sp******@annet site.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. ..
Hi All,

I have written following code, but waveInOpen API call gives me error no
32.
Can anyone help me to solve this?
Public Delegate Function callback(ByVal hw As Integer, ByVal uMsg As
Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer

Public Const CALLBACK_FUNCTI ON = &H30000

Structure WAVEFORMAT

Dim wFormatTag As Integer

Dim nChannels As Integer

Dim nSamplesPerSec As Integer

Dim nAvgBytesPerSec As Integer

Dim nBlockAlign As Integer

Dim wBitsPerSample As Integer

Dim cbSize As Integer

End Structure

Declare Function waveInOpen Lib "winmm.dll" (ByRef lphWaveIn As

IntPtr, _
ByVal uDeviceID As Integer, ByRef lpFormat As WAVEFORMAT, _

ByVal dwCallback As callback, ByVal dwInstance As Integer, _

ByVal dwFlags As Integer) As Integer

Dim Wfmt As WAVEFORMAT

Dim WHdr As WAVEHDR

Dim intWaveIn As IntPtr

Dim intDevID As Integer = 0

Dim intRet As Integer

With Wfmt

.wFormatTag = 1

.nChannels = 1

.nBlockAlign = 1

.nSamplesPerSec = 8000

.nAvgBytesPerSe c = 8000

.wBitsPerSample = 8

.cbSize = 0

End With

Dim Buffer(2048) As Byte

Dim Handle As GCHandle = GCHandle.Alloc( Buffer, GCHandleType.Pi nned)

Dim ptrBuffer As IntPtr = Handle.AddrOfPi nnedObject

intRet = waveInOpen(intW aveIn, intDevID, Wfmt, AddressOf WaveInProc,

0, CALLBACK_FUNCTI ON)

intRet comes as 32.

Hopes kind help from you.

Thanks & Regards.

Sakharam Phapale



Nov 21 '05 #4
looks like your structure needs to be modified a bit:
Structure WAVEFORMAT

Dim wFormatTag As Integer

Dim nChannels As Integer

Dim nSamplesPerSec As Integer

Dim nAvgBytesPerSec As Integer

Dim nBlockAlign As Integer

Dim wBitsPerSample As Integer

Dim cbSize As Integer

End Structure


Structure WAVEFORMAT
Dim wFormatTag As Short
Dim nChannels As Short
Dim nSamplesPerSec As Integer
Dim nAvgBytesPerSec As Integer
Dim nBlockAlign As Short
Dim wBitsPerSample As Short
Dim cbSize As Short
End Structure

remember - DWORD converts to Integer (32-bit) and WORD converts to
Short(16-bit).

hope that helps..
Imran.
Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4522
by: Fred Loud | last post by:
I'm having a problem calling waveInOpen from a VB.NET application, every time I call it I get a return value of 11 which is MMSYSERR_INVALPARAM. I can call waveInGetNumDevs and waveInGetDevCaps just fine. Below is the format of the waveInOpen call and WaveFormatEx structure. <DllImport("winmm.dll", SetLastError:=False, ExactSpelling:=True)> _ Public Shared Function waveInOpen(ByVal lphWaveIn As Int32 _ , ByVal uDeviceID As Int32 _ ,...
2
2322
by: Hennie de Nooijer | last post by:
Because of an error in google or underlying site i can reply on my own issue. Therefore i copied the former entered message in this message. -------------------------------------REPY---------------------------------- Hi Maybe i wasn't clear. I want to dynamically check whether what the lowest date and the highest date is in the calendar table. The presented solutions has fixed dates and i don't want that. If i could store a global...
7
5178
by: Mike D. | last post by:
I have a problem with a dynamic library I am developing, but it is really more of a pointer issue than anything else. Hopefully someone here can lend me some assistance or insight into resolving this. Ok... here goes.... I have a function that passes a pointer to a string to another function. For example: int FunctionA ()
1
4551
by: Ja | last post by:
Hello, I'm capturing audio from the soundcard, using the waveInXXX calls. I'm having no problem capturing a PCM stream. Yet, when I try to capture a GSM compressed stream, I get a failure opening the device (32). As far as I can tell, I'm doing everything according to Article ID : 153866 (http://support.microsoft.com/default.aspx?scid=kb;en-us;153866#kb2) Here's the code (as it apperas in a similar question, asked years ago):
4
9078
by: saverain | last post by:
//WaveIn.h MMRESULT IsFormatSupported(LPWAVEFORMATEX pwfx, UINT uDeviceID) { return waveInOpen ( NULL, // ptr can be NULL for query uDeviceID, // The device identifier pwfx, // Defines the requested // format. NULL, // No callback NULL, // No instance data
3
9877
by: jrumanek | last post by:
Hallo, I have a problem with function WaveInOpen. The function gives ERROR CODE 11 - MMSYSERR_INVALPARAM. Shall you help me please? Any sugestion?
2
3611
by: jrumanek | last post by:
Hallo, I have problem with function WaveInOpen . This function doesn't return meesage MM_WIM_OPEN? Shall YOU help me pleas? Any suggestions? Thank you!
6
5909
by: RandomElle | last post by:
Hi there I'm hoping someone can help me out with the use of the Eval function. I am using Access2003 under WinXP Pro. I can successfully use the Eval function and get it to call any function with or without parms. I know that any function that is passed to Eval() must be declared Public. It can be a Sub or Function, as long as it's Public. I even have it where the "function" evaluated by Eval can be in a form (class) module or in a standard...
3
3962
by: wizche | last post by:
Hi Everybody, I'm trying to play a little with waveIn functions... My goal is to calculate if I'm listening a specified sin frequency or not. For this reason I'm going down with the samplerate... How can I be sure of the sampling rate set on my device? If I declare waveFormat.nSamplesPerSec = 9441000; waveInOpen return NO error.. (same if I put 500 Hz) But I'm not really sure that's working (9 MHz!!)... For example if I want to find a...
0
8407
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2739
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.