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); }
ExtractAllMarksFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Name = settings.AllCollectionName; double lastFeatureMS = -1; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); if (lastFeatureMS != -1) { double interval = (featureMS - lastFeatureMS) / settings.Divisions; for (int j = 0; j < settings.Divisions; j++) { mc.AddMark(new Mark(TimeSpan.FromMilliseconds(lastFeatureMS + (interval * j)))); } } else { mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } lastFeatureMS = featureMS; } } return(mc); }
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); }
public BeatsAndBarsDialog(Audio audio) { InitializeComponent(); ForeColor = ThemeColorTable.ForeColor; BackColor = ThemeColorTable.BackgroundColor; var excludes = new List <Control>(); excludes.Add(BarsColorPanel); excludes.Add(BeatCountsColorPanel); excludes.Add(AllColorPanel); excludes.Add(BeatSplitsColorPanel); ThemeUpdateControls.UpdateControls(this, excludes); m_allowUpdates = false; m_toolTip = new ToolTip(); m_toolTip.AutoPopDelay = 5000; m_toolTip.InitialDelay = 500; m_toolTip.ReshowDelay = 500; m_toolTip.ShowAlways = true; m_toolTip.Active = true; m_toolTip.SetToolTip(AllFeaturesCB, "Single Collection containing all features"); m_toolTip.SetToolTip(BarsCB, "Single Collection containing starting location of each measure/bar"); m_toolTip.SetToolTip(BeatCountsCB, "Generates a beat collection for each beat count"); m_toolTip.SetToolTip(BeatSplitsCB, "Generates a beat collection for each beat count and each beat count split"); m_toolTip.SetToolTip(BeatsNameTB, "Base name of each collection"); m_toolTip.SetToolTip(AllColorPanel, "Color of All Features Collection"); m_toolTip.SetToolTip(BarsColorPanel, "Color of Bars Collection"); m_toolTip.SetToolTip(BeatCountsColorPanel, "Color of Beat Counts Collection"); m_toolTip.SetToolTip(BeatSplitsColorPanel, "Color of Beat Splits Collection"); m_settingsData = m_settingsData ?? new BeatBarSettingsData("Beats"); BarsCB.Checked = true; AllFeaturesCB.Checked = true; BeatCountsCB.Checked = true; BeatSplitsCB.Checked = false; m_allowUpdates = true; SetBeatBarOutputSettings(); musicStaff1.Width = grpDivisions.ClientSize.Width - 20; m_previewWaveForm = new PreviewWaveform(audio); m_previewWaveForm.Anchor = AnchorStyles.Left | AnchorStyles.Right; PreviewGroupBox.Controls.Add(m_previewWaveForm); m_previewWaveForm.Width = PreviewGroupBox.ClientSize.Width - 25; m_previewWaveForm.Height = PreviewGroupBox.ClientSize.Height / 2; m_previewWaveForm.Location = new Point(musicStaff1.Location.X, PreviewGroupBox.ClientSize.Height / 2 - m_previewWaveForm.Height / 2); musicStaff1.SettingChanged += MusicStaffSettingsChanged; }
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)); }
public BeatsAndBarsDialog(Audio audio) { InitializeComponent(); ForeColor = ThemeColorTable.ForeColor; BackColor = ThemeColorTable.BackgroundColor; var excludes = new List<Control>(); excludes.Add(BarsColorPanel); excludes.Add(BeatCountsColorPanel); excludes.Add(AllColorPanel); excludes.Add(BeatSplitsColorPanel); ThemeUpdateControls.UpdateControls(this, excludes); m_allowUpdates = false; m_toolTip = new ToolTip(); m_toolTip.AutoPopDelay = 5000; m_toolTip.InitialDelay = 500; m_toolTip.ReshowDelay = 500; m_toolTip.ShowAlways = true; m_toolTip.Active = true; m_toolTip.SetToolTip(AllFeaturesCB, "Single Collection containing all features"); m_toolTip.SetToolTip(BarsCB, "Single Collection containing starting location of each measure/bar"); m_toolTip.SetToolTip(BeatCountsCB, "Generates a beat collection for each beat count"); m_toolTip.SetToolTip(BeatSplitsCB, "Generates a beat collection for each beat count and each beat count split"); m_toolTip.SetToolTip(BeatsNameTB, "Base name of each collection"); m_toolTip.SetToolTip(AllColorPanel, "Color of All Features Collection"); m_toolTip.SetToolTip(BarsColorPanel, "Color of Bars Collection"); m_toolTip.SetToolTip(BeatCountsColorPanel, "Color of Beat Counts Collection"); m_toolTip.SetToolTip(BeatSplitsColorPanel, "Color of Beat Splits Collection"); m_settingsData = m_settingsData ?? new BeatBarSettingsData("Beats"); BarsCB.Checked = true; AllFeaturesCB.Checked = true; BeatCountsCB.Checked = true; BeatSplitsCB.Checked = false; m_allowUpdates = true; SetBeatBarOutputSettings(); m_previewWaveForm = new PreviewWaveform(audio); m_previewWaveForm.Width = musicStaff1.Width; m_previewWaveForm.Height = 75; m_previewWaveForm.Location = new Point(musicStaff1.Location.X, 25); musicStaff1.SettingChanged += MusicStaffSettingsChanged; PreviewGroupBox.Controls.Add(m_previewWaveForm); }
ExtractBarMarksFromFeatureSet(ICollection <ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Name = settings.BarsCollectionName; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); mc.AddMark(new Mark(TimeSpan.FromMilliseconds(featureMS))); } } return(mc); }
private BeatBarPreviewData GeneratePreviewData() { BeatBarPreviewData previewData = new BeatBarPreviewData(1); QMBarBeatTrack plugin = new QMBarBeatTrack(m_audioModule.Frequency); plugin.SetParameter("bpb", 4); plugin.Initialise(1, (uint)plugin.GetPreferredStepSize(), (uint)plugin.GetPreferredBlockSize()); IDictionary <int, ICollection <ManagedFeature> > featureSet = GenerateFeatures(plugin, m_fSamplesPreview, false); previewData.BeatPeriod = EstimateBeatPeriod(featureSet[2]); BeatBarSettingsData settings = new BeatBarSettingsData("Preview"); settings.Divisions = 1; settings.BeatSplitsEnabled = false; settings.NoteSize = 4; settings.BeatsPerBar = 4; List <MarkCollection> collections = ExtractBeatCollectionsFromFeatureSet(featureSet[2], settings); MarkCollection allCollection = new MarkCollection(); allCollection.Name = "Beat Marks"; collections.ForEach(x => allCollection.AddMarks(x.Marks)); allCollection.EnsureOrder(); previewData.PreviewCollection = allCollection; settings.BeatSplitsEnabled = true; settings.Divisions = 2; collections = ExtractSplitCollectionsFromFeatureSet(featureSet[2], settings); allCollection = new MarkCollection(); allCollection.Name = "Beat Split Marks"; collections.ForEach(x => allCollection.AddMarks(x.Marks)); allCollection.EnsureOrder(); previewData.PreviewSplitCollection = allCollection; return(previewData); }
ExtractAllMarksFromFeatureSet(ICollection<ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = settings.AllCollectionName; double lastFeatureMS = -1; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); if (lastFeatureMS != -1) { double interval = (featureMS - lastFeatureMS) / settings.Divisions; for (int j = 0; j < settings.Divisions; j++) { mc.Marks.Add(TimeSpan.FromMilliseconds(lastFeatureMS + (interval * j))); } } else { mc.Marks.Add(TimeSpan.FromMilliseconds(featureMS)); } lastFeatureMS = featureMS; } } return mc; }
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(); }
private BeatBarPreviewData GeneratePreviewData() { BeatBarPreviewData previewData = new BeatBarPreviewData(1); QMBarBeatTrack plugin = new QMBarBeatTrack(m_audioModule.Frequency); plugin.SetParameter("bpb", 4); plugin.Initialise(1, (uint)plugin.GetPreferredStepSize(), (uint)plugin.GetPreferredBlockSize()); IDictionary<int, ICollection<ManagedFeature>> featureSet = GenerateFeatures(plugin, m_fSamplesPreview, false); previewData.BeatPeriod = EstimateBeatPeriod(featureSet[2]); BeatBarSettingsData settings = new BeatBarSettingsData("Preview"); settings.Divisions = 1; settings.BeatSplitsEnabled = false; settings.NoteSize = 4; settings.BeatsPerBar = 4; List<MarkCollection> collections = ExtractBeatCollectionsFromFeatureSet(featureSet[2], settings); MarkCollection allCollection = new MarkCollection(); allCollection.Name = "Beat Marks"; collections.ForEach(x => allCollection.Marks.AddRange(x.Marks)); allCollection.Marks.Sort(); previewData.PreviewCollection = allCollection; settings.BeatSplitsEnabled = true; settings.Divisions = 2; collections = ExtractSplitCollectionsFromFeatureSet(featureSet[2], settings); allCollection = new MarkCollection(); allCollection.Name = "Beat Split Marks"; collections.ForEach(x => allCollection.Marks.AddRange(x.Marks)); allCollection.Marks.Sort(); previewData.PreviewSplitCollection = allCollection; return previewData; }
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; }
ExtractBarMarksFromFeatureSet(ICollection<ManagedFeature> featureSet, BeatBarSettingsData settings) { MarkCollection mc = new MarkCollection(); mc.Enabled = true; mc.Name = settings.BarsCollectionName; double featureMS = -1; foreach (ManagedFeature feature in featureSet) { if (feature.hasTimestamp) { featureMS = feature.timestamp.totalMilliseconds(); mc.Marks.Add(TimeSpan.FromMilliseconds(featureMS)); } } return mc; }