Esempio n. 1
0
        private string GetText(InternalNote?[] notes, int str, MarkTextOption markTextOption)
        {
            if (str < 0 || str >= notes.Length)
            {
                throw new ArgumentOutOfRangeException(nameof(str));
            }

            string text = "";

            if (notes[str].HasValue)
            {
                switch (markTextOption)
                {
                case MarkTextOption.ShowNote_PreferFlats:
                    text = NoteUtils.ToString(notes[str].Value, InternalNoteStringStyle.PreferFlat);
                    break;

                case MarkTextOption.ShowNote_PreferSharps:
                    text = NoteUtils.ToString(notes[str].Value, InternalNoteStringStyle.PreferSharp);
                    break;

                case MarkTextOption.ShowNote_ShowBoth:
                    text = NoteUtils.ToString(notes[str].Value, InternalNoteStringStyle.ShowBoth);
                    break;
                }
            }

            return(text);
        }
Esempio n. 2
0
        public static string ToString(InternalNote note, InternalNoteStringStyle style)
        {
            if (NoteUtils.IsNatural(note) || style != InternalNoteStringStyle.ShowBoth)
            {
                return(NoteUtils.ToString(NoteUtils.ToNote(note, style)));
            }
            else
            {
                switch (note)
                {
                case InternalNote.Cs_Db:
                    return("C#/Db");

                case InternalNote.Ds_Eb:
                    return("D#/Eb");

                case InternalNote.Fs_Gb:
                    return("F#/Gb");

                case InternalNote.Gs_Ab:
                    return("G#/Ab");

                case InternalNote.As_Bb:
                    return("A#/Bb");
                }
            }

            throw new ArgumentException();
        }
Esempio n. 3
0
        public void Set(string key, Note value)
        {
            if (StringUtils.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentNullException(nameof(key));
            }

            Set(key, NoteUtils.ToString(value));
        }
Esempio n. 4
0
        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;
        }
Esempio n. 5
0
        public void SetTarget(Note rootNote, IScale scale)
        {
            if (null == scale)
            {
                throw new ArgumentNullException(nameof(scale));
            }

            Settings[Prefix + "rootnote"] = NoteUtils.ToString(rootNote);
            Settings[Prefix + "scale"]    = scale.LongName;
            ScaleLevel = scale.Level;

            _cachedScale = scale;
        }
Esempio n. 6
0
        public string ToXml()
        {
            string rootNotes = "";

            for (int i = 0; i < RootNotes.Length; i++)
            {
                rootNotes += NoteUtils.ToString(RootNotes[i]) + ";";
            }

            rootNotes = rootNotes.TrimEnd(';');

            return(String.Format("<tuning name=\"{0}\" notes=\"{1}\" />", Name, rootNotes));
        }
Esempio n. 7
0
        public Chord ChordAt(int index)
        {
            int[] absoluteMarks = ResultAt(index);
            int   baseLine;

            int[] marks = MarkUtils.AbsoluteToRelativeMarks(absoluteMarks, out baseLine, ChordFinderOptions.NumFrets);

            string title    = NoteUtils.ToString(Root) + ChordQuality.Abbreviation;
            string fileName = title + index;

            int numStrings = marks.Length;

            int numFrets = ChordFinderOptions.NumFrets;
            int barre    = ChordFinderOptions.AutoAddBarres ? -1 : 0;

            return(new Chord(fileName, title, numStrings, numFrets, baseLine, barre, marks));
        }
Esempio n. 8
0
        public string GetText(MarkPosition mark, MarkTextOption markTextOption)
        {
            string text = "";

            switch (markTextOption)
            {
            case MarkTextOption.ShowNote_PreferFlats:
                text = NoteUtils.ToString(NoteAt(mark), InternalNoteStringStyle.PreferFlat);
                break;

            case MarkTextOption.ShowNote_PreferSharps:
                text = NoteUtils.ToString(NoteAt(mark), InternalNoteStringStyle.PreferSharp);
                break;

            case MarkTextOption.ShowNote_ShowBoth:
                text = NoteUtils.ToString(NoteAt(mark), InternalNoteStringStyle.ShowBoth);
                break;
            }
            return(text);
        }
Esempio n. 9
0
 public override string ToString()
 {
     return(string.Format("{0}{1}", NoteUtils.ToString(Note), Octave));
 }
