public IChordQuality GetChordQuality() { string longName = Settings[Prefix + "chordquality"]; string level = ChordQualityLevel; if (null != _cachedChordQuality) { if (_cachedChordQuality.LongName == longName && _cachedChordQuality.Level == level) { return(_cachedChordQuality); } _cachedChordQuality = null; } ChordQualitySet qualities = _configFile.ChordQualities; while (null != qualities) { if (qualities.Level == level) { if (qualities.TryGet(longName, out ChordQuality cq)) { _cachedChordQuality = cq; break; } } qualities = qualities.Parent; } return(_cachedChordQuality); }
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 }); }
public void SetTarget(Note rootNote, IChordQuality chordQuality) { if (null == chordQuality) { throw new ArgumentNullException(nameof(chordQuality)); } Settings[Prefix + "rootnote"] = NoteUtils.ToString(rootNote); Settings[Prefix + "chordquality"] = chordQuality.LongName; ChordQualityLevel = chordQuality.Level; _cachedChordQuality = chordQuality; }
public ChordFinderOptions(ConfigFile configFile, ChordiousSettings chordiousSettings = null) : base(configFile, "chord") { if (null != chordiousSettings) { Settings = chordiousSettings; } else { string settingsLevel = "ChordFinderOptions"; Settings = new ChordiousSettings(_configFile.ChordiousSettings, settingsLevel); } _cachedChordQuality = null; }
private void RefreshChordQualities(IChordQuality selectedChordQuality = null) { ChordQualities = AppVM.GetChordQualities(); SelectedChordQuality = null; if (null != selectedChordQuality && null != ChordQualities) { foreach (ObservableChordQuality ocq in ChordQualities) { if (ocq.ChordQuality == selectedChordQuality) { SelectedChordQuality = ocq; break; } } } }
public static async Task <ChordFinderResultSet> FindChordsAsync(IChordFinderOptions chordFinderOptions, CancellationToken cancelToken) { if (null == chordFinderOptions) { throw new ArgumentNullException("chordFinderOptions"); } InternalNote root = NoteUtils.ToInternalNote(chordFinderOptions.RootNote); IChordQuality chordQuality = chordFinderOptions.ChordQuality; InternalNote[] notesInChord = NamedInterval.GetNotes(root, chordQuality.Intervals); ChordFinderResultSet results = new ChordFinderResultSet(chordFinderOptions); if (cancelToken.IsCancellationRequested) { return(results); } await FindAllChordsAsync(results, null, notesInChord, 0, chordFinderOptions, cancelToken); return(results); }