🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.multimedia
Article #1062

Re: playing midi files

#1062
From: PaoloItaly
Date: Mon, 03 Dec 2001 11:15
80 lines
3378 bytes
void stopMIDIFile(UINT wDeviceID)
{
    ::mciSendCommand(wDeviceID, MCI_CLOSE, 0, NULL);
}

DWORD playMIDIFile(HWND hWndNotify, LPSTR lpszMIDIFileName, UINT *wDeviceID)
{
    DWORD dwReturn;
    MCI_OPEN_PARMS mciOpenParms;
    MCI_PLAY_PARMS mciPlayParms;
    MCI_STATUS_PARMS mciStatusParms;
    MCI_SEQ_SET_PARMS mciSeqSetParms;

    // Open the device by specifying the device and filename.
    // MCI will attempt to choose the MIDI mapper as the output port.
    mciOpenParms.lpstrDeviceType = "sequencer";
    mciOpenParms.lpstrElementName = lpszMIDIFileName;
    if (dwReturn = ::mciSendCommand(NULL, MCI_OPEN,
        MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,
        (DWORD)(LPVOID) &mciOpenParms))
    {
        // Failed to open device. Don't close it; just return error.
        return (dwReturn);
    }

    // The device opened successfully; get the device ID.
    *wDeviceID = mciOpenParms.wDeviceID;

    // Check if the output port is the MIDI mapper.
    mciStatusParms.dwItem = MCI_SEQ_STATUS_PORT;
    if (dwReturn = ::mciSendCommand(*wDeviceID, MCI_STATUS,
        MCI_STATUS_ITEM, (DWORD)(LPVOID) &mciStatusParms))
    {
        ::mciSendCommand(*wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    // The output port is not the MIDI mapper.
    // Ask if the user wants to continue.
/*    if (LOWORD(mciStatusParms.dwReturn) != MIDI_MAPPER)
    {
        if (::MessageBox(hWndNotify,
            "The MIDI mapper is not available. Continue?",
            "", MB_YESNO) == IDNO)
        {
            // User does not want to continue. Not an error;
            // just close the device and return.
            ::mciSendCommand(*wDeviceID, MCI_CLOSE, 0, NULL);
            return (0L);
        }
    }*/

    // Begin playback. The window procedure function for the parent
    // window will be notified with an MM_MCINOTIFY message when
    // playback is complete. At this time, the window procedure closes
    // the device.
    mciPlayParms.dwCallback = (DWORD) hWndNotify;
    if (dwReturn = ::mciSendCommand(*wDeviceID, MCI_PLAY, MCI_NOTIFY,
        (DWORD)(LPVOID) &mciPlayParms))
    {
        ::mciSendCommand(*wDeviceID, MCI_CLOSE, 0, NULL);
        return (dwReturn);
    }

    return (0L);
}

Ciao

"Greg Caughill" <gcaughil@sentex.net> ha scritto nel messaggio
news:3c0852b0_1@dnews...
> Hi,
>
> How can I play midi files in builder, I don't know much about sound
related
> functions.
>
> Thanks
>
>
Technical Details
Message-ID: <3c0b609b$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews
References: <3c0852b0_1@dnews>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d0fc,970c0fc02ba566
X-Google-Attributes: gid10d0fc,public
X-Google-ArrivalTime: 2001-12-03 03:35:23 PST
From: "PaoloItaly" <paolo@sirius.tecnoparco.it>
Newsgroups: borland.public.cppbuilder.multimedia
References: <3c0852b0_1@dnews>
Subject: Re: playing midi files
Date: Mon, 3 Dec 2001 12:15:55 +0100
Lines: 82
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 212.110.49.193
Message-ID: <3c0b609b$1_2@dnews>
X-Trace: dnews 1007378587 212.110.49.193 (3 Dec 2001 03:23:07 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!dnews