Back in Step 4: Setting Up Notifications we saw how DMDonuts requests notification whenever a segment ends and whenever a beat or measure boundary is reached. The purpose of this notification is to help limit the number of "blowup" motifs playing at any one time.
Notifications are retrieved in the WinMain function. After dealing with any messages in the queue, the application checks to see if there are any pending notifications. It does this by calling the IDirectMusicPerformance::GetNotificationPMsg method. If no notification message is pending, the method returns S_FALSE and no further action is needed. A return of S_OK indicates that a notification message has been placed in *pEvent. Because it has only requested notifications relevant to the beat, the application doesn't actually need to examine the message, which is immediately discarded. It then resets snMaxBlowUps, which tracks how many more blowup motifs can be played till the next beat.
if (gpPerformance)
{
DMUS_NOTIFICATION_PMSG* pEvent;
while ( S_OK == gpPerformance->GetNotificationPMsg(&pEvent))
{
gpPerformance->FreePMsg((DMUS_PMSG*)pEvent);
snMaxBlowUps = BLOWUPS_PER_BEAT;
}
}