public Triad(JustNote baseNote, int[] theFormula, TriadMode mode = TriadMode.I, TriadInversion inv = TriadInversion.I)
        {
            TriadType = TriadTypes.TriadsTypes.First(f => f.Value[0] == theFormula[0] && f.Value[1] == theFormula[1] && f.Value[2] == theFormula[2]).Key.ToString();

            ChordNotes[0] = baseNote;

            var tempNote = baseNote;

            for (int i = 1; i < 3; i++)
            {
                tempNote      = JustNote.moveNoteBySemitones(tempNote, theFormula[i - 1]);
                ChordNotes[i] = tempNote;
            }

            Mode = mode;

            switch (Mode)
            {
            case TriadMode.I:
                break;

            case TriadMode.II:
                ChordNotes[1] = JustNote.moveNoteBySemitones(ChordNotes[1], 12);
                break;

            default:
                break;
            }

            this.InverseForward(inv);
            Inversion = inv;
        }
        public Triad(JustNote baseNote, JustNote thirdNote, JustNote fifthNote, TriadMode mode, TriadInversion inv)
        {
            ChordNotes[0] = baseNote;
            ChordNotes[1] = thirdNote;
            ChordNotes[2] = fifthNote;

            Mode      = mode;
            Inversion = inv;
        }
Beispiel #3
0
 public Triad(Note note1, Note note2, Note note3, Fraction onset)
 {
     FirstNote       = note1;
     SecondNote      = note2;
     ThirdNote       = note3;
     Onset           = onset;
     triadType       = TriadType.NoTriad;
     triadInversion  = TriadInversion.NoInversion;
     FundamentalTone = FundamentalTone.Default;
 }
        /// <summary>
        /// Creates a new TriadFlashcardGenerator.
        /// </summary>
        /// <param name="triadTypes">This flags value indicates which types of triads to include.</param>
        /// <param name="triadInversions">This flags value indicates which triad inversions to include.</param>
        /// <param name="staffs">This flags value indicates which staffs to include.</param>
        public TriadFlashcardGenerator(TradFlashcardGeneratorArgs args)
            : base(args)
        {
            if(args.TriadInversions == 0)
                throw new ArgumentException("Need at least one triad inversion to construct a triad flashcard generator.");
            if (args.TriadTypes == 0)
                throw new ArgumentException("Need at least one triad type to construct a triad flashcard generator.");

            TriadInversions = args.TriadInversions;
            TriadTypes = args.TriadTypes;

            if (Accidentals == AccidentalType.Natural)
            {
                // there just aren't enough diminished and augmented triads representable without accidentals, so skip them.
                TriadTypes &= ~TriadType.Augmented;
                TriadTypes &= ~TriadType.Diminished;
            }
        }
        // TODO : Keep specific chord steps on their place
        public void InverseForward(TriadInversion inv)
        {
            var mode = TriadTypes.TriadModeFormula[Mode];

            var b = mode[(0 + (int)inv) % 3];
            var c = mode[(1 + (int)inv) % 3];
            var a = mode[(2 + (int)inv) % 3];

            while (ChordNotes[b].getNoteNumber() > ChordNotes[c].getNoteNumber())
            {
                ChordNotes[c] = JustNote.moveNoteBySemitones(ChordNotes[c], 12);
            }
            while (ChordNotes[c].getNoteNumber() > ChordNotes[a].getNoteNumber())
            {
                ChordNotes[a] = JustNote.moveNoteBySemitones(ChordNotes[a], 12);
            }

            Inversion = inv;
        }
Beispiel #6
0
 private void CheckIfExpectedEqualsValueAndSetType(
     long lowerIntervalExpected,
     long lowerIntervalValue,
     long upperIntervalExpected,
     long upperIntervalValue,
     TriadType triadTypeToSet,
     TriadInversion triadInversionToSet,
     FundamentalTone fundamentalToneToSet,
     Triad triad)
 {
     //if lower interval equals the ecpected lower interval AND if upper interval equals the exepected upper interval
     if (lowerIntervalExpected == lowerIntervalValue && upperIntervalExpected == upperIntervalValue)
     {
         //set triad type, fundamental tone and inversion
         triad.triadType       = triadTypeToSet;
         triad.FundamentalTone = fundamentalToneToSet;
         triad.triadInversion  = triadInversionToSet;
     }
 }
Beispiel #7
0
        public Triad(Note note1, Note note2, Note note3)
        {
            FirstNote  = note1;
            SecondNote = note2;
            ThirdNote  = note3;

            if ((note1.Onset == note2.Onset) && (note2.Onset == note3.Onset))
            {
                Onset = note1.Onset;
            }
            else
            {
                throw new Exception("Triad onsets differ. Pass onset as parameter.");
            }

            triadType       = TriadType.NoTriad;
            triadInversion  = TriadInversion.NoInversion;
            FundamentalTone = FundamentalTone.Default;
        }
 /// <summary>
 /// Makes an array of NoteRepresentations to form a triad.
 /// </summary>
 private NoteRepresentation[] MakeTriad(NoteRepresentation rep, TriadType type, TriadInversion inv = TriadInversion.Root)
 {
     switch (type)
     {
         case TriadType.Major:
             switch (inv)
             {
                 case TriadInversion.Root:
                     return rep.MakeGroup(Interval.MajorThird, Interval.PerfectFifth);
                 case TriadInversion.First:
                     return rep.MakeGroup(Interval.MinorThird, Interval.MinorSixth);
                 case TriadInversion.Second:
                     return rep.MakeGroup(Interval.PerfectFourth, Interval.MajorSixth);
             }
             break;
         case TriadType.Minor:
             switch (inv)
             {
                 case TriadInversion.Root:
                     return rep.MakeGroup(Interval.MinorThird, Interval.PerfectFifth);
                 case TriadInversion.First:
                     return rep.MakeGroup(Interval.MajorThird, Interval.MajorSixth);
                 case TriadInversion.Second:
                     return rep.MakeGroup(Interval.PerfectFourth, Interval.MinorSixth);
             }
             break;
         case TriadType.Diminished: // since diminished and augmented triads are symmetrical, they don't invert.
             return rep.MakeGroup(Interval.MinorThird, Interval.DiminishedFifth);
         case TriadType.Augmented:
             return rep.MakeGroup(Interval.MajorThird, Interval.AugmentedFifth);
     }
     return null;
 }