Ejemplo n.º 1
0
        internal Tuning(TuningSet parent, XmlReader xmlReader) : this(parent)
        {
            if (null == xmlReader)
            {
                throw new ArgumentNullException(nameof(xmlReader));
            }

            using (xmlReader)
            {
                if (xmlReader.IsStartElement() && xmlReader.Name == "tuning")
                {
                    Name = xmlReader.GetAttribute("name");

                    string notes = xmlReader.GetAttribute("notes");

                    string[] s = notes.Split(';');

                    FullNote[] rootNotes = new FullNote[s.Length];

                    if (rootNotes.Length != Parent.Instrument.NumStrings)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    for (int i = 0; i < rootNotes.Length; i++)
                    {
                        rootNotes[i] = FullNote.Parse(s[i]);
                    }
                    RootNotes = rootNotes;
                }
            }

            UpdateParent = true;
        }
Ejemplo n.º 2
0
        public int CompareTo(object obj)
        {
            if (null == obj)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            FullNote fullNote = obj as FullNote;

            if (null == fullNote)
            {
                throw new ArgumentException();
            }

            if (Octave == fullNote.Octave)
            {
                return(InternalNote.CompareTo(fullNote.InternalNote));
            }

            return(Octave.CompareTo(fullNote.Octave));
        }
Ejemplo n.º 3
0
        public void CopyFrom(ITuningSet tuningSet)
        {
            if (null == tuningSet)
            {
                throw new ArgumentNullException(nameof(tuningSet));
            }

            if (Instrument.NumStrings != tuningSet.Instrument.NumStrings)
            {
                throw new ArgumentOutOfRangeException(nameof(tuningSet));
            }

            foreach (ITuning sourceTuning in tuningSet)
            {
                if (!TryGet(sourceTuning.LongName, out ITuning tuning))
                {
                    FullNote[] rootNotes = new FullNote[sourceTuning.RootNotes.Length];
                    sourceTuning.RootNotes.CopyTo(rootNotes, 0);

                    Add(sourceTuning.Name, rootNotes);
                }
            }
        }