Ejemplo n.º 1
0
        public ChordManager()
        {
            //http://johncomino.tripod.com/const.htm

            ChordDefinitions = new List <ChordDefinition>();
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Major, "Major", "Maj", "", new int[] {
                (int)IntervalType.i01_1_Prime,
                (int)IntervalType.i05_3_MajorThird_DiminishedFourth,
                (int)IntervalType.i08_5_PerfectFifth
            }));

            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Minor, "Minor", "Min", "m", new int[] {
                (int)IntervalType.i01_1_Prime, (int)IntervalType.i04_b3_MinorThird, (int)IntervalType.i08_5_PerfectFifth
            }));

            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Augmented, "Augmented", "Aug", "aug", new int[] {
                (int)IntervalType.i01_1_Prime,
                (int)IntervalType.i05_3_MajorThird_DiminishedFourth,
                (int)IntervalType.i09_b6_AugmentedFifth_MinorSixth
            }));

            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Diminished, "Diminished", "Dim", "dim", new int[] { 1, 4, 7 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Diminished, "Diminished Seventh", "Dim7", "dim7", new int[] { 1, 4, 7, 10 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Diminished, "Half Diminished Seventh", "HalfDim7", "1/2dim7", new int[] { 1, 4, 7, 11 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Minor, "Minor Seventh", "Min7", "m7", new int[] { 1, 4, 8, 11 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Minor, "Minor Major Seventh", "mM7", "m(M7)", new int[] { 1, 4, 8, 12 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Augmented, "Augmented Seventh", "Aug7", "aug7", new int[] { 1, 5, 9, 11 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Augmented, "Augmented Ninth", "Aug9", "aug9", new int[] {
                (int)IntervalType.i01_1_Prime,
                (int)IntervalType.i05_3_MajorThird_DiminishedFourth,
                (int)IntervalType.i09_b6_AugmentedFifth_MinorSixth,
                (int)IntervalType.i11_b7_AugmentedSixth_MinorSeventh,
                (int)IntervalType.i02_b2_MinorSecond
            }));

            //TODO: special cases: C7 in open position drops 5th interval (8) in 1,5,8,11
            var dom7 = new ChordDefinition(ChordGroup.Dominant7th, "Dominant Seventh", "Dom7", "7", new int[] { 1, 5, 8, 11 });

            //var dom7Variation = new ChordDefinitionVariation { VariationNote = Note.C, RemovedIntervals = new int[] { (int)IntervalType.i08_5_PerfectFifth }.ToList() };
            //hack because sharpkit not allowing int .ToList on safari
            var dom7Variation = new ChordDefinitionVariation {
                VariationNote = Note.C
            };
            var removedIntervals = new int[] { (int)IntervalType.i08_5_PerfectFifth };

            dom7Variation.RemovedIntervals = new List <int>();
            for (int i = 0; i < removedIntervals.Length; i++)
            {
                dom7Variation.RemovedIntervals.Add(removedIntervals[i]);
            }

            dom7.PerNoteVariations = new List <ChordDefinitionVariation>();
            dom7.PerNoteVariations.Add(dom7Variation);
            ChordDefinitions.Add(dom7);
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Major, "Major Seventh", "Maj7", "Maj7", new int[] { 1, 5, 8, 12 }));
            ChordDefinitions.Add(new ChordDefinition(ChordGroup.Augmented, "Augmented Major Seventh", "AugMaj7", "aug M7", new int[] { 1, 5, 9, 12 }));
        }
Ejemplo n.º 2
0
        public List <Note> GetChordNotes(Note rootNote, string chordType, int startingFretPos)
        {
            List <Note> notes = new List <Note>();

            try
            {
                ChordDefinition chord        = ChordDefinitions.First(c => c.Name == chordType || c.ShortName == chordType);
                List <int>      intervalList = chord.IntervalList.ToList();

                //check for chord variation specific to this root note
                if (chord.PerNoteVariations != null && chord.PerNoteVariations.Any(v => v.VariationNote == rootNote && v.StartingFretPos == startingFretPos))
                {
                    var variation = chord.PerNoteVariations.First(v => v.VariationNote == rootNote);
                    if (variation.RemovedIntervals != null)
                    {
                        foreach (int removedInterval in variation.RemovedIntervals)
                        {
                            intervalList.Remove(removedInterval);
                        }
                    }

                    if (variation.AddedIntervals != null)
                    {
                        foreach (int addedInterval in variation.AddedIntervals)
                        {
                            intervalList.Add(addedInterval);
                        }
                    }
                }

                for (int i = 0; i < intervalList.Count; i++)
                {
                    int intervalPos = intervalList[i] - 1;

                    int noteIndex = intervalPos + (int)rootNote;
                    if (noteIndex >= 12)
                    {
                        noteIndex = noteIndex - 12;
                    }
                    Note n = (Note)noteIndex;

                    notes.Add(n);
                }
            }
            catch (Exception)
            {
                System.Diagnostics.Debug.WriteLine("Chord Name Not Found");
            }

            return(notes);
        }