hieurl's world

MCI?

Posted in Nara audio player, Projects by Hieu T. Luong on May 17, 2010

After doing some searching with Google about the method to play an audio file on Windows, most of the returned result are about the Microsoft’s Multimedia Control Interface, calling the function PlaySound() of that library.
But it’s just playing, and there are still a lot to handle, including volume control, fast forward, fast backward, … So I look a closer look to the MCI and found something interesting about reading a wav file in it. So I’ll try to do something with it, like reverse the file, fasten it,… to get acquainted with the library. The PlaySound() is for later, hehe
A lot of troubles happen when start working with the Visual Studio. Its linker is kind of a mess :( Lot of configurations to make it work with the library :-(

Update:
I’ve just written few lines of code, well, it can run but there’s still one thing I still cannot get:

UCHAR * buffer = new UCHAR[child.cksize];
unsigned long n = sizeof(buffer);
mmioRead(handle, (char*)buffer, child.cksize);
n = sizeof(buffer);

The value of child.cksize is really big, greater than 20k, but when I allocate the buffer and check for the value of n, before and after the mmioRead funtion call, it is always 4 :(
The things I get confuse is that, after those code, I call a function to write down the buffer to another file, it works perfectly with the buffer I pass on :( The write function:

bool song::write(unsigned long size, UCHAR* buffer) {
// Get a new file name
char outwav[MAX_PATH];
ZeroMemory(&outwav[0],sizeof(outwav));
strcpy(&outwav[0],”hieu.wav”);
outwav[strlen(&outwav[0])-3] = ‘p’;
outwav[strlen(&outwav[0])-2] = ‘c’;
outwav[strlen(&outwav[0])-1] = ‘m’;
// Write the data
LPWSTR temp = strToLPWSTR(&outwav[0]);
HANDLE hpcm = CreateFile((LPCWSTR)temp,GENERIC_WRITE,NULL,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
DWORD written;
WriteFile(hpcm,&buffer[0],size,&written,NULL);
CloseHandle(hpcm);

return true;
}

Gotta figure out what the heck is this soon :(

Follow

Get every new post delivered to your Inbox.