Ejemplo n.º 1
0
 public void FindChords_NullTest()
 {
     TestUtils.ExpectInnerException <ArgumentNullException>(() =>
     {
         ChordFinder.FindChords(null);
     });
 }
Ejemplo n.º 2
0
        public Form1()
        {
            this.chordFinder = new ChordFinder();

            InitializeComponent();
            StartMonitoringMidi();
        }
Ejemplo n.º 3
0
        public void CanFindABlackNoteChord(string chordName, Note expectedRootNote, string expectedShape)
        {
            var finder = new ChordFinder();

            var chord = finder.GetChord(chordName);

            Assert.That(chord.RootNote, Is.EqualTo(expectedRootNote));
            Assert.That(chord.ChordShape.Names, Contains.Item(expectedShape));
        }
Ejemplo n.º 4
0
        public void CompareNotes_SameOctaves()
        {
            Note highNote = new Note("C#3", 0);
            Note lowNote  = new Note("C3", 0);

            ChordFinder finder = new ChordFinder();

            finder.Notes.TryAdd(highNote.GetNoteIdentifier(), highNote);
            finder.Notes.TryAdd(lowNote.GetNoteIdentifier(), lowNote);

            Assert.AreSame(highNote, finder.GetHighestNote());
            Assert.AreSame(lowNote, finder.GetLowestNote());
        }
Ejemplo n.º 5
0
        public ChordModel Get(string chord = "", bool includeSsml = false)
        {
            if (string.IsNullOrEmpty(chord))
            {
                throw new Exception(Messages.GenericNotRecognisedMessage);
            }

            try
            {
                var foundChord = new ChordFinder().GetChord(chord);
                var notes      = includeSsml ? foundChord.ToNotesSsml() : string.Join(", ", foundChord.Notes.Select(n => n.ToSpoken()));
                return(new ChordModel(foundChord.Name, notes));
            }
            catch (ChordNotFoundException exception)
            {
                throw new Exception(string.Format(Messages.SpecificNotRecognisedFormatMessage, exception.ChordName));
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Call from JQuery to find the chords.
        /// </summary>
        /// <param name="instrument">The instrument.</param>
        /// <param name="tuning">The tuning.</param>
        /// <param name="notes">The root note for the chord.</param>
        /// <param name="chordQualities">The chord qualities.</param>
        /// <param name="numFrets">The number of frets to display.</param>
        /// <param name="maxFrets">The maximum number of frets to use.</param>
        /// <param name="maxReach">The maximum fret reach for the fingers.</param>
        /// <param name="autoAddBarres">Auto add barres?</param>
        /// <param name="allowOpenStrings">Allow open strings?</param>
        /// <param name="allowMutedStrings">Allow muted strings?</param>
        /// <param name="mirrorResults">Mirror the results for left-handed chords?</param>
        /// <param name="allowRootlessChords">Allow rootless chords?</param>
        /// <returns>List of SVG images to display in the UI.</returns>
        public JsonResult FindChords(string instrument, string tuning, string notes, string chordQualities, string numFrets, string maxFrets, string maxReach, string autoAddBarres, string allowOpenStrings, string allowMutedStrings, string mirrorResults, string allowRootlessChords)
        {
            // Initialize the ConfigFile object.
            InitConfig();

            // Define the objects.
            Instrument         Instrument     = null;
            ChordQuality       ChordQuality   = null;
            ChordFinderOptions myOptions      = null;
            ChordFinder        chordFinder    = null;
            ChordResultSet     chordResultSet = null;
            ChordOptions       chordOptions   = null;
            Tuning             Tuning         = null;
            Note myNote = NoteUtils.ParseNote(notes);

            Instrument   = GetAnInstrument(instrument);
            ChordQuality = GetChordQuality(chordQualities);

            if (Instrument != null)
            {
                // Instantiate the selected tuning object from the instrument.
                Tuning = GetTheTuning(Instrument, tuning);

                // Instantiate the chord finder options.
                myOptions = BuildChordFinderOptions(instrument, tuning, numFrets, maxFrets, maxReach, autoAddBarres, allowOpenStrings, allowMutedStrings, mirrorResults, allowRootlessChords);

                // Instantiate the chord finder object.
                chordFinder = new ChordFinder(Instrument, Tuning);

                // Instantiate the chord result set.
                chordResultSet = chordFinder.FindChords(myNote, ChordQuality, myOptions);

                // Instantiate the chord options.
                chordOptions = BuildChordOptions();

                // Build the list of SVG images to return to the screen.
                return(Json(BuildSVGList(chordResultSet, chordOptions), JsonRequestBehavior.AllowGet));
            }
            else
            {
                // The instrument doesn't exist.
                return(Json(String.Empty, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 7
0
        private Task <ChordFinderResultSet> FindChordsAsync(CancellationToken cancelToken)
        {
            return(Task <ChordFinderResultSet> .Factory.StartNew(() =>
            {
                ChordFinderResultSet results = null;

                try
                {
                    Task <ChordFinderResultSet> task = ChordFinder.FindChordsAsync(Options, cancelToken);
                    task.Wait();

                    results = task.Result;
                }
                catch (Exception ex)
                {
                    ExceptionUtils.HandleException(ex);
                }

                return results;
            }));
        }
Ejemplo n.º 8
0
        public void HandlesWhenTheShapeCannotBeParsed(string chordName)
        {
            var finder = new ChordFinder();

            Assert.Throws <ChordNotFoundException>(() => finder.GetChord(chordName));
        }
Ejemplo n.º 9
0
 public void Execute()
 {
     ActualResult = ChordFinder.FindChords(chordFinderOptions).Results;
     TestUtils.AreEqual <IChordFinderResult>(ExpectedResult, ActualResult, allowExtras);
 }