Interval Distributions
interval_direction_distribution_1
¶
interval_direction_distribution_1(
score: Score,
name: str = "Interval Direction Distribution",
weighted: bool = True,
miditoolbox_compatible: bool = True,
) -> Distribution
Returns the proportion of upward intervals for each interval size
Currently, intervals greater than an octave will be ignored.
Parameters:
-
score(Score) –The music Score object to analyze
-
name(str, default:'Interval Direction Distribution') –A name for the resulting distribution (title in distribution plot)
-
weighted(bool, default:True) –If True, the interval distribution is weighted by note durations in seconds that are modified according to Parncutt's durational accent model (1994), by default True.
-
miditoolbox_compatible(bool, default:True) –Invokes interval_distribution_1 using miditoolbox_compatible=True, which performs normalization slightly differently (see interval_distribution_1. Default is False, which simply skips division when the total count is zero (this also returns a zero matrix when the count is zero).
Returns:
-
Distribution–A 12-element distribution representing the proportion of upward intervals for each interval size. The components are spaced at semitone distances with the first component representing a minor second (not unison) and the last component the octave. If the score is empty, the function returns a list with all elements set to zero.
Source code in amads/pitch/ivdirdist1.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
interval_distribution_1
¶
interval_distribution_1(
score: Score,
name: str = "Interval Distribution",
weighted: bool = True,
miditoolbox_compatible: bool = True,
) -> Distribution
Returns the interval distribution of a musical score.
Currently, intervals greater than an octave will be ignored.
Parameters:
-
score(Score) –The musical score to analyze
-
name(str, default:'Interval Distribution') –A name for the distribution and plot title.
-
weighted(bool, default:True) –If True, the interval distribution is weighted by note durations in seconds that are modified according to Parncutt's durational accent model (1994), by default True.
-
miditoolbox_compatible(bool, default:True) –Matlab MIDI Toolbox avoids zero division by dividing counts by the total count plus (1e-12 times the number of bins). True enables this behavior. Default is False, which simply skips division when the total count is zero (this also returns a zero matrix when the count is zero).
Returns:
-
Distribution–A 25-bin distribution representing the probabilities of each pitch interval. The bins are spaced at semitone distances with the first bin representing the downward octave and the last bin representing the upward octave. If the score is empty, the function returns a list with all elements set to zero.
Raises:
-
ValueError–If the score is not monophonic (e.g. contains chords)
Source code in amads/pitch/ivdist1.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 | |
interval_distribution_2
¶
interval_distribution_2(
score: Score,
name: str = "Interval Transition Distribution",
weighted: bool = True,
miditoolbox_compatible: bool = True,
) -> Distribution
Returns the 2nd-order interval distribution of a musical score.
Currently, intervals greater than an octave will be ignored.
Parameters:
-
score(Score) –The musical score to analyze
-
name(str, default:'Interval Transition Distribution') –A name for the distribution and plot title.
-
weighted(bool, default:True) –If True, the interval distribution is weighted by note durations in seconds that are modified according to Parncutt's durational accent model (1994), by default True.
-
miditoolbox_compatible(bool, default:True) –miditoolbox_compatible introduces four changes to emulate
ivdist2in Midi Toolbox: (1) avoid zero division by dividing counts by (total count plus (1e-12 time the number of bins), as opposed to simply skipping division when all bins are zero, (2) assume octave (but not direction) equivalence, so the intervals +1 and +13 update the same bin (as opposed to ignoring intervals larger than an octave), (3) a zero interval (unison) is inserted at the beginning of the sequence, (4) the weight is the sum of the modified durations of the second interval (as opposed to taking the sum of the modified durations of all three notes).
Returns:
-
Distribution–A 25x25 distribution where where (i,j) represents the normalized probabilities of transitioning from interval i to interval j. The bins are spaced at semitone distances with the first bin representing the downward octave and the last bin representing the upward octave. If the score is empty, the function returns a list with all elements set to zero.
Raises:
-
ValueError–If the score is not monophonic (e.g. contains chords)
Source code in amads/pitch/ivdist2.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
interval_size_distribution_1
¶
interval_size_distribution_1(
score: Score,
name: str = "Interval Size Distribution",
weighted: bool = True,
miditoolbox_compatible: bool = True,
) -> Distribution
Returns the interval size distribution of a musical score.
Intervals greater than one octave are ignored.
Parameters:
-
score(Score) –The musical score to analyze
-
name(str, default:'Interval Size Distribution') –A name for the distribution and plot title.
-
weighted(bool, default:True) –If True, the interval distribution is weighted by note durations in seconds that are modified according to Parncutt's durational accent model (1994), by default True.
-
miditoolbox_compatible(bool, default:True) –Invokes interval_distribution_1 using miditoolbox_compatible=True, which performs normalization slightly differently (see interval_distribution_1. Default is False, which simply skips division when the total count is zero (this also returns a zero matrix when the count is zero).
Returns:
-
Distribution–A 13-element distribution representing proportions of interval sizes. The first element corresponds to unison intervals, and the last element corresponds to octave intervals. If the score is empty, the function returns a Distribution with all elements set to zero.
Source code in amads/pitch/ivsizedist1.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | |