public static TuningEditorViewModel EditExistingTuning(ObservableTuning tuning) { if (null == tuning) { throw new ArgumentNullException("tuning"); } TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(false, tuning.ReadOnly, (name, notes) => { FullNote[] rootNotes = new FullNote[notes.Count]; for (int i = 0; i < notes.Count; i++) { rootNotes[i] = notes[i].FullNote; } tuning.Tuning.Update(name, rootNotes); }); tuningEditorVM.Name = tuning.Name; foreach (ObservableNote note in tuning.Notes) { tuningEditorVM.RootNotes.Add(new ObservableNote(note.FullNote.Clone())); } return(tuningEditorVM); }
private static TuningEditorViewModel CopyExistingTuning(Tuning tuning, Instrument targetInstrument) { if (null == tuning) { throw new ArgumentNullException("tuning"); } if (null == targetInstrument) { throw new ArgumentNullException("targetInstrument"); } TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(true, false, (name, notes) => { FullNote[] rootNotes = new FullNote[notes.Count]; for (int i = 0; i < notes.Count; i++) { rootNotes[i] = notes[i].FullNote; } targetInstrument.Tunings.Add(name, rootNotes); }); tuningEditorVM.Name = tuning.Name; foreach (FullNote note in tuning.RootNotes) { tuningEditorVM.RootNotes.Add(new ObservableNote(note.Clone())); } return(tuningEditorVM); }
public static TuningEditorViewModel AddNewTuning(ObservableInstrument instrument) { if (null == instrument) { throw new ArgumentNullException("instrument"); } TuningEditorViewModel tuningEditorVM = new TuningEditorViewModel(true, false, (name, notes) => { FullNote[] rootNotes = new FullNote[notes.Count]; for (int i = 0; i < notes.Count; i++) { rootNotes[i] = notes[i].FullNote; } instrument.Instrument.Tunings.Add(name, rootNotes); }); for (int i = 0; i < instrument.NumStrings; i++) { tuningEditorVM.RootNotes.Add(new ObservableNote()); } return(tuningEditorVM); }
internal ObservableNote(FullNote note) { if (null == note) { throw new ArgumentNullException("note"); } FullNote = note; }
private static double FromFullNote(FullNote first) { return first.Octave * 11 + (double)first.Note; }
public ObservableNote() { FullNote = new FullNote(); }
internal ObservableNote(FullNote note) { FullNote = note ?? throw new ArgumentNullException(nameof(note)); }
private string PureNoteString(FullNote c) { const string flat = "es"; const string sharp = "is"; var note = c.Note.ToString().ToLower(); if (note.Length == 1) { return note; } var firstClean = note.Replace("sharp", sharp).Replace("flat", flat); return firstClean.ToLower(); }
private string OctavePrefix(FullNote c) { if (this.HasOctavePrefix) { if (c.Octave == 4) { return string.Empty; } else if (c.Octave < 4) { return new string(Enumerable.Repeat(',', 4 - c.Octave).ToArray()); } return new string(Enumerable.Repeat('\'', c.Octave - 4).ToArray()); } return string.Empty; }
public static FullNote OctaveTransform(FullNote note) { return(new FullNote(note.Note, note.Octave + 1)); }
public static FullNote OctaveTransform(FullNote note) { return new FullNote(note.Note, note.Octave + 1); }