Skocz do zawartości

Zasoby i midi


Gucio

Recommended Posts

Co do odtwarzania midi z pliku to zmajstrowalem cos takiego:

int PlayMIDI(LPSTR lpsFile)
{
        DWORD                   err;
        MCI_PLAY_PARMS          playParams;
        MCI_STATUS_PARMS        statusParams;
    
    /* Check if device is open and plaing song. */
    statusParams.dwItem = MCI_STATUS_MODE;                   
        if((err = mciSendCommand(midiParams.wDeviceID, MCI_STATUS, MCI_STATUS_ITEM, (DWORD)(LPVOID)&statusParams)))
                {
                        /* Exit on error other than "Device not open" */
                        if(err != 0x0101) return FALSE;
                } else {
                        /* Exit if song is still beeing played. */
                        if(statusParams.dwReturn == MCI_MODE_PLAY) return FALSE;
                };           
        
        /* Close a Sequencer device associated with file just in case that it was opened before */
        mciSendCommand(midiParams.wDeviceID, MCI_CLOSE, MCI_WAIT, (DWORD)(LPVOID)&midiParams);

        /* Open a Sequencer device associated with file */
        midiParams.lpstrDeviceType = (LPCSTR)MCI_DEVTYPE_SEQUENCER;
        midiParams.lpstrElementName = lpsFile;
        if((err = mciSendCommand(0, MCI_OPEN, MCI_WAIT|MCI_OPEN_ELEMENT|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID, (DWORD)(LPVOID)&midiParams)))
                {
                /* Error */
                        char chbuf[80], buff[MAX_PATH];

                        LoadString(hInstance,9250,chbuf,80);
                        LoadString(hInstance,9251,buff,MAX_PATH);
                        MessageBox(NULL,buff,chbuf,MB_OK|MB_ICONERROR);
                        if(mciGetErrorString(err, &buff[0], sizeof(buff))) 
                        {
                                sprintf(buff,"%s", &buff[0]);
                                MessageBox(NULL,buff,chbuf,MB_OK|MB_ICONERROR);
                        };
                        return FALSE;
                };

        /* The device opened successfully. midiParams.wDeviceID now contains the device ID */
        if((err = mciSendCommand(midiParams.wDeviceID, MCI_PLAY, MCI_NOTIFY, (DWORD)(LPVOID)&playParams)))
                {
                        /* Error */
                        char chbuf[80], buff[MAX_PATH];

                        LoadString(hInstance,9250,chbuf,80);
                        LoadString(hInstance,9252,buff,MAX_PATH);
                        MessageBox(NULL,buff,chbuf,MB_OK|MB_ICONERROR);
                if(mciGetErrorString(err, &buff[0], sizeof(buff))) 
                        {
                                sprintf(buff,"%s", &buff[0]);
                                MessageBox(NULL,buff,chbuf,MB_OK|MB_ICONERROR);
                        };
                return FALSE;
                };
        /* The device will be close on exit (see DeInitialize_()) or on begining of new song */
        
        return TRUE;
};

(zasoby)

STRINGTABLE
BEGIN
        9250,   "MCI Error"
        9251,   "Can't open MCI device"
        9252,   "Can't play file"
END

Pytanie jak przemielic ta funkcje i zmosic ja do odtwazania midi (wave'a tez mozna po niewielkiej modyfikacji otworzyc) z zasobow?
Probowalem wiele razy i na rozne sposoby (nawet w roznych pozycjach :) ) ale nic z tego. P.S. Nie chcialo mi sie obcinac funkcji wiec ja wrzucilem zywcem z progsa a midiParams to globalna zmienna MCI_OPEN_PARMS Moze ktos to rozgryzie.

Link do komentarza
Udostępnij na innych stronach

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Gość
Odpowiedz...

×   Wkleiłeś zawartość bez formatowania.   Usuń formatowanie

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Utwórz nowe...