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 :(

Advertisement

4 Responses

Subscribe to comments with RSS.

  1. Tran Diep Hue Man said, on May 18, 2010 at 12:02 pm

    You’re in your way to your dream :D
    But can you be more specific on your post because I don’t understand what is the purpose of those code.

    • lthieu said, on May 18, 2010 at 12:11 pm

      It is very little, so I didn’t post it here, just like you open a file using fstream library and copy the content to an array of characters :D
      I’ll make a detail post when I finish something significant :D

  2. Tran Diep Hue Man said, on May 18, 2010 at 9:56 pm

    Hiếu, I think you should modify your CSS file at line blockquote, insert “overflow:auto;” to adjust horizontal scroll-bar for the code.

  3. nadanaz said, on May 18, 2010 at 11:41 pm

    Ooh, find all you guys here. Hello from Nadan :) )


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.