Sign in to follow this  
NoobApmHacksMap

mci does not recognize wav file?

Recommended Posts

Hi Everybody, I have a very strange problem with Media Control Interface. Basically I generated a bounch of .wav files with MatLab wavwrite function (sampler rate 44.1khz, 32-bit encoding,5 seconds long). However, none of the .wav files are recognized by mci (I tried simple PlaySound() function too and doesn't work). First I used mciSendString() mci would give me an error (error 296):"The specified file cannot be played on the specified MCI device. The file may be corrupt, not in the correct format, or no file handler avaliable for this format". On the other hand, all of the .wav files can be played by any other media player there is (real player, windows media player, etc...) I don't really know what's going on here. the source code is of the following #include <stdio.h> #include <iostream> #include <windows.h> #include <mmsystem.h> using namespace std; // MCI int main() { if(mciSendString("open new type waveaudio alias mysound buffer 5", NULL, 0, NULL) == 0) cout << "Driver Initialized ?" << endl; else cout << "Driver Not initialized" << endl; getchar(); DWORD Error = mciSendString("play 0.5kHz.wav from 0 to 5000",NULL, 0, NULL); char ErrorStr[256]; if(Error == 0) cout << "Succeed? ..." << endl; else { cout << "Failed..." << Error << endl; mciGetErrorString(Error,ErrorStr,256); cout << ErrorStr << endl; } getchar(); return 0; } here is the reference for wavwrite function http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/access/helpdesk/help/techdoc/ref/wavwrite.html&http://www.google.ca/search?hl=en&q=matlab+wavwrite&meta=

Share this post


Link to post
Share on other sites
Do other wav files work with your code, or do all of them fail with the same error?

Can you play them with PlaySound()?

I've not used mci at all, but according to: another site the command string you need is something like:

open waveaudio!c:\win95\media\chimes.wav

or

open c:\win95\media\chimes.wav type waveaudio

And yours doesn't match either pattern. Are you sure your command string is correct? Do the example ones on that site work if you put in an appropriate filename?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this