public Segment(psai.ProtoBuf_Snippet pbSnippet) : this() { this.Id = pbSnippet.id; this.ThemeId = pbSnippet.theme_id; this.Intensity = pbSnippet.intensity; this.SnippetTypeBitfield = pbSnippet.snippet_type; this.Name = pbSnippet.name; this.audioData = new AudioData(pbSnippet.audio_data); for (int i = 0; i < pbSnippet.follower_id.Count; i++) { Follower follower = new Follower(pbSnippet.follower_id[i], pbSnippet.follower_compatibility[i]); this.Followers.Add(follower); } }
Segment GetBestStartSegmentForTheme_internal(Theme theme, float intensity) { //boost::recursive_mutex::scoped_lock block(m_pnxLogicMutex); float maxDeltaIntensity = 0.0f; int minAbgespielt = 0; int maxAbgespielt = 0; // Vergleichsliste aufbauen List<Follower> segmentList = new List<Follower>(); int teilstueckeCount = theme.m_segments.Count; for (int i=0; i < teilstueckeCount; i++) { Segment tempTeil = theme.m_segments[i]; if (tempTeil != null) { if ( ((int)SegmentSuitability.start & tempTeil.SnippetTypeBitfield ) > 0 ) { if (i==0) { minAbgespielt = tempTeil.Playcount; } else { if (tempTeil.Playcount < minAbgespielt) minAbgespielt = tempTeil.Playcount; } if (tempTeil.Playcount > maxAbgespielt) maxAbgespielt = tempTeil.Playcount; float tDeltaIntensity = intensity - tempTeil.Intensity; if (tDeltaIntensity < 0.0f) tDeltaIntensity = tDeltaIntensity * -1.0f; if (tDeltaIntensity > maxDeltaIntensity) maxDeltaIntensity = tDeltaIntensity; // kreiere eine snippetType Nachfolger Follower vorfolger = new Follower(); vorfolger.snippetId = tempTeil.Id; vorfolger.compatibility = 1.0f; // compatiblity is ignored for Start-Segments and therefore set to 1.0f segmentList.Add(vorfolger); } } else { #if !(PSAI_NOLOG) { if (LogLevel.errors <= Logger.Instance.LogLevel) { StringBuilder sb = new StringBuilder(); sb.Append("INTERNAL ERROR ! GetBestStartSegmentForTheme_internal() - a Segment with id "); sb.Append(tempTeil.Id); sb.Append(" could not be found!"); Logger.Instance.Log(sb.ToString(), LogLevel.errors); } } #endif } } Weighting weighting = theme.weightings; return ChooseBestSegmentFromList(segmentList, weighting, intensity, maxAbgespielt, minAbgespielt, maxDeltaIntensity); }
public Segment(psai.ProtoBuf_Snippet pbSnippet) : this() { this.Id = pbSnippet.id; this.ThemeId = pbSnippet.theme_id; this.Intensity = pbSnippet.intensity; this.SnippetTypeBitfield = pbSnippet.snippet_type; this.Name = pbSnippet.name; this.audioData = new AudioData(pbSnippet.audio_data); for (int i=0; i<pbSnippet.follower_id.Count; i++) { Follower follower = new Follower(pbSnippet.follower_id[i], pbSnippet.follower_compatibility[i]); this.Followers.Add(follower); } }