Пример #1
0
//------------------------------------------------------------------------//
void MusicManager::OnSegmentStart()
{
	FN("MusicManager::OnSegmentStart()");

	ISegment* pCurrent;
	ISegment* pNext;
	AudioMgr()->GetCurrentSegment(pCurrent);
	if(m_pPlayingInterlude)
	{
		if(!m_pPlayingInterlude->GetTransition(m_pPreviousTheme, pCurrent, pNext))
		{
			m_pPlayingInterlude = 0;
			if(!m_pPlayingTheme)
				return;
			m_pPlayingTheme->StartTheme();
			if(!m_pPlayingTheme->GetTransition(m_pPreviousTheme, pCurrent, pNext))
				return;
		}
	}
	else
	{
		if(!m_pPlayingTheme)
			return;
		if(!m_pPlayingTheme->GetTransition(m_pPreviousTheme, pCurrent, pNext))
			return;
	}
	pNext->Play();

}
Пример #2
0
//------------------------------------------------------------------------//
void AudioManager::UpdateMusic()
{
	FN("AudioManager::UpdateMusic()");

	DMUS_NOTIFICATION_PMSG* pPmsg;
	while(true)
	{
		WaitForSingleObject(m_hMusicNotify, INFINITE);
		if(!m_bInitialized)
		{
			SetEvent(m_hTerm[MUSIC_EVENT]);
			return;
		}
		while (S_OK == m_pMusicPerformance->GetNotificationPMsg(&pPmsg))
		{
			if(pPmsg->guidNotificationType == GUID_NOTIFICATION_MEASUREANDBEAT)
			{
				DebugOut(5, "Music notification: Beat = %d", pPmsg->dwField1);
			}
			else if(pPmsg->guidNotificationType == GUID_NOTIFICATION_PERFORMANCE)
			{
				if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_MUSICALMOSTEND)
				{
					DebugOut(5, "Music notification: Music almost at end");

					if(!m_pCurrentSegment)
						break;

					if(m_pCurrentSegment->IsLooping() && !m_pNextSegment)
					{
						ISegment* pSeg = m_pCurrentSegment;
						m_pCurrentSegment = 0;
						m_pNextSegment = 0;
						pSeg->Play();
					}
					else if(m_pNextSegment)
					{
						ISegment* pSeg = m_pNextSegment;
						m_pCurrentSegment = 0;
						m_pNextSegment = 0;
						pSeg->Play();
					}
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_MUSICSTARTED)
				{
					DebugOut(5, "Music notification: Music started");
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_MUSICSTOPPED)
				{
					DebugOut(5, "Music notification: Music stopped");
				}
			}
			else if(pPmsg->guidNotificationType == GUID_NOTIFICATION_SEGMENT)
			{
				if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGABORT)
				{
					DebugOut(5, "Music notification: Segment aborted");
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGALMOSTEND)
				{
					DebugOut(5, "Music notification: Segment almost at end");
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGEND)
				{
					DebugOut(5, "Music notification: Segment at end");
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGLOOP)
				{
					DebugOut(5, "Music notification: Segment has looped");
				}
				else if(pPmsg->dwNotificationOption == DMUS_NOTIFICATION_SEGSTART)
				{
					DebugOut(5, "Music notification: Segment has started");

					if(m_Init.m_pMusicCallback)
						m_Init.m_pMusicCallback->OnSegmentStart();
				}
			}
			m_pMusicPerformance->FreePMsg((DMUS_PMSG*)pPmsg); 
		}
	}
}