
May 23rd, 2006, 08:05 PM
| | | 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 23rd, 2006, 08:05 PM
| | | Re: waveInOpen Code Help
saverain wrote:[color=blue]
> //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.
> }[/color]
^^^
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.
[color=blue]
>
> // 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[/color]
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 23rd, 2006, 08:25 PM
| | | Re: waveInOpen Code Help
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 23rd, 2006, 09:05 PM
| | | Re: waveInOpen Code Help
saverain wrote:[color=blue]
> 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.[/color]
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 24th, 2006, 10:45 AM
| | | Re: waveInOpen Code Help
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 | | Thread Tools | Search this Thread | | | |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | | | | What is Bytes?
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 205,338 network members.
|