MidiNext

BOOL WINAPI MidiNext
(
	HANDLE hSequence
);

This function plays any pending event of the sequence. This function is intended for custom playback. See Remarks below.

Parameters

Return values

TRUE if something was played or FALSE if not. Note that you cannot use this function to determine an erroneous behaviour of the sequence.

Remarks

The sequence must have been opened with MidiOpen or created with MidiCreate before to be played. MidiNext returns to position zero if the end of the sequence was reached.

Include MidiNext in a loop to make a manual playback. In the example below, it was included in the main message loop with low priority.

Example

HANDLE Sequence;
MSG msg;
BOOL ShouldPlay, Silenced;

// Open the sequence

MidiOpen("test1.mid", DEFAULT_DEVICE, &Sequence);

// Message loop

msg.message = 0;
ShouldPlay = TRUE;
Silenced = TRUE;

while (msg.message!=WM_QUIT)
{
    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        DispatchMessage(&msg);
    else
        if (ShouldPlay) 
        {
            MidiNext(Sequence);
            Silenced = FALSE;

            // Any other application processing of playback
        }
        else
        {
            if (!Silenced)
            {
                // Stops the sound
                MidiSilence(Sequence);
                Silenced = TRUE;
            };
        };
};

// Finishes

MidiClose(Sequence);

The value of ShouldPlay is controlled by the user input to play or to stop. Another approach for manual playback is to include MidiNext in a timer. The recommended method, of course, is to use MidiPlay.


Further information

Released in November 19th, 2003
Updated in April 29th, 2004
Property of Breno de Lima Sarmento
Home page: http://www27.brinkster.com/brels
E-mail: [email protected]
ICQ: 78977999 ()