1 Replies - 1236 Views - Last Post: 19 March 2013 - 07:00 AM Rate Topic: -----

#1 roopavelumani  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 12-March 13

Music player and recorder in vc++ 2008

Posted 19 March 2013 - 05:20 AM

i am developing an MFC application in vc++ 2008...that enables the user to play music tracks and record sounds..
when i am trying to record sounds it shows an error such tat"Invalid MCI device id .use the id that is returned while opening the device" i hereby have attached the code ..


void CmineDlg::OnRecord()
{
	// TODO: Add your control notification handler code here

MCIWndNew(hwnd,"waveaudio");
	MCI_WAVE_SET_PARMS set_parms; // audio parameters
	set_parms.wFormatTag      = WAVE_FORMAT_PCM;
	set_parms.wBitsPerSample  = 16;
	set_parms.nChannels       = 1;
	set_parms.nSamplesPerSec  = 44100;
	set_parms.nBlockAlign     = (set_parms.nChannels*set_parms.wBitsPerSample)/8;
	set_parms.nAvgBytesPerSec = ((set_parms.wBitsPerSample) *
								set_parms.nChannels *
								set_parms.nSamplesPerSec)/8;
	// now send the format changes with MCI_SET
	int deviceID=MCIWndGetDeviceID(hwnd);
	int result = mciSendCommand( deviceID, MCI_SET,
							   MCI_WAIT
							 | MCI_WAVE_SET_FORMATTAG
							 | MCI_WAVE_SET_BITSPERSAMPLE
							 | MCI_WAVE_SET_CHANNELS
							 | MCI_WAVE_SET_SAMPLESPERSEC
							 | MCI_WAVE_SET_AVGBYTESPERSEC
							 | MCI_WAVE_SET_BLOCKALIGN,
							   (DWORD)(LPVOID)&set_parms);
	if ( result ) // failed?
	{
		char buffer[100];
	    mciGetErrorString(result,LPWSTR(buffer), sizeof(buffer));
		AfxMessageBox(LPCTSTR(buffer));
		return;
	}

	if (MCIWndCanRecord(hwnd))
		MCIWndRecord(hwnd);		

}


This post has been edited by Skydiver: 19 March 2013 - 05:31 AM
Reason for edit:: Put code into code tags. Learn to do this yourself.


Is This A Good Question/Topic? 0
  • +

Replies To: Music player and recorder in vc++ 2008

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8964
  • View blog
  • Posts: 33,624
  • Joined: 12-June 08

Re: Music player and recorder in vc++ 2008

Posted 19 March 2013 - 07:00 AM

Wow.. copy/pasting code from 2002!
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1