Click here to Skip to main content
15,902,891 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Invalidate() Error CDialog Pin
mohit`1213-Aug-10 6:09
mohit`1213-Aug-10 6:09 
GeneralRe: Invalidate() Error CDialog Pin
KarstenK15-Aug-10 22:13
mveKarstenK15-Aug-10 22:13 
GeneralRe: Invalidate() Error CDialog Pin
mohit`1216-Aug-10 3:31
mohit`1216-Aug-10 3:31 
GeneralRe: Invalidate() Error CDialog Pin
KarstenK16-Aug-10 3:37
mveKarstenK16-Aug-10 3:37 
GeneralRe: Invalidate() Error CDialog Pin
mohit`1216-Aug-10 6:01
mohit`1216-Aug-10 6:01 
QuestionC++ MFC - DatePickerControl - DTN_DATETIMECHANGE event getting triggered twice when clicked !!!! Pin
Kausik4u12-Aug-10 4:26
Kausik4u12-Aug-10 4:26 
AnswerRe: C++ MFC - DatePickerControl - DTN_DATETIMECHANGE event getting triggered twice when clicked !!!! Pin
Niklas L12-Aug-10 6:18
Niklas L12-Aug-10 6:18 
Questionwave sound not playing properly..sounds different?? [modified] Pin
AmbiguousName12-Aug-10 0:41
AmbiguousName12-Aug-10 0:41 
MODIFIED QUESTION
hello guys...I want to play wave audio data but it is not playing properly, plays differentlyConfused | :confused:
WAVEFORMATEX	        _oFormat;
LPWAVEFORMATEX	        _pFormat = NULL;
HGLOBAL			_hWaveData;
PCHAR			_pWaveData;
HGLOBAL                 _hWaveHeader;
LPWAVEHDR               _pWaveHeader;
HWAVEOUT		_hOutputDevice = NULL;
DWORD			_nAlignedBufferSize = 0;
MMRESULT		rc = 0;
HANDLE			fileHandle = NULL;
DWORD			size = 0;
DWORD			readBytes = 0;
void*			block = NULL;

	_pFormat = &_oFormat;
	_pFormat->wFormatTag = WAVE_FORMAT_PCM;
	_pFormat->nChannels = 1;
	_pFormat->nSamplesPerSec = 8000;
	_pFormat->wBitsPerSample = 8;
	_pFormat->nBlockAlign = 1;
	_pFormat->nAvgBytesPerSec = 8000;
	_pFormat->cbSize = 0;

	//allocate and lock memory for the buffers...
	_hWaveHeader = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE | GMEM_ZEROINIT, (DWORD)sizeof(WAVEHDR));
	if(!_hWaveHeader) return false;
	_pWaveHeader = (LPWAVEHDR) GlobalLock(_hWaveHeader);
	if(!_pWaveHeader) return false;
	_hWaveData = GlobalAlloc(GMEM_MOVEABLE | GMEM_SHARE, AUDIO_BUFFER_SIZE);
	if(!_hWaveData) return false;
	_pWaveHeader->lpData = _pWaveData = (LPSTR)GlobalLock(_hWaveData);

	//open suitable device for output(input or outpur)
	rc = waveOutOpen(&_hOutputDevice, WAVE_MAPPER,_pFormat, (DWORD) &waveOutProc, 0, CALLBACK_FUNCTION);
	if (rc!=MMSYSERR_NOERROR)
		MessageBox(NULL,"Error:","",NULL);

	//creating file to read from.....ringout, the same file from c:\windows\media\ringout.wav
	if ((fileHandle = CreateFile("\sounds\\ringout.wav", GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,0,NULL)) == INVALID_HANDLE_VALUE)
		return NULL;

	do {
		if( (size = GetFileSize(fileHandle,NULL)) == 0)
			break;

		if ( (block = HeapAlloc(GetProcessHeap(), 0, size)) == NULL)
			break;

		ReadFile(fileHandle, block, size, &readBytes, NULL);
	} while(0);

	CloseHandle(fileHandle);
	CopyMemory(_pWaveHeader, &block, sizeof(block));

	// prepare buffers and pass to output device
	_nAlignedBufferSize = (AUDIO_BUFFER_SIZE - AUDIO_BUFFER_SIZE % _pFormat->nBlockAlign ); //buffer size
	_pWaveHeader->dwFlags = 0;
	_pWaveHeader->dwBufferLength = _nAlignedBufferSize;
	rc = waveOutPrepareHeader(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));


	rc = waveOutWrite(_hOutputDevice, _pWaveHeader, sizeof(WAVEHDR));


modified on Thursday, August 12, 2010 12:32 PM

AnswerRe: wave sound not playing properly..sounds different?? Pin
Maximilien12-Aug-10 3:14
Maximilien12-Aug-10 3:14 
QuestionRe: wave sound not playing properly..sounds different?? PinPopular
David Crow12-Aug-10 3:31
David Crow12-Aug-10 3:31 
AnswerRe: wave sound not playing properly..sounds different?? Pin
Niklas L12-Aug-10 5:37
Niklas L12-Aug-10 5:37 
GeneralRe: wave sound not playing properly..sounds different?? Pin
Richard MacCutchan12-Aug-10 6:15
mveRichard MacCutchan12-Aug-10 6:15 
QuestionRe: wave sound not playing properly..sounds different?? Pin
Niklas L12-Aug-10 6:48
Niklas L12-Aug-10 6:48 
AnswerRe: wave sound not playing properly..sounds different?? Pin
Richard MacCutchan12-Aug-10 9:57
mveRichard MacCutchan12-Aug-10 9:57 
GeneralRe: wave sound not playing properly..sounds different?? Pin
AmbiguousName12-Aug-10 6:32
AmbiguousName12-Aug-10 6:32 
AnswerRe: wave sound not playing properly..sounds different?? Pin
Richard MacCutchan12-Aug-10 10:00
mveRichard MacCutchan12-Aug-10 10:00 
QuestionCreateRemoteThread Error Pin
gothic_coder12-Aug-10 0:36
gothic_coder12-Aug-10 0:36 
AnswerRe: CreateRemoteThread Error Pin
_AnsHUMAN_ 12-Aug-10 2:30
_AnsHUMAN_ 12-Aug-10 2:30 
RantRe: CreateRemoteThread Error Pin
Cool_Dev12-Aug-10 3:30
Cool_Dev12-Aug-10 3:30 
AnswerRe: CreateRemoteThread Error Pin
Richard MacCutchan12-Aug-10 4:25
mveRichard MacCutchan12-Aug-10 4:25 
AnswerRe: CreateRemoteThread Error Pin
elchupathingy12-Aug-10 4:56
elchupathingy12-Aug-10 4:56 
GeneralRe: CreateRemoteThread Error Pin
gothic_coder12-Aug-10 21:15
gothic_coder12-Aug-10 21:15 
QuestionDuplicate String Pin
T.RATHA KRISHNAN11-Aug-10 23:08
T.RATHA KRISHNAN11-Aug-10 23:08 
QuestionRe: Duplicate String Pin
CPallini11-Aug-10 23:48
mveCPallini11-Aug-10 23:48 
AnswerRe: Duplicate String Pin
T.RATHA KRISHNAN11-Aug-10 23:59
T.RATHA KRISHNAN11-Aug-10 23:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.