public Car(string producer, int bhp, string model, ITuning tuning)
 {
     this.Producer = producer;
     this.Bhp      = bhp;
     this.Model    = model;
     this.tuning   = tuning;
 }
Exemplo n.º 2
0
        public IInstrument GetInstrument()
        {
            string name = Settings[Prefix + "instrument"];

            string level = InstrumentTuningLevel;

            if (null != _cachedInstrument)
            {
                if (_cachedInstrument.Name == name && _cachedInstrument.Level == level)
                {
                    return(_cachedInstrument);
                }
                _cachedInstrument = null;
                _cachedTuning     = null;
            }

            InstrumentSet instruments = _configFile.Instruments;

            while (null != instruments)
            {
                if (instruments.Level == level)
                {
                    if (instruments.TryGet(name, out Instrument i))
                    {
                        _cachedInstrument = i;
                        break;
                    }
                }

                instruments = instruments.Parent;
            }

            return(_cachedInstrument);
        }
Exemplo n.º 3
0
        public void CopyFrom(ITuningSet tuningSet)
        {
            if (null == tuningSet)
            {
                throw new ArgumentNullException("tuningSet");
            }

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

            foreach (ITuning sourceTuning in tuningSet)
            {
                ITuning tuning = null;

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

                    Add(sourceTuning.Name, rootNotes);
                }
            }
        }
