473,503 Members | 1,910 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

waveInOpen Code Help

//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
WAVE_FORMAT_QUERY); // Query only, do not open.
}
//WaveIn.cpp
#include "stdafx.h"
#include "WaveIn.h"

int main()
{
UINT wReturn;
WAVEFORMATEX pcmWaveFormat;

pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 1;
pcmWaveFormat.nSamplesPerSec = 44100L;
pcmWaveFormat.nAvgBytesPerSec = 88200L;
pcmWaveFormat.nBlockAlign = 2;
pcmWaveFormat.wBitsPerSample = 16;
pcmWaveFormat.cbSize = 0;

waveInOpen (
NULL, // ptr can be NULL for query
WAVE_MAPPER, // The device identifier
pwfx, // Defines the requested
// format.
NULL, // No callback
NULL, // No instance data
WAVE_FORMAT_QUERY); // Query only, do not open.
}

// See if format is supported by any device in the system.

wReturn = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);

// Report results.

if (wReturn == MMSYSERR_NOERROR)
MessageBox(NULL, "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(NULL, "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(NULL, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);
}

I get these errors along with others

e:\Amp\Tabs\WaveIn.cpp(29): error C2065: 'pcmWaveFormat' : undeclared
identifier
e:\Amp\Tabs\WaveIn.cpp(29): error C2501: 'wReturn' : missing
storage-class or type specifiers
e:\Amp\Tabs\WaveIn.cpp(20): error C2065: 'pwfx' : undeclared identifier
Hi, new to the group, I'm trying to check to see if a waveformatex
format is supported by my sound card. Everything seems to be working
except for the waveInOpen struct. Any suggestions about the pwfx or
uDeviceDriver or anything? Thanks

May 23 '06 #1
4 9064
saverain wrote:
//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
WAVE_FORMAT_QUERY); // Query only, do not open.
}
//WaveIn.cpp
#include "stdafx.h"
#include "WaveIn.h"

int main()
{
UINT wReturn;
WAVEFORMATEX pcmWaveFormat;

pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
pcmWaveFormat.nChannels = 1;
pcmWaveFormat.nSamplesPerSec = 44100L;
pcmWaveFormat.nAvgBytesPerSec = 88200L;
pcmWaveFormat.nBlockAlign = 2;
pcmWaveFormat.wBitsPerSample = 16;
pcmWaveFormat.cbSize = 0;

waveInOpen (
NULL, // ptr can be NULL for query
WAVE_MAPPER, // The device identifier
pwfx, // Defines the requested
// format.
NULL, // No callback
NULL, // No instance data
WAVE_FORMAT_QUERY); // Query only, do not open.
} ^^^
I believe this curly brace is what screws you up. It closes the 'main'
function and the following statements are placed _outside_ of any function,
which is not what you wanted.

// See if format is supported by any device in the system.

wReturn = IsFormatSupported(&pcmWaveFormat, WAVE_MAPPER);

// Report results.

if (wReturn == MMSYSERR_NOERROR)
MessageBox(NULL, "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMATION);
else if (wReturn == WAVERR_BADFORMAT)
MessageBox(NULL, "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMATION);
else
MessageBox(NULL, "Error opening waveform device.",
"Error", MB_ICONEXCLAMATION);
}

I get these errors along with others

e:\Amp\Tabs\WaveIn.cpp(29): error C2065: 'pcmWaveFormat' : undeclared
identifier
e:\Amp\Tabs\WaveIn.cpp(29): error C2501: 'wReturn' : missing
storage-class or type specifiers
e:\Amp\Tabs\WaveIn.cpp(20): error C2065: 'pwfx' : undeclared
identifier
Hi, new to the group, I'm trying to check to see if a waveformatex
format is supported by my sound card. Everything seems to be working
except for the waveInOpen struct. Any suggestions about the pwfx or
uDeviceDriver or anything? Thanks


See above

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 23 '06 #2
Thanks now the only error I have is
e:\Amp\Tabs\WaveIn.cpp(20): error C2065: 'pwfx' : undeclared identifier

I believe this points to the pcmwaveformat but not shure.

May 23 '06 #3
saverain wrote:
Thanks now the only error I have is
e:\Amp\Tabs\WaveIn.cpp(20): error C2065: 'pwfx' : undeclared
identifier

I believe this points to the pcmwaveformat but not shure.


Undeclared identifier usually is either scoping issue or the result of
a typo. You've got to be able to take care of those on your own.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 23 '06 #4
maybe try to erase definition of WAVEFORMATEX value. create the pointer
LPWAVEFORMATEX pwfx.

this:
pcmWaveFormat.wFormatTag = WAVE_FORMAT_PCM;
(...) You can do the same with pwfx->wFormatTag and so on.

Then function IsFormatSupported() call with pwfx.
Maybe this will help.

Greets,
V

May 24 '06 #5

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

Similar topics

2
4497
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...
6
391
by: Mark Reed | last post by:
Hi all, I am trying to learn a little about programming (I know next to nothing so far) and have found some code which hides the toolbars. However, this bit of code is a little too effective and...
18
18302
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
7
3287
by: Timothy Shih | last post by:
Hi, I am trying to figure out how to use unmanaged code using P/Invoke. I wrote a simple function which takes in 2 buffers (one a byte buffer, one a char buffer) and copies the contents of the byte...
1
4540
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...
4
4736
by: Sakharam Phapale | last post by:
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...
3
9861
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
3602
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!
3
3941
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...
0
7093
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...
0
7287
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,...
0
7348
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...
0
7467
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5592
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5021
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...
0
3175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3166
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1519
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 ...

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.