private void BuildMarkCollections(ICollection <IMarkCollection> markCollection, BeatBarSettingsData settings) { List <MarkCollection> retVal = new List <MarkCollection>(); m_featureSet = GenerateFeatures(m_plugin, m_fSamplesAll); String[] beatCollectionNames = settings.BeatCollectionNames(false); String[] splitCollectionNames = settings.BeatCollectionNames(true); if (settings.BarsEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.BarsCollectionName)); var mc = ExtractBarMarksFromFeatureSet(m_featureSet[1], settings); mc.Decorator.Color = settings.BarsColor; retVal.Add(mc); } if (settings.BeatCollectionsEnabled) { foreach (String name in beatCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List <MarkCollection> mcl = ExtractBeatCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.Decorator.Color = settings.BeatCountsColor); retVal.AddRange(mcl); } if (settings.BeatSplitsEnabled) { foreach (String name in splitCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List <MarkCollection> mcl = ExtractSplitCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.Decorator.Color = settings.BeatSplitsColor); retVal.AddRange(mcl); } if (settings.AllFeaturesEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.AllCollectionName)); MarkCollection mc = ExtractAllMarksFromFeatureSet(m_featureSet[0], settings); mc.Decorator.Color = settings.AllFeaturesColor; retVal.Add(mc); } retVal.RemoveAll(x => x.Marks.Count == 0); markCollection.AddRange(retVal.OrderBy(x => x.Name)); }
ExtractBeatCollectionsFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings, List <MarkCollection> otherMarks = null) { List <MarkCollection> retVal = new List <MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(false); for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Name = collectionNames[j - 1]; foreach (ManagedFeature feature in featureSet) { if ((feature.hasTimestamp) && (feature.label == j.ToString())) { var featureMS = feature.timestamp.totalMilliseconds(); mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return(retVal); }
ExtractSplitCollectionsFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings, List <MarkCollection> otherMarks = null) { List <MarkCollection> retVal = new List <MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(true); KeyValuePair <int, double>[] tsValuePairs = new KeyValuePair <int, double> [(featureSet.Count * 2)]; int count = 0; double featureMS = -1; double lastFeatureMS = -1; int labelVal = 0; ManagedFeature lastFeature = null; foreach (ManagedFeature feature in featureSet) { if (lastFeature == null) { lastFeature = feature; continue; } labelVal = (Convert.ToInt32(lastFeature.label) * 2) - 1; lastFeatureMS = lastFeature.timestamp.totalMilliseconds(); tsValuePairs[count++] = new KeyValuePair <int, double>(labelVal, lastFeatureMS); featureMS = feature.timestamp.totalMilliseconds(); tsValuePairs[count] = new KeyValuePair <int, double>(labelVal + 1, lastFeatureMS + ((featureMS - lastFeatureMS) / settings.Divisions)); count++; lastFeature = feature; } for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = collectionNames[j - 1]; foreach (KeyValuePair <int, double> tsValue in tsValuePairs) { if (tsValue.Key == j) { mc.Marks.Add(TimeSpan.FromMilliseconds(tsValue.Value)); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return(retVal); }
private List<MarkCollection> BuildMarkCollections(List<MarkCollection> markCollection, BeatBarSettingsData settings) { List<MarkCollection> retVal = new List<MarkCollection>(); m_featureSet = GenerateFeatures(m_plugin, m_fSamplesAll); String[] beatCollectionNames = settings.BeatCollectionNames(false); String[] splitCollectionNames = settings.BeatCollectionNames(true); if (settings.BarsEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.BarsCollectionName)); MarkCollection mc = ExtractBarMarksFromFeatureSet(m_featureSet[1], settings); mc.MarkColor = settings.BarsColor; retVal.Add(mc); } if (settings.BeatCollectionsEnabled) { foreach (String name in beatCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List<MarkCollection> mcl = ExtractBeatCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.MarkColor = settings.BeatCountsColor); retVal.AddRange(mcl); } if (settings.BeatSplitsEnabled) { foreach (String name in splitCollectionNames) { markCollection.RemoveAll(x => x.Name.Equals(name)); } List<MarkCollection> mcl = ExtractSplitCollectionsFromFeatureSet(m_featureSet[2], settings, retVal); mcl.ForEach(x => x.MarkColor = settings.BeatSplitsColor); retVal.AddRange(mcl); } if (settings.AllFeaturesEnabled) { markCollection.RemoveAll(x => x.Name.Equals(settings.AllCollectionName)); MarkCollection mc = ExtractAllMarksFromFeatureSet(m_featureSet[0], settings); mc.MarkColor = settings.AllFeaturesColor; retVal.Add(mc); } retVal.RemoveAll(x => x.Marks.Count == 0); retVal.AddRange(markCollection); return retVal.OrderBy(x => x.Name).ToList(); }
ExtractSplitCollectionsFromFeatureSet(ICollection<ManagedFeature> featureSet, BeatBarSettingsData settings, List<MarkCollection> otherMarks = null ) { List<MarkCollection> retVal = new List<MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(true); KeyValuePair<int,double>[] tsValuePairs = new KeyValuePair<int, double>[(featureSet.Count * 2)]; int count = 0; double featureMS = -1; double lastFeatureMS = -1; int labelVal = 0; ManagedFeature lastFeature = null; foreach (ManagedFeature feature in featureSet) { if (lastFeature == null) { lastFeature = feature; continue; } labelVal = (Convert.ToInt32(lastFeature.label) * 2) - 1; lastFeatureMS = lastFeature.timestamp.totalMilliseconds(); tsValuePairs[count++] = new KeyValuePair<int, double>(labelVal, lastFeatureMS); featureMS = feature.timestamp.totalMilliseconds(); tsValuePairs[count] = new KeyValuePair<int, double>(labelVal + 1, lastFeatureMS + ((featureMS - lastFeatureMS) / settings.Divisions)); count++; lastFeature = feature; } for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = collectionNames[j - 1]; foreach (KeyValuePair<int,double> tsValue in tsValuePairs) { if (tsValue.Key == j) { mc.Marks.Add(TimeSpan.FromMilliseconds(tsValue.Value)); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return retVal; }
ExtractBeatCollectionsFromFeatureSet(ICollection<ManagedFeature> featureSet, BeatBarSettingsData settings, List<MarkCollection> otherMarks = null) { List<MarkCollection> retVal = new List<MarkCollection>(); string[] collectionNames = settings.BeatCollectionNames(false); for (int j = 1; j <= collectionNames.Length; j++) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = collectionNames[j-1]; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if ((feature.hasTimestamp) && (feature.label == j.ToString())) { featureMS = feature.timestamp.totalMilliseconds(); mc.Marks.Add(TimeSpan.FromMilliseconds(featureMS)); } } RemoveDuplicateMarks(ref mc, otherMarks); retVal.Add(mc); } return retVal; }