Exemplo n.º 4
0
        private void RefreshInstruments(IInstrument selectedInstrument = null, ITuning selectedTuning = null)
        {
            Instruments        = AppVM.GetInstruments();
            SelectedInstrument = null;

            if (null != selectedInstrument && null != Instruments)
            {
                foreach (ObservableInstrument oi in Instruments)
                {
                    if (oi.Instrument == selectedInstrument)
                    {
                        SelectedInstrument = oi;
                        break;
                    }
                }
            }

            if (null != SelectedInstrument)
            {
                Tunings        = SelectedInstrument.GetTunings();
                SelectedTuning = null;

                if (null != selectedTuning && null != Tunings)
                {
                    foreach (ObservableTuning ot in Tunings)
                    {
                        if (ot.Tuning == selectedTuning)
                        {
                            SelectedTuning = ot;
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
 public Fretboard(ITuning tuning, int fretCount)
 {
     FretCount         = fretCount;
     Tuning            = tuning;
     InstrumentStrings = new List <InstrumentString>(tuning.ReturnStringCount());
     PopulateFretboard();
 }
Exemplo n.º 6
0
            public static TestChordFinderOptions Parse(string s)
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    throw new ArgumentNullException(nameof(s));
                }

                s = s.Trim();

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

                IInstrument instrument = null;

                switch (vals[0])
                {
                case TestInstrument.UkuleleInstrumentName:
                    instrument = TestInstrument.Ukulele;
                    break;
                }

                ITuning tuning = null;

                switch (vals[1])
                {
                case TestInstrument.UkuleleStandardTuningName:
                    tuning = TestInstrument.Ukulele.Tunings.Get(TestInstrument.UkuleleStandardTuningName);
                    break;
                }

                IChordQuality chordQuality = null;

                switch (vals[2])
                {
                case TestChordQuality.MajorChordQualityName:
                    chordQuality = TestChordQuality.MajorChord;
                    break;

                case TestChordQuality.Dominant7thChordQualityName:
                    chordQuality = TestChordQuality.DominantSeventhChord;
                    break;

                case TestChordQuality.Dominant9thChordQualityName:
                    chordQuality = TestChordQuality.DominantNinthChord;
                    break;
                }

                Note rootNote = (Note)Enum.Parse(typeof(Note), vals[3]);

                int  numFrets            = int.Parse(vals[4]);
                int  maxFret             = int.Parse(vals[5]);
                int  maxReach            = int.Parse(vals[6]);
                bool allowOpenStrings    = bool.Parse(vals[7]);
                bool allowMutedStrings   = bool.Parse(vals[8]);
                bool allowRootlessChords = bool.Parse(vals[9]);

                return(new TestChordFinderOptions {
                    Instrument = instrument, Tuning = tuning, ChordQuality = chordQuality, RootNote = rootNote, NumFrets = numFrets, MaxFret = maxFret, MaxReach = maxReach, AllowOpenStrings = allowOpenStrings, AllowMutedStrings = allowMutedStrings, AllowRootlessChords = allowRootlessChords
                });
            }
Exemplo n.º 7
0
        protected FinderOptions(ConfigFile configFile, string prefix)
        {
            if (StringUtils.IsNullOrWhiteSpace(prefix))
            {
                throw new ArgumentNullException(nameof(prefix));
            }

            _configFile = configFile ?? throw new ArgumentNullException(nameof(configFile));
            Prefix      = prefix;

            _cachedInstrument = null;
            _cachedTuning     = null;
        }
Exemplo n.º 8
0
        public bool Remove(ITuning tuning)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException(nameof(tuning));
            }

            if (ReadOnly)
            {
                throw new ObjectIsReadOnlyException(this);
            }

            return(_tunings.Remove(tuning));
        }
Exemplo n.º 9
0
            public static TestScaleFinderOptions Parse(string s)
            {
                if (string.IsNullOrWhiteSpace(s))
                {
                    throw new ArgumentNullException(nameof(s));
                }

                s = s.Trim();

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

                IInstrument instrument = null;

                switch (vals[0])
                {
                case TestInstrument.UkuleleInstrumentName:
                    instrument = TestInstrument.Ukulele;
                    break;
                }

                ITuning tuning = null;

                switch (vals[1])
                {
                case TestInstrument.UkuleleStandardTuningName:
                    tuning = TestInstrument.Ukulele.Tunings.Get(TestInstrument.UkuleleStandardTuningName);
                    break;
                }

                IScale scale = null;

                switch (vals[2])
                {
                case TestScale.MajorScaleName:
                    scale = TestScale.MajorScale;
                    break;
                }

                Note rootNote = (Note)Enum.Parse(typeof(Note), vals[3]);

                int  numFrets          = int.Parse(vals[4]);
                int  maxFret           = int.Parse(vals[5]);
                int  maxReach          = int.Parse(vals[6]);
                bool allowOpenStrings  = bool.Parse(vals[7]);
                bool allowMutedStrings = bool.Parse(vals[8]);

                return(new TestScaleFinderOptions {
                    Instrument = instrument, Tuning = tuning, Scale = scale, RootNote = rootNote, NumFrets = numFrets, MaxFret = maxFret, MaxReach = maxReach, AllowOpenStrings = allowOpenStrings, AllowMutedStrings = allowMutedStrings
                });
            }
Exemplo n.º 10
0
        private void Add(ITuning tuning)
        {
            if (null == tuning)
            {
                throw new ArgumentNullException(nameof(tuning));
            }

            if (tuning.Parent != this)
            {
                throw new ArgumentOutOfRangeException(nameof(tuning));
            }

            if (!ListUtils.SortedInsert <ITuning>(_tunings, tuning))
            {
                throw new TuningAlreadyExistsException(this, tuning.LongName);
            }
        }
Exemplo n.º 11
0
        public bool TryGet(string longName, out ITuning tuning)
        {
            if (StringUtils.IsNullOrWhiteSpace(longName))
            {
                throw new ArgumentNullException(nameof(longName));
            }

            foreach (Tuning t in _tunings)
            {
                if (t.LongName == longName)
                {
                    tuning = t;
                    return(true);
                }
            }

            tuning = null;
            return(false);
        }
Exemplo n.º 12
0
        public ITuning GetTuning()
        {
            string longName = Settings[Prefix + "tuning"];

            if (null != _cachedInstrument && null != _cachedTuning)
            {
                string level = InstrumentTuningLevel;
                if (_cachedInstrument.Level == level && _cachedTuning.LongName == longName && _cachedTuning.Level == level)
                {
                    return(_cachedTuning);
                }
                _cachedTuning = null;
            }

            if (null != Instrument && Instrument.Tunings.TryGet(longName, out ITuning t))
            {
                _cachedTuning = t;
            }

            return(_cachedTuning);
        }
Exemplo n.º 13
0
        public static InternalNote?[] GetInternalNotes(int[] marks, ITuning tuning)
        {
            if (null == marks || marks.Length == 0)
            {
                throw new ArgumentNullException("marks");
            }

            if (null == tuning)
            {
                throw new ArgumentNullException("tuning");
            }

            InternalNote?[] notes = new InternalNote?[marks.Length];

            for (int i = 0; i < marks.Length; i++)
            {
                notes[i] = marks[i] == -1 ? null : (InternalNote?)NoteUtils.Shift(tuning.RootNotes[i].InternalNote, marks[i]);
            }

            return(notes);
        }
Exemplo n.º 14
0
        public void SetTarget(IInstrument instrument, ITuning tuning)
        {
            if (null == instrument)
            {
                throw new ArgumentNullException(nameof(instrument));
            }

            if (null == tuning)
            {
                throw new ArgumentNullException(nameof(tuning));
            }

            if (tuning.Parent != instrument.Tunings)
            {
                throw new InstrumentTuningMismatchException(instrument, tuning);
            }

            Settings[Prefix + "instrument"] = instrument.Name;
            Settings[Prefix + "tuning"]     = tuning.LongName;
            InstrumentTuningLevel           = instrument.Level;

            _cachedInstrument = instrument;
            _cachedTuning     = tuning;
        }
Exemplo n.º 15
0
 public bool TryGet(string longName, out ITuning tuning)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 16
0
        public GuitarController(IScaleListService dictionary, IModeDefinitionService scaleDirectoryService, InstrumentViewModel instrumentViewModel) : base(instrumentViewModel)
        {
            _tuning = new StandardGuitarTuning();

            _instrumentViewModel.UpdateViewModel(_instrumentName, _tuning, _fretCount);
        }
Exemplo n.º 17
0
        public BassController(InstrumentViewModel instrumentViewModel) : base(instrumentViewModel)
        {
            _tuning = new StandardBassTuning();

            _instrumentViewModel.UpdateViewModel(_instrumentName, _tuning, _fretCount);
        }
 public Car(ITuning tuning)
 {
     this.tuning = tuning;
 }
Exemplo n.º 19
0
 public bool Remove(ITuning tuning)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 20
0
 public void UpdateViewModel(string instrumentName, ITuning tuning, int fretCount)
 {
     //TODO: Stop creating a new fretboard everytime
     Fretboard      = new Fretboard(tuning, fretCount);
     InstrumentName = instrumentName;
 }
Exemplo n.º 21
0
 public InstrumentTuningMismatchException(IInstrument instrument, ITuning tuning) : base()
 {
     Instrument = instrument;
     Tuning     = tuning;
 }