musa-dsl 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +0 -1
- data/docs/subsystems/music.md +326 -15
- data/lib/musa-dsl/generative/darwin.rb +36 -1
- data/lib/musa-dsl/generative/generative-grammar.rb +28 -0
- data/lib/musa-dsl/generative/markov.rb +2 -0
- data/lib/musa-dsl/generative/rules.rb +54 -0
- data/lib/musa-dsl/generative/variatio.rb +69 -0
- data/lib/musa-dsl/midi/midi-recorder.rb +4 -0
- data/lib/musa-dsl/midi/midi-voices.rb +10 -0
- data/lib/musa-dsl/music/chords.rb +54 -9
- data/lib/musa-dsl/music/equally-tempered-12-tone-scale-system.rb +70 -521
- data/lib/musa-dsl/music/scale_kinds/bebop/bebop_dominant_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/bebop/bebop_major_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/bebop/bebop_minor_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/blues/blues_major_scale_kind.rb +100 -0
- data/lib/musa-dsl/music/scale_kinds/blues/blues_scale_kind.rb +99 -0
- data/lib/musa-dsl/music/scale_kinds/chromatic_scale_kind.rb +79 -0
- data/lib/musa-dsl/music/scale_kinds/ethnic/double_harmonic_scale_kind.rb +102 -0
- data/lib/musa-dsl/music/scale_kinds/ethnic/hungarian_minor_scale_kind.rb +102 -0
- data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_major_scale_kind.rb +102 -0
- data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_minor_scale_kind.rb +101 -0
- data/lib/musa-dsl/music/scale_kinds/ethnic/phrygian_dominant_scale_kind.rb +103 -0
- data/lib/musa-dsl/music/scale_kinds/harmonic_major/harmonic_major_scale_kind.rb +104 -0
- data/lib/musa-dsl/music/scale_kinds/major_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/altered_scale_kind.rb +106 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/dorian_b2_scale_kind.rb +104 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/locrian_sharp2_scale_kind.rb +103 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_augmented_scale_kind.rb +103 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_dominant_scale_kind.rb +106 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/melodic_minor_scale_kind.rb +104 -0
- data/lib/musa-dsl/music/scale_kinds/melodic_minor/mixolydian_b6_scale_kind.rb +103 -0
- data/lib/musa-dsl/music/scale_kinds/minor_harmonic_scale_kind.rb +125 -0
- data/lib/musa-dsl/music/scale_kinds/minor_natural_scale_kind.rb +123 -0
- data/lib/musa-dsl/music/scale_kinds/modes/dorian_scale_kind.rb +111 -0
- data/lib/musa-dsl/music/scale_kinds/modes/locrian_scale_kind.rb +114 -0
- data/lib/musa-dsl/music/scale_kinds/modes/lydian_scale_kind.rb +111 -0
- data/lib/musa-dsl/music/scale_kinds/modes/mixolydian_scale_kind.rb +111 -0
- data/lib/musa-dsl/music/scale_kinds/modes/phrygian_scale_kind.rb +111 -0
- data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_major_scale_kind.rb +93 -0
- data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_minor_scale_kind.rb +99 -0
- data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_hw_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_wh_scale_kind.rb +110 -0
- data/lib/musa-dsl/music/scale_kinds/symmetric/whole_tone_scale_kind.rb +99 -0
- data/lib/musa-dsl/music/scale_systems/equally_tempered_12_tone_scale_system.rb +80 -0
- data/lib/musa-dsl/music/scale_systems/twelve_semitones_scale_system.rb +60 -0
- data/lib/musa-dsl/music/scales.rb +427 -0
- data/lib/musa-dsl/series/buffer-serie.rb +6 -0
- data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +23 -0
- data/lib/musa-dsl/series/quantizer-serie.rb +12 -0
- data/lib/musa-dsl/series/queue-serie.rb +13 -0
- data/lib/musa-dsl/version.rb +2 -1
- data/musa-dsl.gemspec +20 -15
- metadata +85 -22
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Neapolitan major scale kind.
|
|
6
|
+
#
|
|
7
|
+
# NeapolitanMajorScaleKind defines the Neapolitan major scale, a
|
|
8
|
+
# major scale with a lowered second degree, combining the Neapolitan
|
|
9
|
+
# coloring with a brighter major upper structure.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony:
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (uppercase for major quality):
|
|
16
|
+
#
|
|
17
|
+
# - **I** (tonic): Root (0 semitones)
|
|
18
|
+
# - **II** (supertonic): Minor second (1 semitone) ← NEAPOLITAN (b2)
|
|
19
|
+
# - **III** (mediant): Minor third (3 semitones)
|
|
20
|
+
# - **IV** (subdominant): Perfect fourth (5 semitones)
|
|
21
|
+
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
22
|
+
# - **VI** (submediant): Major sixth (9 semitones)
|
|
23
|
+
# - **VII** (leading): Major seventh (11 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Relationship to Melodic Minor
|
|
26
|
+
#
|
|
27
|
+
# Neapolitan major = Melodic minor with lowered 2nd
|
|
28
|
+
#
|
|
29
|
+
# ## Musical Character
|
|
30
|
+
#
|
|
31
|
+
# The Neapolitan major scale:
|
|
32
|
+
#
|
|
33
|
+
# - Exotic but brighter than Neapolitan minor
|
|
34
|
+
# - Combines Phrygian darkness with major brightness
|
|
35
|
+
# - Used in classical and contemporary music
|
|
36
|
+
# - Unique harmonic possibilities
|
|
37
|
+
#
|
|
38
|
+
# ## Usage
|
|
39
|
+
#
|
|
40
|
+
# c_neap_maj = Scales[:et12][440.0][:neapolitan_major][60]
|
|
41
|
+
# c_neap_maj.tonic # C (60)
|
|
42
|
+
# c_neap_maj.II # Db (61) - minor second (Neapolitan)
|
|
43
|
+
# c_neap_maj.VI # A (69) - major sixth
|
|
44
|
+
# c_neap_maj.VII # B (71) - leading tone
|
|
45
|
+
#
|
|
46
|
+
# @see ScaleKind Abstract base class
|
|
47
|
+
# @see MelodicMinorScaleKind Melodic minor (with major 2nd)
|
|
48
|
+
# @see NeapolitanMinorScaleKind Neapolitan minor
|
|
49
|
+
class NeapolitanMajorScaleKind < ScaleKind
|
|
50
|
+
@base_metadata = {
|
|
51
|
+
family: :ethnic,
|
|
52
|
+
brightness: -1,
|
|
53
|
+
character: [:neapolitan, :classical, :bright_dark],
|
|
54
|
+
parent: nil
|
|
55
|
+
}.freeze
|
|
56
|
+
|
|
57
|
+
class << self
|
|
58
|
+
@@pitches =
|
|
59
|
+
[{ functions: %i[I _1 tonic first],
|
|
60
|
+
pitch: 0 },
|
|
61
|
+
{ functions: %i[II _2 supertonic second],
|
|
62
|
+
pitch: 1 },
|
|
63
|
+
{ functions: %i[III _3 mediant third],
|
|
64
|
+
pitch: 3 },
|
|
65
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
66
|
+
pitch: 5 },
|
|
67
|
+
{ functions: %i[V _5 dominant fifth],
|
|
68
|
+
pitch: 7 },
|
|
69
|
+
{ functions: %i[VI _6 submediant sixth],
|
|
70
|
+
pitch: 9 },
|
|
71
|
+
{ functions: %i[VII _7 leading seventh],
|
|
72
|
+
pitch: 11 },
|
|
73
|
+
{ functions: %i[VIII _8 eighth],
|
|
74
|
+
pitch: 12 },
|
|
75
|
+
{ functions: %i[IX _9 ninth],
|
|
76
|
+
pitch: 12 + 1 },
|
|
77
|
+
{ functions: %i[X _10 tenth],
|
|
78
|
+
pitch: 12 + 3 },
|
|
79
|
+
{ functions: %i[XI _11 eleventh],
|
|
80
|
+
pitch: 12 + 5 },
|
|
81
|
+
{ functions: %i[XII _12 twelfth],
|
|
82
|
+
pitch: 12 + 7 },
|
|
83
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
84
|
+
pitch: 12 + 9 }].freeze
|
|
85
|
+
|
|
86
|
+
def pitches
|
|
87
|
+
@@pitches
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def grades
|
|
91
|
+
7
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def id
|
|
95
|
+
:neapolitan_major
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
EquallyTempered12ToneScaleSystem.register NeapolitanMajorScaleKind
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Neapolitan minor scale kind.
|
|
6
|
+
#
|
|
7
|
+
# NeapolitanMinorScaleKind defines the Neapolitan minor scale, a
|
|
8
|
+
# harmonic minor scale with a lowered second degree, named after
|
|
9
|
+
# the Neapolitan school of opera in the 18th century.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony:
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (lowercase for minor quality):
|
|
16
|
+
#
|
|
17
|
+
# - **i** (tonic): Root (0 semitones)
|
|
18
|
+
# - **ii** (supertonic): Minor second (1 semitone) ← NEAPOLITAN (b2)
|
|
19
|
+
# - **iii** (mediant): Minor third (3 semitones)
|
|
20
|
+
# - **iv** (subdominant): Perfect fourth (5 semitones)
|
|
21
|
+
# - **v** (dominant): Perfect fifth (7 semitones)
|
|
22
|
+
# - **vi** (submediant): Minor sixth (8 semitones)
|
|
23
|
+
# - **vii** (leading): Major seventh (11 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Relationship to Harmonic Minor
|
|
26
|
+
#
|
|
27
|
+
# Neapolitan minor = Harmonic minor with lowered 2nd
|
|
28
|
+
#
|
|
29
|
+
# ## Musical Character
|
|
30
|
+
#
|
|
31
|
+
# The Neapolitan minor scale:
|
|
32
|
+
#
|
|
33
|
+
# - Dark, dramatic, operatic
|
|
34
|
+
# - The Neapolitan sixth chord (bII) is characteristic
|
|
35
|
+
# - Used in classical and film music
|
|
36
|
+
# - Strong resolution tendency to tonic
|
|
37
|
+
#
|
|
38
|
+
# ## Usage
|
|
39
|
+
#
|
|
40
|
+
# a_neap_min = Scales[:et12][440.0][:neapolitan_minor][69]
|
|
41
|
+
# a_neap_min.tonic # A (69)
|
|
42
|
+
# a_neap_min.ii # Bb (70) - minor second (Neapolitan)
|
|
43
|
+
# a_neap_min.vii # G# (80) - leading tone
|
|
44
|
+
#
|
|
45
|
+
# @see ScaleKind Abstract base class
|
|
46
|
+
# @see MinorHarmonicScaleKind Harmonic minor (with major 2nd)
|
|
47
|
+
# @see NeapolitanMajorScaleKind Neapolitan major
|
|
48
|
+
class NeapolitanMinorScaleKind < ScaleKind
|
|
49
|
+
@base_metadata = {
|
|
50
|
+
family: :ethnic,
|
|
51
|
+
brightness: -2,
|
|
52
|
+
character: [:neapolitan, :classical, :dark],
|
|
53
|
+
parent: nil
|
|
54
|
+
}.freeze
|
|
55
|
+
|
|
56
|
+
class << self
|
|
57
|
+
@@pitches =
|
|
58
|
+
[{ functions: %i[i _1 tonic first],
|
|
59
|
+
pitch: 0 },
|
|
60
|
+
{ functions: %i[ii _2 supertonic second],
|
|
61
|
+
pitch: 1 },
|
|
62
|
+
{ functions: %i[iii _3 mediant third],
|
|
63
|
+
pitch: 3 },
|
|
64
|
+
{ functions: %i[iv _4 subdominant fourth],
|
|
65
|
+
pitch: 5 },
|
|
66
|
+
{ functions: %i[v _5 dominant fifth],
|
|
67
|
+
pitch: 7 },
|
|
68
|
+
{ functions: %i[vi _6 submediant sixth],
|
|
69
|
+
pitch: 8 },
|
|
70
|
+
{ functions: %i[vii _7 leading seventh],
|
|
71
|
+
pitch: 11 },
|
|
72
|
+
{ functions: %i[viii _8 eighth],
|
|
73
|
+
pitch: 12 },
|
|
74
|
+
{ functions: %i[ix _9 ninth],
|
|
75
|
+
pitch: 12 + 1 },
|
|
76
|
+
{ functions: %i[x _10 tenth],
|
|
77
|
+
pitch: 12 + 3 },
|
|
78
|
+
{ functions: %i[xi _11 eleventh],
|
|
79
|
+
pitch: 12 + 5 },
|
|
80
|
+
{ functions: %i[xii _12 twelfth],
|
|
81
|
+
pitch: 12 + 7 },
|
|
82
|
+
{ functions: %i[xiii _13 thirteenth],
|
|
83
|
+
pitch: 12 + 8 }].freeze
|
|
84
|
+
|
|
85
|
+
def pitches
|
|
86
|
+
@@pitches
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def grades
|
|
90
|
+
7
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def id
|
|
94
|
+
:neapolitan_minor
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
EquallyTempered12ToneScaleSystem.register NeapolitanMinorScaleKind
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Phrygian dominant scale kind (Spanish Phrygian).
|
|
6
|
+
#
|
|
7
|
+
# PhrygianDominantScaleKind defines the Phrygian dominant scale (also called
|
|
8
|
+
# Spanish Phrygian, Freygish, or Spanish Gypsy scale), the fifth mode of
|
|
9
|
+
# harmonic minor. It's the quintessential flamenco scale.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony:
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (uppercase for major 3rd quality):
|
|
16
|
+
#
|
|
17
|
+
# - **I** (tonic): Root (0 semitones)
|
|
18
|
+
# - **II** (supertonic): Minor second (1 semitone) ← PHRYGIAN
|
|
19
|
+
# - **III** (mediant): Major third (4 semitones) ← DOMINANT
|
|
20
|
+
# - **IV** (subdominant): Perfect fourth (5 semitones)
|
|
21
|
+
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
22
|
+
# - **VI** (submediant): Minor sixth (8 semitones)
|
|
23
|
+
# - **VII** (subtonic): Minor seventh (10 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Key Features
|
|
26
|
+
#
|
|
27
|
+
# - Phrygian's minor second (exotic)
|
|
28
|
+
# - Dominant's major third (strong harmonic character)
|
|
29
|
+
# - Creates the characteristic flamenco sound
|
|
30
|
+
#
|
|
31
|
+
# ## Musical Character
|
|
32
|
+
#
|
|
33
|
+
# The Phrygian dominant scale:
|
|
34
|
+
#
|
|
35
|
+
# - The sound of flamenco and Spanish guitar
|
|
36
|
+
# - Works over dominant chords resolving to minor
|
|
37
|
+
# - Common in klezmer and Middle Eastern music too
|
|
38
|
+
# - Intensely expressive and dramatic
|
|
39
|
+
#
|
|
40
|
+
# ## Usage
|
|
41
|
+
#
|
|
42
|
+
# e_phry_dom = Scales[:et12][440.0][:phrygian_dominant][64]
|
|
43
|
+
# e_phry_dom.tonic # E (64)
|
|
44
|
+
# e_phry_dom.II # F (65) - minor second (Phrygian)
|
|
45
|
+
# e_phry_dom.III # G# (68) - major third (Dominant)
|
|
46
|
+
#
|
|
47
|
+
# @see ScaleKind Abstract base class
|
|
48
|
+
# @see PhrygianScaleKind Phrygian mode (with minor 3rd)
|
|
49
|
+
# @see MinorHarmonicScaleKind Parent harmonic minor scale
|
|
50
|
+
class PhrygianDominantScaleKind < ScaleKind
|
|
51
|
+
@base_metadata = {
|
|
52
|
+
family: :ethnic,
|
|
53
|
+
brightness: -1,
|
|
54
|
+
character: [:spanish, :flamenco, :jewish],
|
|
55
|
+
parent: { scale: :minor_harmonic, degree: 5 }
|
|
56
|
+
}.freeze
|
|
57
|
+
|
|
58
|
+
class << self
|
|
59
|
+
@@pitches =
|
|
60
|
+
[{ functions: %i[I _1 tonic first],
|
|
61
|
+
pitch: 0 },
|
|
62
|
+
{ functions: %i[II _2 supertonic second],
|
|
63
|
+
pitch: 1 },
|
|
64
|
+
{ functions: %i[III _3 mediant third],
|
|
65
|
+
pitch: 4 },
|
|
66
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
67
|
+
pitch: 5 },
|
|
68
|
+
{ functions: %i[V _5 dominant fifth],
|
|
69
|
+
pitch: 7 },
|
|
70
|
+
{ functions: %i[VI _6 submediant sixth],
|
|
71
|
+
pitch: 8 },
|
|
72
|
+
{ functions: %i[VII _7 subtonic seventh],
|
|
73
|
+
pitch: 10 },
|
|
74
|
+
{ functions: %i[VIII _8 eighth],
|
|
75
|
+
pitch: 12 },
|
|
76
|
+
{ functions: %i[IX _9 ninth],
|
|
77
|
+
pitch: 12 + 1 },
|
|
78
|
+
{ functions: %i[X _10 tenth],
|
|
79
|
+
pitch: 12 + 4 },
|
|
80
|
+
{ functions: %i[XI _11 eleventh],
|
|
81
|
+
pitch: 12 + 5 },
|
|
82
|
+
{ functions: %i[XII _12 twelfth],
|
|
83
|
+
pitch: 12 + 7 },
|
|
84
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
85
|
+
pitch: 12 + 8 }].freeze
|
|
86
|
+
|
|
87
|
+
def pitches
|
|
88
|
+
@@pitches
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def grades
|
|
92
|
+
7
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def id
|
|
96
|
+
:phrygian_dominant
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
EquallyTempered12ToneScaleSystem.register PhrygianDominantScaleKind
|
|
101
|
+
end
|
|
102
|
+
end
|
|
103
|
+
end
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Harmonic major scale kind.
|
|
6
|
+
#
|
|
7
|
+
# HarmonicMajorScaleKind defines the harmonic major scale, a major scale
|
|
8
|
+
# with a lowered sixth degree. It creates an augmented second between
|
|
9
|
+
# the sixth and seventh degrees, similar to harmonic minor but in a
|
|
10
|
+
# major context.
|
|
11
|
+
#
|
|
12
|
+
# ## Pitch Structure
|
|
13
|
+
#
|
|
14
|
+
# 7 diatonic degrees plus extended harmony:
|
|
15
|
+
#
|
|
16
|
+
# **Scale Degrees** (uppercase for major quality):
|
|
17
|
+
#
|
|
18
|
+
# - **I** (tonic): Root (0 semitones)
|
|
19
|
+
# - **II** (supertonic): Major second (2 semitones)
|
|
20
|
+
# - **III** (mediant): Major third (4 semitones)
|
|
21
|
+
# - **IV** (subdominant): Perfect fourth (5 semitones)
|
|
22
|
+
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
23
|
+
# - **VI** (submediant): Minor sixth (8 semitones) ← CHARACTERISTIC (b6)
|
|
24
|
+
# - **VII** (leading): Major seventh (11 semitones)
|
|
25
|
+
#
|
|
26
|
+
# ## Key Feature
|
|
27
|
+
#
|
|
28
|
+
# The augmented second between b6 and natural 7 creates an exotic
|
|
29
|
+
# interval similar to harmonic minor, but in a major key context.
|
|
30
|
+
#
|
|
31
|
+
# ## Musical Character
|
|
32
|
+
#
|
|
33
|
+
# The harmonic major scale:
|
|
34
|
+
#
|
|
35
|
+
# - Major quality with exotic coloring
|
|
36
|
+
# - Augmented second (b6 to 7) adds drama
|
|
37
|
+
# - Used in classical, jazz, and film music
|
|
38
|
+
# - Creates unique diminished chord on bVI
|
|
39
|
+
#
|
|
40
|
+
# ## Usage
|
|
41
|
+
#
|
|
42
|
+
# c_harm_maj = Scales[:et12][440.0][:major_harmonic][60]
|
|
43
|
+
# c_harm_maj.tonic # C (60)
|
|
44
|
+
# c_harm_maj.VI # Ab (68) - minor sixth
|
|
45
|
+
# c_harm_maj.leading # B (71) - major seventh
|
|
46
|
+
# # Ab to B = augmented second (3 semitones)
|
|
47
|
+
#
|
|
48
|
+
# @see ScaleKind Abstract base class
|
|
49
|
+
# @see MajorScaleKind Major scale (with major 6th)
|
|
50
|
+
# @see MinorHarmonicScaleKind Harmonic minor (similar augmented second)
|
|
51
|
+
class HarmonicMajorScaleKind < ScaleKind
|
|
52
|
+
@base_metadata = {
|
|
53
|
+
family: :diatonic,
|
|
54
|
+
brightness: -1,
|
|
55
|
+
character: [:major_minor, :dramatic, :classical],
|
|
56
|
+
parent: nil
|
|
57
|
+
}.freeze
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
@@pitches =
|
|
61
|
+
[{ functions: %i[I _1 tonic first],
|
|
62
|
+
pitch: 0 },
|
|
63
|
+
{ functions: %i[II _2 supertonic second],
|
|
64
|
+
pitch: 2 },
|
|
65
|
+
{ functions: %i[III _3 mediant third],
|
|
66
|
+
pitch: 4 },
|
|
67
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
68
|
+
pitch: 5 },
|
|
69
|
+
{ functions: %i[V _5 dominant fifth],
|
|
70
|
+
pitch: 7 },
|
|
71
|
+
{ functions: %i[VI _6 submediant sixth],
|
|
72
|
+
pitch: 8 },
|
|
73
|
+
{ functions: %i[VII _7 leading seventh],
|
|
74
|
+
pitch: 11 },
|
|
75
|
+
{ functions: %i[VIII _8 eighth],
|
|
76
|
+
pitch: 12 },
|
|
77
|
+
{ functions: %i[IX _9 ninth],
|
|
78
|
+
pitch: 12 + 2 },
|
|
79
|
+
{ functions: %i[X _10 tenth],
|
|
80
|
+
pitch: 12 + 4 },
|
|
81
|
+
{ functions: %i[XI _11 eleventh],
|
|
82
|
+
pitch: 12 + 5 },
|
|
83
|
+
{ functions: %i[XII _12 twelfth],
|
|
84
|
+
pitch: 12 + 7 },
|
|
85
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
86
|
+
pitch: 12 + 8 }].freeze
|
|
87
|
+
|
|
88
|
+
def pitches
|
|
89
|
+
@@pitches
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def grades
|
|
93
|
+
7
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def id
|
|
97
|
+
:major_harmonic
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
EquallyTempered12ToneScaleSystem.register HarmonicMajorScaleKind
|
|
102
|
+
end
|
|
103
|
+
end
|
|
104
|
+
end
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Major scale kind (Ionian mode).
|
|
6
|
+
#
|
|
7
|
+
# MajorScaleKind defines the major scale, the fundamental scale of Western
|
|
8
|
+
# tonal music. It follows the pattern: W-W-H-W-W-W-H (whole-half steps)
|
|
9
|
+
# or intervals: M2-M2-m2-M2-M2-M2-m2 from the root.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (Roman numerals, uppercase for major):
|
|
16
|
+
#
|
|
17
|
+
# - **I** (tonic): Root (0 semitones)
|
|
18
|
+
# - **II** (supertonic): Major second (2 semitones)
|
|
19
|
+
# - **III** (mediant): Major third (4 semitones)
|
|
20
|
+
# - **IV** (subdominant): Perfect fourth (5 semitones)
|
|
21
|
+
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
22
|
+
# - **VI** (submediant): Major sixth (9 semitones, relative minor)
|
|
23
|
+
# - **VII** (leading): Major seventh (11 semitones)
|
|
24
|
+
#
|
|
25
|
+
# **Extended degrees** (for extended harmony):
|
|
26
|
+
#
|
|
27
|
+
# - VIII-XIII: Compound intervals (8th, 9th, 10th, 11th, 12th, 13th)
|
|
28
|
+
#
|
|
29
|
+
# ## Function Aliases
|
|
30
|
+
#
|
|
31
|
+
# Each degree has multiple function names:
|
|
32
|
+
#
|
|
33
|
+
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7 (ordinal)
|
|
34
|
+
# - **Roman**: I, II, III, IV, V, VI, VII (harmonic analysis)
|
|
35
|
+
# - **Function**: tonic, supertonic, mediant, subdominant, dominant,
|
|
36
|
+
# submediant, leading
|
|
37
|
+
# - **Ordinal**: first, second, third, fourth, fifth, sixth, seventh
|
|
38
|
+
# - **Special**: relative/relative_minor for VI (relative minor root)
|
|
39
|
+
#
|
|
40
|
+
# ## Usage
|
|
41
|
+
#
|
|
42
|
+
# c_major = Scales[:et12][440.0][:major][60]
|
|
43
|
+
# c_major.tonic # C (60)
|
|
44
|
+
# c_major.dominant # G (67)
|
|
45
|
+
# c_major.VI # A (69) - relative minor root
|
|
46
|
+
# c_major.relative_minor.scale(:minor) # A minor scale
|
|
47
|
+
#
|
|
48
|
+
# @see ScaleKind Abstract base class
|
|
49
|
+
# @see MinorNaturalScaleKind Natural minor scale
|
|
50
|
+
# @see ChromaticScaleKind Chromatic scale
|
|
51
|
+
class MajorScaleKind < ScaleKind
|
|
52
|
+
@base_metadata = {
|
|
53
|
+
family: :diatonic,
|
|
54
|
+
brightness: 0,
|
|
55
|
+
character: [:bright, :stable, :resolved],
|
|
56
|
+
parent: nil
|
|
57
|
+
}.freeze
|
|
58
|
+
|
|
59
|
+
class << self
|
|
60
|
+
@@pitches =
|
|
61
|
+
[{ functions: %i[I _1 tonic first],
|
|
62
|
+
pitch: 0 },
|
|
63
|
+
{ functions: %i[II _2 supertonic second],
|
|
64
|
+
pitch: 2 },
|
|
65
|
+
{ functions: %i[III _3 mediant third],
|
|
66
|
+
pitch: 4 },
|
|
67
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
68
|
+
pitch: 5 },
|
|
69
|
+
{ functions: %i[V _5 dominant fifth],
|
|
70
|
+
pitch: 7 },
|
|
71
|
+
{ functions: %i[VI _6 submediant relative relative_minor sixth],
|
|
72
|
+
pitch: 9 },
|
|
73
|
+
{ functions: %i[VII _7 leading seventh],
|
|
74
|
+
pitch: 11 },
|
|
75
|
+
{ functions: %i[VIII _8 eighth],
|
|
76
|
+
pitch: 12 },
|
|
77
|
+
{ functions: %i[IX _9 ninth],
|
|
78
|
+
pitch: 12 + 2 },
|
|
79
|
+
{ functions: %i[X _10 tenth],
|
|
80
|
+
pitch: 12 + 4 },
|
|
81
|
+
{ functions: %i[XI _11 eleventh],
|
|
82
|
+
pitch: 12 + 5 },
|
|
83
|
+
{ functions: %i[XII _12 twelfth],
|
|
84
|
+
pitch: 12 + 7 },
|
|
85
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
86
|
+
pitch: 12 + 9 }].freeze
|
|
87
|
+
|
|
88
|
+
# Pitch structure.
|
|
89
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
90
|
+
def pitches
|
|
91
|
+
@@pitches
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# Number of diatonic degrees.
|
|
95
|
+
# @return [Integer] 7
|
|
96
|
+
def grades
|
|
97
|
+
7
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Scale kind identifier.
|
|
101
|
+
# @return [Symbol] :major
|
|
102
|
+
def id
|
|
103
|
+
:major
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
EquallyTempered12ToneScaleSystem.register MajorScaleKind
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Altered scale kind (seventh mode of melodic minor).
|
|
6
|
+
#
|
|
7
|
+
# AlteredScaleKind defines the Altered scale (also called Super Locrian,
|
|
8
|
+
# Diminished Whole Tone, or Altered Dominant), the seventh mode of the
|
|
9
|
+
# melodic minor scale. It's the quintessential scale for altered dominant
|
|
10
|
+
# chords in jazz.
|
|
11
|
+
#
|
|
12
|
+
# ## Pitch Structure
|
|
13
|
+
#
|
|
14
|
+
# 7 diatonic degrees plus extended harmony:
|
|
15
|
+
#
|
|
16
|
+
# **Scale Degrees** (lowercase for diminished quality):
|
|
17
|
+
#
|
|
18
|
+
# - **i** (tonic): Root (0 semitones)
|
|
19
|
+
# - **ii** (supertonic): Minor second (1 semitone) ← b9
|
|
20
|
+
# - **iii** (mediant): Minor third (3 semitones) ← #9 (enharmonic)
|
|
21
|
+
# - **iv** (subdominant): Major third (4 semitones) ← b11 (3rd of chord)
|
|
22
|
+
# - **v** (dominant): Diminished fifth (6 semitones) ← b5/#11
|
|
23
|
+
# - **vi** (submediant): Minor sixth (8 semitones) ← #5/b13
|
|
24
|
+
# - **vii** (subtonic): Minor seventh (10 semitones) ← b7
|
|
25
|
+
#
|
|
26
|
+
# ## All Alterations Present
|
|
27
|
+
#
|
|
28
|
+
# Contains all possible alterations of a dominant chord:
|
|
29
|
+
# - b9, #9 (altered 9ths)
|
|
30
|
+
# - #11/b5 (altered 11th/5th)
|
|
31
|
+
# - b13/#5 (altered 13th/5th)
|
|
32
|
+
#
|
|
33
|
+
# ## Musical Character
|
|
34
|
+
#
|
|
35
|
+
# The Altered scale:
|
|
36
|
+
#
|
|
37
|
+
# - Maximum tension for dominant chords
|
|
38
|
+
# - Used over 7alt, 7#9, 7b9#11, etc.
|
|
39
|
+
# - Essential in bebop and modern jazz
|
|
40
|
+
# - Creates strong resolution to tonic
|
|
41
|
+
#
|
|
42
|
+
# ## Usage
|
|
43
|
+
#
|
|
44
|
+
# g_alt = Scales[:et12][440.0][:altered][67]
|
|
45
|
+
# g_alt.tonic # G (67)
|
|
46
|
+
# g_alt.ii # Ab (68) - b9
|
|
47
|
+
# g_alt.iii # Bb (70) - #9
|
|
48
|
+
# g_alt.v # Db (73) - b5
|
|
49
|
+
#
|
|
50
|
+
# @see ScaleKind Abstract base class
|
|
51
|
+
# @see MelodicMinorScaleKind Parent melodic minor scale
|
|
52
|
+
# @see DiminishedWHScaleKind Another altered dominant scale option
|
|
53
|
+
class AlteredScaleKind < ScaleKind
|
|
54
|
+
@base_metadata = {
|
|
55
|
+
family: :melodic_minor_modes,
|
|
56
|
+
brightness: -3,
|
|
57
|
+
character: [:altered_dominant, :jazz, :tension],
|
|
58
|
+
parent: { scale: :minor_melodic, degree: 7 }
|
|
59
|
+
}.freeze
|
|
60
|
+
|
|
61
|
+
class << self
|
|
62
|
+
@@pitches =
|
|
63
|
+
[{ functions: %i[i _1 tonic first],
|
|
64
|
+
pitch: 0 },
|
|
65
|
+
{ functions: %i[ii _2 supertonic second],
|
|
66
|
+
pitch: 1 },
|
|
67
|
+
{ functions: %i[iii _3 mediant third],
|
|
68
|
+
pitch: 3 },
|
|
69
|
+
{ functions: %i[iv _4 subdominant fourth],
|
|
70
|
+
pitch: 4 },
|
|
71
|
+
{ functions: %i[v _5 dominant fifth],
|
|
72
|
+
pitch: 6 },
|
|
73
|
+
{ functions: %i[vi _6 submediant sixth],
|
|
74
|
+
pitch: 8 },
|
|
75
|
+
{ functions: %i[vii _7 subtonic seventh],
|
|
76
|
+
pitch: 10 },
|
|
77
|
+
{ functions: %i[viii _8 eighth],
|
|
78
|
+
pitch: 12 },
|
|
79
|
+
{ functions: %i[ix _9 ninth],
|
|
80
|
+
pitch: 12 + 1 },
|
|
81
|
+
{ functions: %i[x _10 tenth],
|
|
82
|
+
pitch: 12 + 3 },
|
|
83
|
+
{ functions: %i[xi _11 eleventh],
|
|
84
|
+
pitch: 12 + 4 },
|
|
85
|
+
{ functions: %i[xii _12 twelfth],
|
|
86
|
+
pitch: 12 + 6 },
|
|
87
|
+
{ functions: %i[xiii _13 thirteenth],
|
|
88
|
+
pitch: 12 + 8 }].freeze
|
|
89
|
+
|
|
90
|
+
def pitches
|
|
91
|
+
@@pitches
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def grades
|
|
95
|
+
7
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def id
|
|
99
|
+
:altered
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
EquallyTempered12ToneScaleSystem.register AlteredScaleKind
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|