473,569 Members | 2,691 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

waveInOpen Code Help

//WaveIn.h
MMRESULT IsFormatSupport ed(LPWAVEFORMAT EX 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_QUE RY); // Query only, do not open.
}
//WaveIn.cpp
#include "stdafx.h"
#include "WaveIn.h"

int main()
{
UINT wReturn;
WAVEFORMATEX pcmWaveFormat;

pcmWaveFormat.w FormatTag = WAVE_FORMAT_PCM ;
pcmWaveFormat.n Channels = 1;
pcmWaveFormat.n SamplesPerSec = 44100L;
pcmWaveFormat.n AvgBytesPerSec = 88200L;
pcmWaveFormat.n BlockAlign = 2;
pcmWaveFormat.w BitsPerSample = 16;
pcmWaveFormat.c bSize = 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_QUE RY); // Query only, do not open.
}

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

wReturn = IsFormatSupport ed(&pcmWaveForm at, WAVE_MAPPER);

// Report results.

if (wReturn == MMSYSERR_NOERRO R)
MessageBox(NULL , "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMAT ION);
else if (wReturn == WAVERR_BADFORMA T)
MessageBox(NULL , "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMAT ION);
else
MessageBox(NULL , "Error opening waveform device.",
"Error", MB_ICONEXCLAMAT ION);
}

I get these errors along with others

e:\Amp\Tabs\Wav eIn.cpp(29): error C2065: 'pcmWaveFormat' : undeclared
identifier
e:\Amp\Tabs\Wav eIn.cpp(29): error C2501: 'wReturn' : missing
storage-class or type specifiers
e:\Amp\Tabs\Wav eIn.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 9072
saverain wrote:
//WaveIn.h
MMRESULT IsFormatSupport ed(LPWAVEFORMAT EX 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_QUE RY); // Query only, do not open.
}
//WaveIn.cpp
#include "stdafx.h"
#include "WaveIn.h"

int main()
{
UINT wReturn;
WAVEFORMATEX pcmWaveFormat;

pcmWaveFormat.w FormatTag = WAVE_FORMAT_PCM ;
pcmWaveFormat.n Channels = 1;
pcmWaveFormat.n SamplesPerSec = 44100L;
pcmWaveFormat.n AvgBytesPerSec = 88200L;
pcmWaveFormat.n BlockAlign = 2;
pcmWaveFormat.w BitsPerSample = 16;
pcmWaveFormat.c bSize = 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_QUE RY); // 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 = IsFormatSupport ed(&pcmWaveForm at, WAVE_MAPPER);

// Report results.

if (wReturn == MMSYSERR_NOERRO R)
MessageBox(NULL , "44.1 kHz 16-bit stereo is supported.",
"", MB_ICONINFORMAT ION);
else if (wReturn == WAVERR_BADFORMA T)
MessageBox(NULL , "44.1 kHz 16-bit stereo NOT supported.",
"", MB_ICONINFORMAT ION);
else
MessageBox(NULL , "Error opening waveform device.",
"Error", MB_ICONEXCLAMAT ION);
}

I get these errors along with others

e:\Amp\Tabs\Wav eIn.cpp(29): error C2065: 'pcmWaveFormat' : undeclared
identifier
e:\Amp\Tabs\Wav eIn.cpp(29): error C2501: 'wReturn' : missing
storage-class or type specifiers
e:\Amp\Tabs\Wav eIn.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\Wav eIn.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\Wav eIn.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.w FormatTag = WAVE_FORMAT_PCM ;
(...) You can do the same with pwfx->wFormatTag and so on.

Then function IsFormatSupport ed() 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
4511
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,...
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 hides all of them including hiding the database window, disabling menu changes. What I am after is the same effect as disabling all the check boxes...
18
18334
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 a remote update of tables and fields and can't find enough information on these things. Also, how do you index a field in code?
7
3291
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 buffer into the character pointer. The code looks like the following: #include <stdio.h> #include <stdlib.h> #include "stdafx.h" BOOL APIENTRY...
1
4544
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...
4
4745
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 Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer Public Const CALLBACK_FUNCTION = &H30000
3
9869
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
3606
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
3949
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...
0
7698
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...
0
7924
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. ...
0
8122
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...
1
7673
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...
0
7970
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.