Esempio n. 10
0
        public Diagram ToDiagram(ChordFinderStyle chordFinderStyle)
        {
            int[] marks = MarkUtils.AbsoluteToRelativeMarks(Marks, out int baseLine, Parent.ChordFinderOptions.NumFrets);

            InternalNote?[] notes    = MarkUtils.GetInternalNotes(Marks, Parent.ChordFinderOptions.Tuning);
            InternalNote    rootNote = NoteUtils.ToInternalNote(Parent.ChordFinderOptions.RootNote);

            if (chordFinderStyle.MirrorResults)
            {
                Array.Reverse(marks);
                Array.Reverse(notes);
            }

            int numStrings = marks.Length;

            int numFrets = Parent.ChordFinderOptions.NumFrets;

            Diagram d = new Diagram(chordFinderStyle.Style, numStrings, numFrets);

            if (chordFinderStyle.AddTitle)
            {
                d.Title = NoteUtils.ToString(Parent.ChordFinderOptions.RootNote) + Parent.ChordFinderOptions.ChordQuality.Abbreviation;
                d.Style.TitleLabelStyle = DiagramLabelStyle.ChordName;
            }

            // Add marks
            for (int i = 0; i < marks.Length; i++)
            {
                int @string = i + 1;

                int          fret = Math.Max(marks[i], 0);
                MarkPosition mp   = new MarkPosition(@string, fret);

                DiagramMark dm = d.NewMark(mp);

                // Set mark type
                if (marks[i] == -1) // Muted string
                {
                    dm.Type = DiagramMarkType.Muted;
                }
                else if (marks[i] == 0) // Open string
                {
                    dm.Type = DiagramMarkType.Open;
                }

                // Change to root if necessary
                if (chordFinderStyle.AddRootNotes && notes[i].HasValue && notes[i].Value == rootNote)
                {
                    dm.Type = (dm.Type == DiagramMarkType.Open) ? DiagramMarkType.OpenRoot : DiagramMarkType.Root;
                }

                // Add text
                if (chordFinderStyle.MarkTextOption != MarkTextOption.None)
                {
                    dm.Text = GetText(notes, i, chordFinderStyle.MarkTextOption);
                }

                // Add bottom marks
                if (chordFinderStyle.AddBottomMarks)
                {
                    MarkPosition bottomPosition = new MarkPosition(@string, numFrets + 1);
                    DiagramMark  bottomMark     = d.NewMark(bottomPosition);
                    bottomMark.Type = DiagramMarkType.Bottom;
                    bottomMark.Text = GetText(notes, i, chordFinderStyle.BottomMarkTextOption);
                }
            }

            // Add nut or fret label
            if (baseLine == 0)
            {
                d.Style.GridNutVisible = true;
            }
            else
            {
                d.Style.GridNutVisible = false;
                FretLabelPosition flp = new FretLabelPosition(chordFinderStyle.FretLabelSide, 1);
                d.NewFretLabel(flp, baseLine.ToString());
            }

            // Add barre
            BarrePosition bp = MarkUtils.AutoBarrePosition(marks, chordFinderStyle.BarreTypeOption, chordFinderStyle.MirrorResults);

            if (null != bp)
            {
                d.NewBarre(bp);
            }

            return(d);
        }
Esempio n. 11
0
        public Diagram ToDiagram(ScaleFinderStyle scaleFinderStyle)
        {
            int numStrings = Parent.ScaleFinderOptions.Instrument.NumStrings;
            int numFrets   = Parent.ScaleFinderOptions.NumFrets;

            int baseLine;
            IEnumerable <MarkPosition> marks = MarkUtils.AbsoluteToRelativeMarks(Marks, out baseLine, numFrets, numStrings);

            Diagram d = new Diagram(scaleFinderStyle.Style, numStrings, numFrets);

            if (scaleFinderStyle.AddTitle)
            {
                d.Title = NoteUtils.ToString(Parent.ScaleFinderOptions.RootNote) + " " + Parent.ScaleFinderOptions.Scale.Name;
                d.Style.TitleLabelStyle = DiagramLabelStyle.Regular;
            }

            int markPositionIndex = 0;

            // Add existing marks
            foreach (MarkPosition mark in marks)
            {
                int @string = mark.String;

                if (scaleFinderStyle.MirrorResults)
                {
                    @string = numStrings - (@string - 1);
                }

                int          fret = mark.Fret;
                MarkPosition mp   = new MarkPosition(@string, fret);

                DiagramMark dm = d.NewMark(mp);

                // Set mark type
                if (scaleFinderStyle.AddRootNotes && IsRoot(markPositionIndex))  // Use markPositionIndex, to get the correct roots in mirror mode
                {
                    dm.Type = DiagramMarkType.Root;
                }

                if (fret == 0) // Open string
                {
                    dm.Type = (dm.Type == DiagramMarkType.Root) ? DiagramMarkType.OpenRoot : DiagramMarkType.Open;
                }

                // Add text
                dm.Text = GetText(markPositionIndex, scaleFinderStyle.MarkTextOption);  // Use markPositionIndex, not mp, to get the correct text in mirror mode

                markPositionIndex++;
            }

            // Add nut or fret label
            if (baseLine == 0)
            {
                d.Style.GridNutVisible = true;
            }
            else
            {
                d.Style.GridNutVisible = false;
                FretLabelPosition flp = new FretLabelPosition(FretLabelSide.Right, 1);
                d.NewFretLabel(flp, baseLine.ToString());
            }

            return(d);
        }