Music and Mathematics. Finding the natural scale generator. The best way? [closed]
Want to improve this question? Update the question so it can be answered with facts and citations b开发者_如何学JAVAy editing this post.
Closed 3 years ago.
Improve this questionI wrote this post Music and Mathematics, finding the Natural and the Pentatonic scales.
I want to find the best programmatic aproach. A solution could be:
<script>
function getScaleIntervals(c) {
var tot = 0;
var scale = [];
while(tot <= 12){
scale.push(Math.round(tot));
tot += c;
}
return scale;
}
var natural_scale = getScaleIntervals(12/7);
document.write(natural_scale + " \n"); // ==> 0, 2, 3, 5, 7, 9, 10, 12
var pentatonic_scale = getScaleIntervals(12/5);
document.write(pentatonic_scale + " \n"); // ==> 0, 2, 5, 7, 10, 12
</script>
The resultant intervals starts with D (Re) in 0 so you have D E F G A B C D This is the Dorian Mode
Your question (as written) is ambiguous. If you mean "can your algorithm be used to generate natural scales?" (those containing all natural notes, i.e. notes that are neither sharp nor flat), then yes, but only one (unless you allow for different rounding methods, in which case you get one natural scale per rounding method) and only by cherry picking a tonic. If you mean "does your algorithm, by itself, result in a natural scale?", then the answer is no because it does not, by itself, generate a scale; it generates a mode.
Note: in this answer, all named modes (e.g. Ionian) refer to the modern definitions.
In terms of semitones, your algorithm results in intervals (from the tonic) of 0,2,3,5,7,9,10,12, which corresponds to a semitone sequence (i.e. scale steps) of 2-1-2-2-2-1-2, or Dorian mode. Note that the algorithm doesn't determine the tonic (the first note in a scale), so it doesn't give you a specific scale, which is a sequence of pitches, such as C-major or Dorian mode in D.
In terms of the named intervals from the tonic, the Dorian mode contains the major 2nd, minor 3rd, perfect 4th, perfect 5th, major 6th, minor 7th, and perfect 8th. C major is M2, M3, P4, P5, M6, M7, P8 (all major or perfect intervals).
Generating Other Modes
Your choice of rounding function is arbitrary. If you always round up (⌈i*12/7⌉
), you get the intervals 0,2,4,6,7,9,11,12 and semitone sequence 2-2-2-1-2-2-1, which is Lydian mode. Rounding down (⌊i*12/7⌋
) gets you intervals 0,1,3,5,6,8,10,12 and steps 1-2-2-1-2-2-2, which is Locrian mode. None of these are the intervals or semitone sequence for the natural scale in C (i.e. Ionian mode in C, or C major), which is 0,2,4,5,7,9,11,12 and 2-2-1-2-2-2-1, respectively.
If you expand the algorithm to use a different rounding function for each term rather than the same rounding function for all, you can generate the other named modes (e.g. (_, ceil, ceil, floor, ceil, ceil, ceil, _)
, where _
means "don't care", will generate Ionian), but you will also generate many other modes that can't result in a natural scale. You can generate a total of 2n-1 modes this way, where n
is the number of tones (I'm covering n=7
, or heptatonic modes). The number of heptatonic modes equals the number of compositions of 12 of length 7, which is 11C6=462, so this method won't generate all modes. If we define roundr(x) = floor(x+r)
, we can generate only the diatonic modes (the 7 named modes, or Heptatonia Prima, which maximally separate the semitone steps) using this rounding function by limiting r
to i/7
, where i ∈ [0, 7) ⊂ ℕ. For example, Ionian is roundTo5/7(i*12/7)
for i ∈ [0, 7) (note: round-to-nearest is roundTo0.5(x)
). With this last approach, we can generate modes that can generate all 7 natural scales.
Diatonic(n) = <roundTon/7(x*12/7) for x in ∈ [0, 7)>
where <...>
indicates a tuple (i.e. a finite sequence).
Generating Scales
Your algorithm only generates modes, but those can be used to generate scales. Depending on which note you pick to start on (the tonic), you'll get different scales for a given mode. Dorian results in a minor scale because it includes the minor third (the first two semitone steps in Dorian are 2-1, which sum to 3, the minor third) and perfect fifth (the sequence starts with 2-1-2-2, giving 7 semitones above the tonic). Lydian gives you a major scale because it includes the major third (it's semitone sequence starts with 2-2, which sums to 4, the major third) and perfect fifth (2-1-2-2). Locrian doesn't include the perfect fifth, so it's neither major nor minor.
Generating Natural Scales
To see which natural scales your algorithm can generate, let ADLO(n, round, tonic)
stand for the scale resulting from the generalized version of your algorithm, where n
is the number of pitches per octave, round
is the rounding function and tonic
is the tonic for a scale. If any is unspecified, the result is a collection of all possible values (thus ADLO(7, nearest)
is all scales in Dorian mode). A named mode and tonic will be used for the scale in that mode with that tonic (e.g. Ionian('C')
is C-major); a named mode with no tonic (e.g. Ionian()
) will stand for the set of all scales in that mode. {}
denotes a set, and <>
a sequence.
ADLO(7, nearest) = Dorian() = Diatonic(3) { <C, D, D#, F, G, A, A#, C>, <D, E, F, G, A, B, C, D>, <E, F#, G, A, B, C#, D, E>, <F, G, G#, A#, C, D, D#, F>, <G, A, A#, C, D, E, F, G>, <A, B, C, D, E, F#, G, A>, <B, C#, D, E, F#, G#, A, B> } ADLO(7, ceil) = Lydian() = Diatonic(6) { <C, D, E, F#, G, A, B, C>, <D, E, F#, G#, A, B, C#, D>, <E, F#, G#, A#, B, C#, D#, E>, <F, G, A, B, C, D, E, F>, <G, A, B, C#, D, E, F#, G>, <A, B, C#, D#, E, F#, G#, A>, <B, C#, D#, F, F#, G#, A#, B> } ADLO(7, floor) = Locrian() = Diatonic(0) { <C, C#, D#, F, F#, G#, A#, C>, <D, D#, F, G, G#, A#, C, D>, <E, F, G, A, A#, C, D, E>, <F, F#, G#, A#, B, C#, D#, F>, <G, G#, A#, C, C#, D#, F, G>, <A, A#, C, D, D#, F, G, A>, <B, C, D, E, F, G, A, B> }
Thus we see that
if you and pick * round to nearest D * round down B * round up F * ... as the tonic, you get a natural scale.
Also,
ADLO(7, roundTo5/7(x)) = Ionian() = Diatonic(5) ADLO(7, roundTo3/7(x)) = Dorian() = Diatonic(3) ADLO(7, roundTo1/7(x)) = Phrygian() = Diatonic(1) ADLO(7, roundTo6/7(x)) = Lydian() = Diatonic(6) ADLO(7, roundTo4/7(x)) = Mixolydian() = Diatonic(4) ADLO(7, roundTo2/7(x)) = Aeolian() = Diatonic(2) ADLO(7, roundTo0/7(x)) = Locrian() = Diatonic(0)
Which note to pick as the tonic is also given as the "white note" in the Wikipedia article on modes in modern music.
Computational Correctness
The reason the code works to generate a mode is that the notes in a diatonic scale are as evenly distributed among the semitones as is possible. i*n/m
, for i ∈ [0, m), is an even distribution of m things among n things. Round those values and you get a distribution that's as even as possible among integers from 0 through n. Thus your algorithm results a diatonic mode. This isn't all that significant a result; it's a rather simple consequence of rounding.
I don't know if the theory in the blog page is correct, but if for some crazy reason I put 18 notes into the 12 semitones then the upper limit of tot
will be 13; also the pentatonic scale won't include the last 12.
Programmatically to translate the stuff on the blog page should use
while (tot <= 12) {
The rest are fine, except I don't know why the if(scale.length == 8) {
is needed.
For the validity of the music theory, ask somewhere else.
From reading your article, it seems to me that you are seriously confusing minor with flat and major with sharp, respectively.
So, from “2 rounded to ceil, minor note” you conclude that the second note in the scale must be the flat version of the second white key on the piano starting with D. That is, E♭. You basically start with a Dorian mode (i.e. all the white keys starting at D) and then augment or diminish the keys depending on the result of your rounding.
However, you should note that the Dorian scale is already a scale; therefore the most natural scale you’d get from starting with a Dorian would be the very same Dorian scale. And you’d achieve this without any flats or sharps (or minor and major notes as you name it).
Starting this whole theory on the Dorian scale is already such a strong assumption that it would need some hard work to put this in a reasonable way. And this hard work would eventually lead to a real theory of scales. And not the number casting you do afterwards.
As you write, you “used to believe that the half-tones between some notes where a kind of adjustment” – it really looks to me that this is still the case, otherwise you wouldn’t be ignoring them by starting with a non-equally tempered scale. If you want to get any further, this scale should be your starting point:
c – c♯ – d – d♯ – e – f – f♯ – g – g♯ – a – a♯ – h
(And to avoid further confusion, you should drop their names and refer to them by 1, 2, 3, … 12.)
Or in frequency fractions:
1 – 2^(1/12) – 2^(2/12) – 2^(3/12) – … – 2^(11/12) – 2^(12/12) = 2
1 – 1.059 – 1.122 – 1.189 – … – 1.888 – 2
You can do your number games on the equal tempered scale and see what comes out then. Some theory regarding the finding of major chords is done by looking at the overtone series in musical instruments. You’ll find some notes in this series which naturally lead to some sort of major chords and basic scale, if you accept some compromises. One of the compromises being that what you’ll find is actually not exactly equal tempered…
精彩评论