Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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;
 }
Ejemplo n.º 6
0
 public ObservableNote()
 {
     FullNote = new FullNote();
 }
Ejemplo n.º 7
0
 internal ObservableNote(FullNote note)
 {
     FullNote = note ?? throw new ArgumentNullException(nameof(note));
 }
Ejemplo n.º 8
0
        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();
        }
Ejemplo n.º 9
0
 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));
 }
Ejemplo n.º 11
0
 public static FullNote OctaveTransform(FullNote note)
 {
     return new FullNote(note.Note, note.Octave + 1);
 }