Re: How can I send data to my sound card?
- From: "Chris P." <msdn@xxxxxxxxxxxx>
- Date: Fri, 8 Aug 2008 13:58:32 -0400
On Fri, 8 Aug 2008 01:35:01 -0700, m.abdelghany wrote:
Missouri is very far from where I live, but no problem, here is the code I
used I hope you cab tell me then what is wrong :
It's not close to where I live either but it's a good expression.
// Global variables.
HANDLE hData = sHandle; // handle of waveform data memory
HPSTR lpData = S; // pointer to waveform data memory
void WriteWaveData(void)
{
HWAVEOUT hWaveOut;
HGLOBAL hWaveHdr;
LPWAVEHDR lpWaveHdr;
HMMIO hmmio;
UINT wResult;
HANDLE hFormat;
WAVEFORMAT *pFormat;
DWORD dwDataSize;
// Open a waveform device for output using window callback.
if (waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER,
(LPWAVEFORMAT)pFormat,
(LONG)hwndApp, 0L, CALLBACK_WINDOW))
You're problem is that you have passed an uninitialized structure pFormat
to waveOutOpen. It could of just as easily thrown an exception because
pFormat is pointing off into the void.
What you are supposed to do is have a WAVEFORMATEX struct, populate all the
members and then pass the address of that struct.
e.g.
WAVEFORMATEX wFormat;
wFormat.wFormatTag = WAVEFORMAT_PCM;
wFormat.nChannels = 2;
wFormat.nSamplesPecSec = 16000;
wFormat.wBitesPerSample = 16;
wFormat.nBlockAlign = (wFormat.nChannels * (wFormat.wBitesPerSample/8));
wFormat.nAvgBytesPerSec = wFormat.nBlockAlign * wFormat.nSamplesPecSec;
wFormat.cbSize = 0;
if (waveOutOpen((LPHWAVEOUT)&hWaveOut, WAVE_MAPPER,
(LPWAVEFORMAT)&wFormat,
(LONG)hwndApp, 0L, CALLBACK_WINDOW))
--
http://www.chrisnet.net/code.htm
[MS MVP for DirectShow / MediaFoundation]
.
- References:
- How can I send data to my sound card?
- From: m.abdelghany
- Re: How can I send data to my sound card?
- From: Chris P.
- Re: How can I send data to my sound card?
- From: m.abdelghany
- How can I send data to my sound card?
- Prev by Date: Re: Access vista component devices of playback devices like microphone, linein, front mic etc in vc++
- Next by Date: RE: HELP multimedia audio controller
- Previous by thread: Re: How can I send data to my sound card?
- Next by thread: Re: Xp speaker behaviour in diffrent sound cards
- Index(es):
Relevant Pages
|
Loading