public MarkCollection(MarkCollection original) { Marks = new List <TimeSpan>(original.Marks); Id = Guid.NewGuid(); MarkColor = original.MarkColor; Level = original.Level; Enabled = original.Enabled; Name = original.Name; }
public MarkCollection(MarkCollection original) { Marks = new List<TimeSpan>(original.Marks); Id = Guid.NewGuid(); MarkColor = original.MarkColor; Level = original.Level; Enabled = original.Enabled; Name = original.Name; }
private void RemoveDuplicateMarks(ref MarkCollection mcOrig, List<MarkCollection> otherCollections) { if (otherCollections != null) { foreach (var otherCollection in otherCollections) { mcOrig.Marks.RemoveAll(x => otherCollection.Marks.Contains(x)); } } }
private void buttonAddCollection_Click(object sender, EventArgs e) { MarkCollection newCollection = new MarkCollection(); newCollection.Name = "New Collection"; MarkCollections.Add(newCollection); // populate the form with the new collection first, *then* update the collection list, // so that the displayed collection is remembered and selected in the list. PopulateFormWithMarkCollection(newCollection); PopulateMarkCollectionsList(); }
private Tuple<TimeSpan, TimeSpan> CalcPhonemeTimespans(MarkCollection mc, int index, int subelements) { TimeSpan duration; TimeSpan relStart; TimeSpan lastOffset; if (mc != null) { //Sort the Marklist by time. mc.Marks.Sort(); lastOffset = mc.Marks.Last(); } else { lastOffset = new TimeSpan(0, 0, 0, 0); } if ((mc != null) && (index < mc.MarkCount - 1)) { duration = new TimeSpan((mc.Marks[index + 1] - mc.Marks[index]).Ticks / subelements); } else { //Default Phoneme timing to 250ms duration = new TimeSpan(0, 0, 0, 0, 250); } if (index == 0) { unMarkedPhonemes = 0; } if ((mc != null) && (index < mc.MarkCount)) { relStart = mc.Marks[index] - mc.Marks[0]; unMarkedPhonemes = 0; } else { relStart = new TimeSpan(lastOffset.Ticks + (duration.Ticks * unMarkedPhonemes)); unMarkedPhonemes += subelements; } return new Tuple<TimeSpan, TimeSpan>(relStart, duration); }
public void PopulateMarkCollectionsList(MarkCollection selectedCollection) { listViewMarkCollections.Items.Clear(); foreach (MarkCollection mc in Sequence.MarkCollections) { ListViewItem item = new ListViewItem(); item.Text = mc.Name; item.SubItems.Add(mc.Level.ToString()); item.SubItems.Add(mc.MarkCount.ToString()); item.BackColor = (mc.Enabled) ? mc.MarkColor : SystemColors.Window; item.ForeColor = (mc.Enabled) ? ((GetGrayValueForColor(mc.MarkColor) > 128) ? Color.Black : Color.White) : SystemColors.InactiveCaptionText; item.Tag = mc; item.Checked = mc.Enabled; listViewMarkCollections.Items.Add(item); item.Selected = (mc == selectedCollection); } }
public void PopulateMarkCollectionsList(MarkCollection selectedCollection) { listViewMarkCollections.Items.Clear(); foreach (MarkCollection mc in Sequence.MarkCollections) { ListViewItem item = new ListViewItem(); item.Text = mc.Name; item.ForeColor = mc.MarkColor;// : Color.FromArgb(221,221,221); //item.ForeColor = (mc.Enabled) // ? ((GetGrayValueForColor(mc.MarkColor) > 128) ? Color.Black : Color.White) // : SystemColors.InactiveCaptionText; item.Tag = mc; item.Checked = mc.Enabled; listViewMarkCollections.Items.Add(item); item.Selected = (mc == selectedCollection); } ResizeColumnHeaders(); }
public MarkCollectionArgs(MarkCollection mc) { MarkCollection = mc; }
private void toolStripButtonAddMarkCollection_Click(object sender, EventArgs e) { MarkCollection mc = new MarkCollection(); mc.Name = "New Mark Collection"; mc.MarkColor = Color.White; Sequence.MarkCollections.Add(mc); OnChangedMarkCollection(new MarkCollectionArgs(mc)); PopulateMarkCollectionsList(mc); }
private void PopulateFormWithMarkCollection(MarkCollection collection, bool forceUpdate = false) { if (_displayedCollection == collection && !forceUpdate) return; _displayedCollection = collection; if (collection == null) { textBoxCollectionName.Text = ""; numericUpDownWeight.Value = 1; checkBoxEnabled.Checked = false; checkBoxBold.Checked = false; checkBoxSolidLine.Checked = false; } else { textBoxCollectionName.Text = collection.Name; numericUpDownWeight.Value = collection.Level; checkBoxEnabled.Checked = collection.Enabled; checkBoxBold.Checked = collection.Bold; checkBoxSolidLine.Checked = collection.SolidLine; } PopulateMarkListFromMarkCollection(collection); checkBoxEnabled.AutoCheck = (collection != null); checkBoxBold.AutoCheck = (collection != null); checkBoxSolidLine.AutoCheck = (collection != null); textBoxCollectionName.Enabled = (collection != null); numericUpDownWeight.Enabled = (collection != null); panelColor.Enabled = (collection != null); groupBoxOperations.Enabled = (collection != null); buttonSelectAllMarks.Enabled = (collection != null); buttonAddOrUpdateMark.Enabled = (collection != null); textBoxTime.Enabled = (collection != null); }
private void UpdateMarkCollectionInList(MarkCollection collection) { foreach (ListViewItem item in listViewMarkCollections.Items) { if (item.Tag as MarkCollection == collection) { item.SubItems[0].Text = collection.Name; item.SubItems[1].Text = collection.Level.ToString(); item.SubItems[2].Text = collection.Marks.Count.ToString(); item.ForeColor = collection.MarkColor; } } }
private void createTimedSequence() { Sequence = new TimedSequence() { SequenceData = new TimedSequenceData() }; // TODO: use this mark collection (maybe generate a grid?) //I am not sure what to do with this, but it looks like John had a plan. MarkCollection mc = new MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongPath + Path.DirectorySeparatorChar + parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { var message = string.Format("Could not locate the audio file '{0}'; please add it manually " + "after import (Under Tools -> Associate Audio).", Path.GetFileName(songFileName)); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Error; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm(message, "Couldn't find audio", false, false); messageBox.ShowDialog(); } } }
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; }
private void PopulateFormWithMarkCollection(MarkCollection collection, bool forceUpdate = false) { if (_displayedCollection == collection && !forceUpdate) return; _displayedCollection = collection; if (collection == null) { textBoxCollectionName.Text = ""; numericUpDownWeight.Value = 1; panelColor.BackColor = SystemColors.Control; checkBoxEnabled.Checked = false; } else { textBoxCollectionName.Text = collection.Name; numericUpDownWeight.Value = collection.Level; panelColor.BackColor = collection.MarkColor; checkBoxEnabled.Checked = collection.Enabled; } PopulateMarkListFromMarkCollection(collection); groupBoxSelectedMarkCollection.Enabled = (collection != null); }
private void PopulateMarkListFromMarkCollection(MarkCollection collection) { listViewMarks.BeginUpdate(); listViewMarks.Items.Clear(); string timeFormat = @"m\:ss\.fff"; if (collection != null) { collection.Marks.Sort(); foreach (TimeSpan time in collection.Marks) { ListViewItem item = new ListViewItem(time.ToString(timeFormat)); item.Tag = time; listViewMarks.Items.Add(item); } } textBoxTime.Text = ""; buttonAddOrUpdateMark.Text = "Add"; listViewMarks.EndUpdate(); }
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 void createTimedSequence() { Sequence = new TimedSequence(); Sequence.SequenceData = new TimedSequenceData(); VixenModules.Sequence.Timed.MarkCollection mc = new VixenModules.Sequence.Timed.MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { var message = String.Format("Could not locate the audio file '{0}' please add it manually in the sequence editor " + "after the import completes. Use the Tools menu, then select Associate Audio...", Path.GetFileName(songFileName)); MessageBox.Show(message, "Sorry, couldn't find audio"); } } }
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; }
private void UpdateMarkListBox(MarkCollection marks) { marks.Marks.Sort(); PopulateMarkListFromMarkCollection(marks); UpdateMarkCollectionInList(marks); }
private MarkCollection GetOrAddNewMarkCollection(Color color, string name = "New Collection") { MarkCollection mc = _sequence.MarkCollections.FirstOrDefault(mCollection => mCollection.Name == name); if (mc == null) { MarkCollection newCollection = new MarkCollection {Name = name, MarkColor = color}; _sequence.MarkCollections.Add(newCollection); mc = newCollection; SequenceModified(); } return mc; }
private void GenerateCollection(int index) { ConcurrentBag<TimeSpan> values = new ConcurrentBag<TimeSpan>(); if (detectedActions.TryGetValue(index, out values)) { MarkCollection collection = new MarkCollection(); collection.MarkColor = Color.Blue; collection.Name = string.Format("Note {0} Freq. {1}", _audio.DetectionNotes[index], _audio.DetectionNoteFreq[index]); TimeSpan lastValue = TimeSpan.FromMilliseconds(0); values.OrderBy(a => a).ToList().ForEach(v => { var xtime = v - TimeSpan.FromMilliseconds(settings.MusicAccuracy); if (xtime > lastValue) { collection.Marks.Add(v); lastValue = v; } }); lock (MarkCollections) { MarkCollections.RemoveAll(r => r.Name == collection.Name); MarkCollections.Add(collection); } } }
private MarkCollection AddNewCollection(Color color, string name = "New Collection") { MarkCollection newCollection = new MarkCollection(); newCollection.Name = name; newCollection.MarkColor = color; MarkCollections.Add(newCollection); // populate the form with the new collection first, *then* update the collection list, // so that the displayed collection is remembered and selected in the list. PopulateFormWithMarkCollection(newCollection); PopulateMarkCollectionsList(); //enable Tapper as long as a collection is selected. radioButtonTapper.Enabled = (listViewMarkCollections.SelectedItems.Count > 0); radioButtonPlayback.Checked = true; return newCollection; }
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; }
private void UpdateMarkCollectionInList(MarkCollection collection) { foreach (ListViewItem item in listViewMarkCollections.Items) { if (item.Tag as MarkCollection == collection) { item.SubItems[0].Text = collection.Name; item.SubItems[1].Text = collection.Level.ToString(); item.SubItems[2].Text = collection.Marks.Count.ToString(); item.BackColor = (collection.Enabled) ? collection.MarkColor : SystemColors.Window; item.ForeColor = (collection.Enabled) ? ((GetGrayValueForColor(collection.MarkColor) > 128) ? Color.Black : Color.White) : SystemColors.InactiveCaptionText; } } }
private void createTimedSequence() { Sequence = new TimedSequence() { SequenceData = new TimedSequenceData() }; // TODO: use this mark collection (maybe generate a grid?) //I am not sure what to do with this, but it looks like John had a plan. MarkCollection mc = new MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongPath + Path.DirectorySeparatorChar + parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { var message = string.Format("Could not locate the audio file '{0}'; please add it manually " + "after import (Under Tools -> Associate Audio).", Path.GetFileName(songFileName)); MessageBox.Show(message, "Couldn't find audio"); } } }
//Beat Mark Collection Export routine 2-7-2014 JMB //In the audacity section, if the MarkCollections.Count = 1 then we assume the collection is bars and iMarkCollection++ //Other wise its beats, at least from the information I have studied, and we do not iMarkCollection++ to keep the collections together properly. private void ExportMarkCollections(MarkCollection collection, string exportType) { if (exportType == "vixen3") { saveFileDialog.DefaultExt = ".v3m"; saveFileDialog.Filter = "Vixen 3 Mark Collection (*.v3m)|*.v3m|All Files (*.*)|*.*"; saveFileDialog.InitialDirectory = lastFolder; if (saveFileDialog.ShowDialog() == DialogResult.OK) { var xmlsettings = new XmlWriterSettings() { Indent = true, IndentChars = "\t", }; DataContractSerializer ser = new DataContractSerializer(typeof(List<MarkCollection>)); var writer = XmlWriter.Create(saveFileDialog.FileName, xmlsettings); ser.WriteObject(writer, MarkCollections); writer.Close(); } } if (exportType == "audacity") { int iMarkCollection = 0; List<string> BeatMarks = new List<string>(); foreach (MarkCollection mc in MarkCollections) { iMarkCollection++; foreach (TimeSpan time in mc.Marks) { BeatMarks.Add(time.TotalSeconds.ToString("0000.000") + "\t" + time.TotalSeconds.ToString("0000.000") + "\t" + iMarkCollection); if (MarkCollections.Count == 1) iMarkCollection++; } } saveFileDialog.DefaultExt = ".txt"; saveFileDialog.Filter = "Audacity Marks (*.txt)|*.txt|All Files (*.*)|*.*"; if (saveFileDialog.ShowDialog() == DialogResult.OK) { string name = saveFileDialog.FileName; using (System.IO.StreamWriter file = new System.IO.StreamWriter(name)) { foreach (string bm in BeatMarks.OrderBy(x => x)) { file.WriteLine(bm); } } } } }
private MarkCollection AddNewCollection(Color color, string name = "New Collection") { MarkCollection newCollection = new MarkCollection(); newCollection.Name = name; newCollection.MarkColor = color; MarkCollections.Add(newCollection); // populate the form with the new collection first, *then* update the collection list, // so that the displayed collection is remembered and selected in the list. PopulateFormWithMarkCollection(newCollection); PopulateMarkCollectionsList(); panelColor.BackColor = color; return newCollection; }
private MarkCollection GetOrAddNewMarkCollection(Color color, string name = "New Collection") { MarkCollection mc = null; foreach (MarkCollection mCollection in _sequence.MarkCollections) { if (mCollection.Name == name) { mc = mCollection; break; } } if (mc == null) { MarkCollection newCollection = new MarkCollection(); newCollection.Name = name; newCollection.MarkColor = color; _sequence.MarkCollections.Add(newCollection); mc = newCollection; sequenceModified(); } return mc; }
private void createTimedSequence() { Sequence = new TimedSequence(); Sequence.SequenceData = new TimedSequenceData(); VixenModules.Sequence.Timed.MarkCollection mc = new VixenModules.Sequence.Timed.MarkCollection(); Sequence.Length = TimeSpan.FromMilliseconds(parsedV2Sequence.SeqLengthInMills); var songFileName = parsedV2Sequence.SongFileName; if (songFileName != null) { if (File.Exists(songFileName)) { Sequence.AddMedia(MediaService.Instance.GetMedia(songFileName)); } else { dialogOpen.CheckFileExists = true; dialogOpen.CheckPathExists = true; dialogOpen.Title = "Audio Not Found! Please Locate " + Path.GetFileName(songFileName); dialogOpen.Multiselect = false; dialogOpen.FileName = Path.GetFileName(songFileName); if (dialogOpen.ShowDialog() == DialogResult.OK) { Sequence.AddMedia(MediaService.Instance.GetMedia(dialogOpen.FileName)); } } } }