// this wrapper is needed to set the intensity slope correcly, when a theme was popped from the themeQueue PsaiResult PlayThemeNowOrAtEndOfCurrentSegment(ThemeQueueEntry tqe, bool immediately) { return PlayThemeNowOrAtEndOfCurrentSegment(tqe.themeId, tqe.startIntensity, tqe.musicDuration, immediately, tqe.holdIntensity); }
/** basic internal function for setting the first theme that will be played as soon as the * current theme's intensity has dropped (or has been set) to zero. This method behaves as a push operation, so the parameter will be * the first theme on the theme queue stack. * @param clearThemeQueue pass true to clear the themeQueue, false to enqueue the followingTheme in the themeQueue * @param restTimeMillis if the theme should start in rest mode, pass the resting millis. 0 otherwise. * @param playMode the playMode that will be entered when the theme is popped. * @param holdIntensity true for holding the intensity at a constant level */ bool pushThemeToThemeQueue(int themeId, float intensity, int musicDuration, bool clearThemeQueue, int restTimeMillis, PsaiPlayMode playMode, bool holdIntensity) { //boost::recursive_mutex::scoped_lock block(m_pnxLogicMutex); #if !(PSAI_NOLOG) { if (LogLevel.info <= Logger.Instance.LogLevel) { StringBuilder sb = new StringBuilder(); sb.Append("setting the Following Theme to "); sb.Append(themeId); if (LogLevel.debug <= Logger.Instance.LogLevel) { sb.Append(" intensity= "); sb.Append(intensity); sb.Append(" clearThemeQueue="); sb.Append(clearThemeQueue); sb.Append(" playmode="); sb.Append(playMode); sb.Append(" holdIntensity="); sb.Append(holdIntensity); sb.Append(" musicDuration="); sb.Append(musicDuration); } Logger.Instance.Log(sb.ToString(), LogLevel.info); } } #endif if (clearThemeQueue) { m_themeQueue.Clear(); } Theme theme = m_soundtrack.getThemeById(themeId); if (theme != null) { ThemeQueueEntry newEntry = new ThemeQueueEntry(); newEntry.themeId = themeId; newEntry.startIntensity = intensity; newEntry.musicDuration = musicDuration; newEntry.restTimeMillis = restTimeMillis; newEntry.playmode = playMode; newEntry.holdIntensity = holdIntensity; #if !(PSAI_NOLOG) { if (LogLevel.debug <= Logger.Instance.LogLevel) { StringBuilder sb = new StringBuilder(); sb.Append(" m_themeQueue.size()="); sb.Append(m_themeQueue.Count); for (int i=0; i<m_themeQueue.Count; i++) { ThemeQueueEntry tmpEntry = m_themeQueue[i]; sb.Append(" ["); sb.Append(i); sb.Append("] themeId="); sb.Append(tmpEntry.themeId); sb.Append(" startIntensity="); sb.Append(tmpEntry.startIntensity); } Logger.Instance.Log(sb.ToString(), LogLevel.debug); } } #endif m_themeQueue.Insert(0, newEntry); m_psaiStateIntended = PsaiState.playing; // in case IntensityZeroHandler() had already been called, we need to reset the psaiStateIntended here return true; } else { return false; } }