Exemplo n.º 1
0
        /// <summary>
        /// Create a chord options object and set it's default values.
        /// </summary>
        /// <returns>The chord options object.</returns>
        private ChordOptions BuildChordOptions()
        {
            ChordOptions chordOptions = new ChordOptions();

            chordOptions.BarreType      = BarreType.Arc;
            chordOptions.OpenStringType = OpenStringType.Circle;
            chordOptions.Width          = 150;
            chordOptions.Height         = 226;
            return(chordOptions);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Build the list of SVG images to display.
        /// </summary>
        /// <param name="chordResultSet">The chord result set.</param>
        /// <param name="chordOptions">The chord options.</param>
        /// <returns>The list of SVG images.</returns>
        private List <string> BuildSVGList(ChordResultSet chordResultSet, ChordOptions chordOptions)
        {
            // Define the collections.
            List <string> svgList  = new List <string>();
            List <Chord>  myChords = new List <Chord>();

            for (int i = 0; i < chordResultSet.Count; i++)
            {
                myChords.Add(chordResultSet.ChordAt(i));
            }

            foreach (Chord chord in myChords)
            {
                svgList.Add(chord.ToSvg(chordOptions));
            }

            return(svgList);
        }
Exemplo n.º 3
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));
            }
        }