public List <Triad> GetTriadsOfInstrument(TriadType type, string nameOfInstrument, int indexOfInstrument) { //Get triads of an instrument returned //Param "type" - enum that declares what kind of triads shall be returned //Param "nameOfInstrument" - name of wanted instrument //Param "indexOfInstrument" - in case that multiple instrument share a name an index can be passed to specify the selection Instrument instrument; try { instrument = Composition.GetInstrumentByName(nameOfInstrument, indexOfInstrument); if (instrument != null) { return(instrument.GetTriads(type)); } else { throw new NullReferenceException("Instrument doesn't exist"); } } catch (ArgumentException e) { Console.WriteLine(e.ToString()); } return(null); }
public Triad(TriadOperand leftOperand, TriadOperand rightOperand, Token operation, TriadType type) { LeftOperand = leftOperand; RightOperand = rightOperand; Operation = operation; Type = type; }
public Triads(Matrix matrix, TriadType type, double binaryCutoff = 0.0) { _type = type; R = binaryCutoff; colCount = matrix.Rows; numNodes = matrix.Rows; _count = numNodes; triadList = new int[colCount][][]; //triadListValue = new int[colCount][]; triadListCount = new int[colCount]; transitiveTriads = new Matrix(numNodes); triangleList = new List<int>[numNodes]; // dyads to the node: 1 to 1 relationship // temp tempCount = new double[numNodes]; degrees = new int[numNodes]; for (int i = 0; i < numNodes; i++) { triadList[i] = new int[MAX_TRIAD_LIST_SIZE][]; //triadListValue[i] = new int[MAX_TRIAD_LIST_SIZE]; triadListCount[i] = 0; // create the triads list for each node triangleList[i] = new List<int>(); for (int j = 0; j < numNodes; j++) { if (matrix[i, j] > R) { transitiveTriads[i, j] = 1; triangleList[i].Add(j); // calculate the degree of each node degrees[i]++; } } } calcClosedTriangles(); calcRelevantTriangles(); newCalc(matrix); for (int i = 0; i < colCount; i++) { int triadCount = 0; // counter of how many nodes have been accumulated in the triad so far int[] list = new int[MAX_TRIAD_SIZE]; // a dynamic array used to contain the nodes in a triad bool[] markedList = new bool[colCount]; // an array to check which nodes have been used for (int j = 0; j < colCount; j++) markedList[j] = false; list[triadCount++] = i; // add the first node to the triad markedList[i] = true; computeTriads(matrix, ref triadCount, list, i, ref markedList, ref triadList[i], ref triadListCount[i]); } computeDiads(matrix); //computeLocalTransitivity(); if (_type == TriadType.Balance) computeLocalBalance(matrix); }
public List <Triad> GetTriadsOfInstrument(TriadType type, int indexOfInstrument) { //Get triads of an instrument returned //Param "type" - enum that declares what kind of triads shall be returned //Param "indexOfInstrument" - index of wanted instrument if (Composition.Instruments[indexOfInstrument] != null) { return(Composition.Instruments[indexOfInstrument].GetTriads(type)); } else { throw new NullReferenceException("Instrument doesn't exist"); } }
/// <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; } }
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; } }
public List <Triad> GetTriads(TriadType type) { if (Triads.Count <= 0) { Console.WriteLine("No triads found. You may first use the method 'InitializeTriads' and then repeat this method-call."); Console.WriteLine("If still nothing is shown, the analyzed music doesn't contain any triads"); } if (type == TriadType.AllTriads) { return(Triads); } if (type == TriadType.AllRealTriads) { return(Triads.Where(t => t.triadType != TriadType.NoTriad).ToList()); } return(Triads.Where(t => t.triadType == type).ToList()); }
private int _count; // number of different triad nodes public Triads(Matrix matrix, TriadType type, double binaryCutoff = 0.0) { _type = type; R = binaryCutoff; colCount = matrix.Rows; numNodes = matrix.Rows; _count = numNodes; triadList = new int[colCount][][]; //triadListValue = new int[colCount][]; triadListCount = new int[colCount]; transitiveTriads = new Matrix(numNodes); triangleList = new List <int> [numNodes]; // dyads to the node: 1 to 1 relationship // temp tempCount = new double[numNodes]; degrees = new int[numNodes]; for (int i = 0; i < numNodes; i++) { triadList[i] = new int[MAX_TRIAD_LIST_SIZE][]; //triadListValue[i] = new int[MAX_TRIAD_LIST_SIZE]; triadListCount[i] = 0; // create the triads list for each node triangleList[i] = new List <int>(); for (int j = 0; j < numNodes; j++) { if (matrix[i, j] > R) { transitiveTriads[i, j] = 1; triangleList[i].Add(j); // calculate the degree of each node degrees[i]++; } } } calcClosedTriangles(); calcRelevantTriangles(); newCalc(matrix); for (int i = 0; i < colCount; i++) { int triadCount = 0; // counter of how many nodes have been accumulated in the triad so far int[] list = new int[MAX_TRIAD_SIZE]; // a dynamic array used to contain the nodes in a triad bool[] markedList = new bool[colCount]; // an array to check which nodes have been used for (int j = 0; j < colCount; j++) { markedList[j] = false; } list[triadCount++] = i; // add the first node to the triad markedList[i] = true; computeTriads(matrix, ref triadCount, list, i, ref markedList, ref triadList[i], ref triadListCount[i]); } computeDiads(matrix); //computeLocalTransitivity(); if (_type == TriadType.Balance) { computeLocalBalance(matrix); } }
/// <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; }