views:

383

answers:

2

Hello

A few months ago I added audio recording to a MFC app that I'm working on. This turned out to be easy enough and after an hour or two the code was working on my PC and on a couple of the customers test machines (one running XP the other Vista). Recently however one of their test machines was upgraded and now the recording feature refuses to work.

The basic code to start the recording is ..

mcierr=mciSendString("open new type waveaudio alias mysound",tmpstr,80,NULL);
mcierr=mciSendString("set mysound time format ms bitspersample 8 samplespersec 11025",tmpstr,80,NULL);
mcierr=mciSendString("record mysound",tmpstr,80,NULL);

which appears to work fine. To stop recording the following code is executed ..

mcierr=mciSendString("stop mysound",tmpstr,80,NULL);
mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL);   
mcierr=mciSendString("close mysound",tmpstr,80,NULL);

The following error occurs when the "save mysound C:\filename.wav" instruction is sent. The error returned is ..

MCI Error A parameter or value was specified twice.  Only specify it once.

But I can't see any error in what I am sending and that error doesn't make sense. Is it possible that the error is because the program is trying to record using a format the PC doesn't support ?

Thanks for your time

Ian

A: 

Hello

OK I managed to find a solution to this. This line in the code ..

mcierr=mciSendString("save mysound C:\\filename.wav",tmpstr,80,NULL);

works fine on my development PC running XP but causes errors on some test PC's running XP and on all of them running Vista. The error goes away however if the filename itself is put within quotes like this ..

mcierr=mciSendString("save mysound "C:\\filename.wav"",tmpstr,80,NULL);

Now the code runs fine on all the XP and Vista PC's it has been tested on.

Ian

IanW
A: 

Hi, I trying to do this but I am very new in C#. Could you please give you full code for this. Many thanks. Best, Mamun [email protected]

Sorry I have never used C# so can't help. However if you Google mciSendString and C# there seem to be plenty of code examples online. Sorry I can't help more and good luck with this.
IanW