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,125 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Harmonic minor scale kind.
|
|
6
|
+
#
|
|
7
|
+
# MinorHarmonicScaleKind defines the harmonic minor scale, a variation of
|
|
8
|
+
# the natural minor with a raised seventh degree. This creates a leading
|
|
9
|
+
# tone (major seventh) that resolves strongly to the tonic, giving the
|
|
10
|
+
# scale a more directed, dramatic character.
|
|
11
|
+
#
|
|
12
|
+
# ## Pitch Structure
|
|
13
|
+
#
|
|
14
|
+
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
15
|
+
#
|
|
16
|
+
# **Scale Degrees** (Roman numerals, lowercase for minor):
|
|
17
|
+
#
|
|
18
|
+
# - **i** (tonic): Root (0 semitones)
|
|
19
|
+
# - **ii** (supertonic): Major second (2 semitones)
|
|
20
|
+
# - **iii** (mediant): Minor third (3 semitones, relative major)
|
|
21
|
+
# - **iv** (subdominant): Perfect fourth (5 semitones)
|
|
22
|
+
# - **v** (dominant): Perfect fifth (7 semitones)
|
|
23
|
+
# - **vi** (submediant): Minor sixth (8 semitones)
|
|
24
|
+
# - **vii** (leading): **Major seventh** (11 semitones) ← RAISED from natural minor
|
|
25
|
+
#
|
|
26
|
+
# **Extended degrees**: viii-xiii (compound intervals)
|
|
27
|
+
#
|
|
28
|
+
# ## Key Difference from Natural Minor
|
|
29
|
+
#
|
|
30
|
+
# The **vii** degree is raised from 10 semitones (minor seventh) to
|
|
31
|
+
# 11 semitones (major seventh), creating:
|
|
32
|
+
#
|
|
33
|
+
# - A **leading tone** that resolves strongly upward to the tonic
|
|
34
|
+
# - An **augmented second** interval between vi and vii (3 semitones)
|
|
35
|
+
# - A **dominant seventh chord** (v7) with strong resolution to i
|
|
36
|
+
#
|
|
37
|
+
# ## Musical Character
|
|
38
|
+
#
|
|
39
|
+
# The harmonic minor scale:
|
|
40
|
+
#
|
|
41
|
+
# - Maintains minor quality (minor third)
|
|
42
|
+
# - Provides strong dominant-to-tonic resolution
|
|
43
|
+
# - Creates exotic sound due to augmented second (vi-vii)
|
|
44
|
+
# - Common in classical, jazz, and Middle Eastern music
|
|
45
|
+
#
|
|
46
|
+
# ## Function Aliases
|
|
47
|
+
#
|
|
48
|
+
# Same as natural minor:
|
|
49
|
+
#
|
|
50
|
+
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7
|
|
51
|
+
# - **Roman**: i, ii, iii, iv, v, vi, vii
|
|
52
|
+
# - **Function**: tonic, supertonic, mediant, subdominant, dominant,
|
|
53
|
+
# submediant, leading
|
|
54
|
+
# - **Special**: relative/relative_major for iii
|
|
55
|
+
#
|
|
56
|
+
# ## Usage
|
|
57
|
+
#
|
|
58
|
+
# a_harmonic_minor = Scales[:et12][440.0][:minor_harmonic][69]
|
|
59
|
+
# a_harmonic_minor.vii # G# (80) - raised 7th, not G (79)
|
|
60
|
+
# a_harmonic_minor.vi # F (77)
|
|
61
|
+
# # Augmented second: F to G# = 3 semitones
|
|
62
|
+
#
|
|
63
|
+
# @see ScaleKind Abstract base class
|
|
64
|
+
# @see MinorNaturalScaleKind Natural minor (with minor 7th)
|
|
65
|
+
# @see MajorScaleKind Major scale
|
|
66
|
+
class MinorHarmonicScaleKind < ScaleKind
|
|
67
|
+
@base_metadata = {
|
|
68
|
+
family: :diatonic,
|
|
69
|
+
brightness: -2,
|
|
70
|
+
character: [:dark, :exotic, :dramatic],
|
|
71
|
+
parent: nil
|
|
72
|
+
}.freeze
|
|
73
|
+
|
|
74
|
+
class << self
|
|
75
|
+
@@pitches =
|
|
76
|
+
[{ functions: %i[i _1 tonic],
|
|
77
|
+
pitch: 0 },
|
|
78
|
+
{ functions: %i[ii _2 supertonic],
|
|
79
|
+
pitch: 2 },
|
|
80
|
+
{ functions: %i[iii _3 mediant relative relative_major],
|
|
81
|
+
pitch: 3 },
|
|
82
|
+
{ functions: %i[iv _4 subdominant],
|
|
83
|
+
pitch: 5 },
|
|
84
|
+
{ functions: %i[v _5 dominant],
|
|
85
|
+
pitch: 7 },
|
|
86
|
+
{ functions: %i[vi _6 submediant],
|
|
87
|
+
pitch: 8 },
|
|
88
|
+
{ functions: %i[vii _7 leading],
|
|
89
|
+
pitch: 11 },
|
|
90
|
+
{ functions: %i[viii _8],
|
|
91
|
+
pitch: 12 },
|
|
92
|
+
{ functions: %i[ix _9],
|
|
93
|
+
pitch: 12 + 2 },
|
|
94
|
+
{ functions: %i[x _10],
|
|
95
|
+
pitch: 12 + 3 },
|
|
96
|
+
{ functions: %i[xi _11],
|
|
97
|
+
pitch: 12 + 5 },
|
|
98
|
+
{ functions: %i[xii _12],
|
|
99
|
+
pitch: 12 + 7 },
|
|
100
|
+
{ functions: %i[xiii _13],
|
|
101
|
+
pitch: 12 + 8 }].freeze
|
|
102
|
+
|
|
103
|
+
# Pitch structure.
|
|
104
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
105
|
+
def pitches
|
|
106
|
+
@@pitches
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Number of diatonic degrees.
|
|
110
|
+
# @return [Integer] 7
|
|
111
|
+
def grades
|
|
112
|
+
7
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# Scale kind identifier.
|
|
116
|
+
# @return [Symbol] :minor_harmonic
|
|
117
|
+
def id
|
|
118
|
+
:minor_harmonic
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
EquallyTempered12ToneScaleSystem.register MinorHarmonicScaleKind
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
end
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Natural minor scale kind (Aeolian mode).
|
|
6
|
+
#
|
|
7
|
+
# MinorNaturalScaleKind defines the natural minor scale, parallel to the
|
|
8
|
+
# major scale but with a darker, melancholic character. It follows the
|
|
9
|
+
# pattern: W-H-W-W-H-W-W 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, lowercase for minor):
|
|
16
|
+
#
|
|
17
|
+
# - **i** (tonic): Root (0 semitones)
|
|
18
|
+
# - **ii** (supertonic): Major second (2 semitones)
|
|
19
|
+
# - **iii** (mediant): Minor third (3 semitones, relative major)
|
|
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, NOT leading tone)
|
|
24
|
+
#
|
|
25
|
+
# **Extended degrees**: viii-xiii (compound intervals)
|
|
26
|
+
#
|
|
27
|
+
# ## Differences from Major
|
|
28
|
+
#
|
|
29
|
+
# Compared to major scale (same tonic):
|
|
30
|
+
#
|
|
31
|
+
# - **iii**: Flatted third (minor third instead of major)
|
|
32
|
+
# - **vi**: Flatted sixth (minor sixth instead of major)
|
|
33
|
+
# - **vii**: Flatted seventh (minor seventh instead of major)
|
|
34
|
+
#
|
|
35
|
+
# ## Relative Major
|
|
36
|
+
#
|
|
37
|
+
# The **iii** degree is the root of the relative major scale (shares same
|
|
38
|
+
# notes but different tonic). For example:
|
|
39
|
+
#
|
|
40
|
+
# - A minor (natural) relative major: C major
|
|
41
|
+
# - C major relative minor: A minor
|
|
42
|
+
#
|
|
43
|
+
# ## Function Aliases
|
|
44
|
+
#
|
|
45
|
+
# Similar to major but with lowercase Roman numerals:
|
|
46
|
+
#
|
|
47
|
+
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7
|
|
48
|
+
# - **Roman**: i, ii, iii, iv, v, vi, vii
|
|
49
|
+
# - **Function**: tonic, supertonic, mediant, subdominant, dominant, submediant
|
|
50
|
+
# - **Ordinal**: first, second, third, fourth, fifth, sixth, seventh
|
|
51
|
+
# - **Special**: relative/relative_major for iii
|
|
52
|
+
#
|
|
53
|
+
# ## Usage
|
|
54
|
+
#
|
|
55
|
+
# a_minor = Scales[:et12][440.0][:minor][69]
|
|
56
|
+
# a_minor.tonic # A (69)
|
|
57
|
+
# a_minor.dominant # E (76)
|
|
58
|
+
# a_minor.iii # C (72) - relative major root
|
|
59
|
+
# a_minor.relative_major.scale(:major) # C major scale
|
|
60
|
+
#
|
|
61
|
+
# @see ScaleKind Abstract base class
|
|
62
|
+
# @see MajorScaleKind Major scale
|
|
63
|
+
# @see MinorHarmonicScaleKind Harmonic minor (with raised 7th)
|
|
64
|
+
class MinorNaturalScaleKind < ScaleKind
|
|
65
|
+
@base_metadata = {
|
|
66
|
+
family: :diatonic,
|
|
67
|
+
brightness: -3,
|
|
68
|
+
character: [:dark, :sad, :introspective],
|
|
69
|
+
parent: nil
|
|
70
|
+
}.freeze
|
|
71
|
+
|
|
72
|
+
class << self
|
|
73
|
+
@@pitches =
|
|
74
|
+
[{ functions: %i[i _1 tonic first],
|
|
75
|
+
pitch: 0 },
|
|
76
|
+
{ functions: %i[ii _2 supertonic second],
|
|
77
|
+
pitch: 2 },
|
|
78
|
+
{ functions: %i[iii _3 mediant relative relative_major third],
|
|
79
|
+
pitch: 3 },
|
|
80
|
+
{ functions: %i[iv _4 subdominant fourth],
|
|
81
|
+
pitch: 5 },
|
|
82
|
+
{ functions: %i[v _5 dominant fifth],
|
|
83
|
+
pitch: 7 },
|
|
84
|
+
{ functions: %i[vi _6 submediant sixth],
|
|
85
|
+
pitch: 8 },
|
|
86
|
+
{ functions: %i[vii _7 seventh],
|
|
87
|
+
pitch: 10 },
|
|
88
|
+
{ functions: %i[viii _8 eighth],
|
|
89
|
+
pitch: 12 },
|
|
90
|
+
{ functions: %i[ix _9 ninth],
|
|
91
|
+
pitch: 12 + 2 },
|
|
92
|
+
{ functions: %i[x _10 tenth],
|
|
93
|
+
pitch: 12 + 3 },
|
|
94
|
+
{ functions: %i[xi _11 eleventh],
|
|
95
|
+
pitch: 12 + 5 },
|
|
96
|
+
{ functions: %i[xii _12 twelfth],
|
|
97
|
+
pitch: 12 + 7 },
|
|
98
|
+
{ functions: %i[xiii _13 thirteenth],
|
|
99
|
+
pitch: 12 + 8 }].freeze
|
|
100
|
+
|
|
101
|
+
# Pitch structure.
|
|
102
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
103
|
+
def pitches
|
|
104
|
+
@@pitches
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Number of diatonic degrees.
|
|
108
|
+
# @return [Integer] 7
|
|
109
|
+
def grades
|
|
110
|
+
7
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Scale kind identifier.
|
|
114
|
+
# @return [Symbol] :minor
|
|
115
|
+
def id
|
|
116
|
+
:minor
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
EquallyTempered12ToneScaleSystem.register MinorNaturalScaleKind
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Dorian mode (second mode of major scale).
|
|
6
|
+
#
|
|
7
|
+
# DorianScaleKind defines the Dorian mode, a minor mode with a characteristic
|
|
8
|
+
# raised sixth degree. It's built on the second degree of the major scale
|
|
9
|
+
# and has a brighter, more hopeful quality than natural minor.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (Roman numerals, lowercase for minor):
|
|
16
|
+
#
|
|
17
|
+
# - **i** (tonic): Root (0 semitones)
|
|
18
|
+
# - **ii** (supertonic): Major second (2 semitones)
|
|
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) ← CHARACTERISTIC
|
|
23
|
+
# - **vii** (subtonic): Minor seventh (10 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Key Difference from Natural Minor
|
|
26
|
+
#
|
|
27
|
+
# The **vi** degree is raised from 8 semitones (minor sixth) to
|
|
28
|
+
# 9 semitones (major sixth), creating:
|
|
29
|
+
#
|
|
30
|
+
# - A brighter, less melancholic minor quality
|
|
31
|
+
# - The characteristic "Dorian color"
|
|
32
|
+
# - Common in jazz, folk, and rock music
|
|
33
|
+
#
|
|
34
|
+
# ## Musical Character
|
|
35
|
+
#
|
|
36
|
+
# The Dorian mode:
|
|
37
|
+
#
|
|
38
|
+
# - Maintains minor quality (minor third)
|
|
39
|
+
# - Has a raised 6th that adds brightness
|
|
40
|
+
# - Common in jazz improvisation (ii-V-I progressions)
|
|
41
|
+
# - Used extensively in modal jazz and Celtic music
|
|
42
|
+
#
|
|
43
|
+
# ## Usage
|
|
44
|
+
#
|
|
45
|
+
# d_dorian = Scales[:et12][440.0][:dorian][62]
|
|
46
|
+
# d_dorian.tonic # D (62)
|
|
47
|
+
# d_dorian.vi # B (71) - major sixth (characteristic)
|
|
48
|
+
#
|
|
49
|
+
# @see ScaleKind Abstract base class
|
|
50
|
+
# @see MinorNaturalScaleKind Natural minor (with minor 6th)
|
|
51
|
+
# @see PhrygianScaleKind Phrygian mode
|
|
52
|
+
class DorianScaleKind < ScaleKind
|
|
53
|
+
@base_metadata = {
|
|
54
|
+
family: :greek_modes,
|
|
55
|
+
brightness: -1,
|
|
56
|
+
character: [:minor, :jazzy, :sophisticated],
|
|
57
|
+
parent: { scale: :major, degree: 2 }
|
|
58
|
+
}.freeze
|
|
59
|
+
|
|
60
|
+
class << self
|
|
61
|
+
@@pitches =
|
|
62
|
+
[{ functions: %i[i _1 tonic first],
|
|
63
|
+
pitch: 0 },
|
|
64
|
+
{ functions: %i[ii _2 supertonic second],
|
|
65
|
+
pitch: 2 },
|
|
66
|
+
{ functions: %i[iii _3 mediant third],
|
|
67
|
+
pitch: 3 },
|
|
68
|
+
{ functions: %i[iv _4 subdominant fourth],
|
|
69
|
+
pitch: 5 },
|
|
70
|
+
{ functions: %i[v _5 dominant fifth],
|
|
71
|
+
pitch: 7 },
|
|
72
|
+
{ functions: %i[vi _6 submediant sixth],
|
|
73
|
+
pitch: 9 },
|
|
74
|
+
{ functions: %i[vii _7 subtonic seventh],
|
|
75
|
+
pitch: 10 },
|
|
76
|
+
{ functions: %i[viii _8 eighth],
|
|
77
|
+
pitch: 12 },
|
|
78
|
+
{ functions: %i[ix _9 ninth],
|
|
79
|
+
pitch: 12 + 2 },
|
|
80
|
+
{ functions: %i[x _10 tenth],
|
|
81
|
+
pitch: 12 + 3 },
|
|
82
|
+
{ functions: %i[xi _11 eleventh],
|
|
83
|
+
pitch: 12 + 5 },
|
|
84
|
+
{ functions: %i[xii _12 twelfth],
|
|
85
|
+
pitch: 12 + 7 },
|
|
86
|
+
{ functions: %i[xiii _13 thirteenth],
|
|
87
|
+
pitch: 12 + 9 }].freeze
|
|
88
|
+
|
|
89
|
+
# Pitch structure.
|
|
90
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
91
|
+
def pitches
|
|
92
|
+
@@pitches
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Number of diatonic degrees.
|
|
96
|
+
# @return [Integer] 7
|
|
97
|
+
def grades
|
|
98
|
+
7
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Scale kind identifier.
|
|
102
|
+
# @return [Symbol] :dorian
|
|
103
|
+
def id
|
|
104
|
+
:dorian
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
EquallyTempered12ToneScaleSystem.register DorianScaleKind
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Locrian mode (seventh mode of major scale).
|
|
6
|
+
#
|
|
7
|
+
# LocrianScaleKind defines the Locrian mode, a diminished mode with a
|
|
8
|
+
# characteristic lowered second and fifth degrees. It's built on the
|
|
9
|
+
# seventh degree of the major scale and has an unstable, dissonant quality.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (Roman numerals, lowercase for diminished):
|
|
16
|
+
#
|
|
17
|
+
# - **i** (tonic): Root (0 semitones)
|
|
18
|
+
# - **ii** (supertonic): **Minor second** (1 semitone) ← CHARACTERISTIC
|
|
19
|
+
# - **iii** (mediant): Minor third (3 semitones)
|
|
20
|
+
# - **iv** (subdominant): Perfect fourth (5 semitones)
|
|
21
|
+
# - **v** (dominant): **Diminished fifth** (6 semitones) ← CHARACTERISTIC
|
|
22
|
+
# - **vi** (submediant): Minor sixth (8 semitones)
|
|
23
|
+
# - **vii** (subtonic): Minor seventh (10 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Key Differences from Natural Minor
|
|
26
|
+
#
|
|
27
|
+
# Two degrees are altered:
|
|
28
|
+
# - **ii** lowered from 2 to 1 semitone (minor second)
|
|
29
|
+
# - **v** lowered from 7 to 6 semitones (diminished fifth/tritone)
|
|
30
|
+
#
|
|
31
|
+
# This creates:
|
|
32
|
+
# - A highly unstable, dissonant quality
|
|
33
|
+
# - No stable perfect fifth above the tonic
|
|
34
|
+
# - Rarely used as a tonal center
|
|
35
|
+
#
|
|
36
|
+
# ## Musical Character
|
|
37
|
+
#
|
|
38
|
+
# The Locrian mode:
|
|
39
|
+
#
|
|
40
|
+
# - Has diminished quality (minor third + diminished fifth)
|
|
41
|
+
# - The most unstable of the seven modes
|
|
42
|
+
# - Used sparingly, often for tension or dissonance
|
|
43
|
+
# - Common over half-diminished (m7b5) chords in jazz
|
|
44
|
+
#
|
|
45
|
+
# ## Usage
|
|
46
|
+
#
|
|
47
|
+
# b_locrian = Scales[:et12][440.0][:locrian][71]
|
|
48
|
+
# b_locrian.tonic # B (71)
|
|
49
|
+
# b_locrian.ii # C (72) - minor second (characteristic)
|
|
50
|
+
# b_locrian.v # F (77) - diminished fifth (characteristic)
|
|
51
|
+
#
|
|
52
|
+
# @see ScaleKind Abstract base class
|
|
53
|
+
# @see MinorNaturalScaleKind Natural minor
|
|
54
|
+
# @see PhrygianScaleKind Phrygian mode (also has minor 2nd)
|
|
55
|
+
class LocrianScaleKind < ScaleKind
|
|
56
|
+
@base_metadata = {
|
|
57
|
+
family: :greek_modes,
|
|
58
|
+
brightness: -3,
|
|
59
|
+
character: [:unstable, :diminished, :tense],
|
|
60
|
+
parent: { scale: :major, degree: 7 }
|
|
61
|
+
}.freeze
|
|
62
|
+
|
|
63
|
+
class << self
|
|
64
|
+
@@pitches =
|
|
65
|
+
[{ functions: %i[i _1 tonic first],
|
|
66
|
+
pitch: 0 },
|
|
67
|
+
{ functions: %i[ii _2 supertonic second],
|
|
68
|
+
pitch: 1 },
|
|
69
|
+
{ functions: %i[iii _3 mediant third],
|
|
70
|
+
pitch: 3 },
|
|
71
|
+
{ functions: %i[iv _4 subdominant fourth],
|
|
72
|
+
pitch: 5 },
|
|
73
|
+
{ functions: %i[v _5 dominant fifth],
|
|
74
|
+
pitch: 6 },
|
|
75
|
+
{ functions: %i[vi _6 submediant sixth],
|
|
76
|
+
pitch: 8 },
|
|
77
|
+
{ functions: %i[vii _7 subtonic seventh],
|
|
78
|
+
pitch: 10 },
|
|
79
|
+
{ functions: %i[viii _8 eighth],
|
|
80
|
+
pitch: 12 },
|
|
81
|
+
{ functions: %i[ix _9 ninth],
|
|
82
|
+
pitch: 12 + 1 },
|
|
83
|
+
{ functions: %i[x _10 tenth],
|
|
84
|
+
pitch: 12 + 3 },
|
|
85
|
+
{ functions: %i[xi _11 eleventh],
|
|
86
|
+
pitch: 12 + 5 },
|
|
87
|
+
{ functions: %i[xii _12 twelfth],
|
|
88
|
+
pitch: 12 + 6 },
|
|
89
|
+
{ functions: %i[xiii _13 thirteenth],
|
|
90
|
+
pitch: 12 + 8 }].freeze
|
|
91
|
+
|
|
92
|
+
# Pitch structure.
|
|
93
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
94
|
+
def pitches
|
|
95
|
+
@@pitches
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Number of diatonic degrees.
|
|
99
|
+
# @return [Integer] 7
|
|
100
|
+
def grades
|
|
101
|
+
7
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
# Scale kind identifier.
|
|
105
|
+
# @return [Symbol] :locrian
|
|
106
|
+
def id
|
|
107
|
+
:locrian
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
EquallyTempered12ToneScaleSystem.register LocrianScaleKind
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Lydian mode (fourth mode of major scale).
|
|
6
|
+
#
|
|
7
|
+
# LydianScaleKind defines the Lydian mode, a major mode with a characteristic
|
|
8
|
+
# raised fourth degree. It's built on the fourth degree of the major scale
|
|
9
|
+
# and has a bright, dreamy, floating quality.
|
|
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): **Augmented fourth** (6 semitones) ← CHARACTERISTIC
|
|
21
|
+
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
22
|
+
# - **VI** (submediant): Major sixth (9 semitones)
|
|
23
|
+
# - **VII** (leading): Major seventh (11 semitones)
|
|
24
|
+
#
|
|
25
|
+
# ## Key Difference from Major
|
|
26
|
+
#
|
|
27
|
+
# The **IV** degree is raised from 5 semitones (perfect fourth) to
|
|
28
|
+
# 6 semitones (augmented fourth/tritone), creating:
|
|
29
|
+
#
|
|
30
|
+
# - A bright, ethereal quality
|
|
31
|
+
# - The characteristic "Lydian color"
|
|
32
|
+
# - A sense of floating or suspension
|
|
33
|
+
#
|
|
34
|
+
# ## Musical Character
|
|
35
|
+
#
|
|
36
|
+
# The Lydian mode:
|
|
37
|
+
#
|
|
38
|
+
# - Maintains major quality (major third)
|
|
39
|
+
# - Has a raised 4th that adds brightness and tension
|
|
40
|
+
# - Common in film scores and jazz (especially over maj7#11 chords)
|
|
41
|
+
# - Creates a dreamy, otherworldly atmosphere
|
|
42
|
+
#
|
|
43
|
+
# ## Usage
|
|
44
|
+
#
|
|
45
|
+
# f_lydian = Scales[:et12][440.0][:lydian][65]
|
|
46
|
+
# f_lydian.tonic # F (65)
|
|
47
|
+
# f_lydian.IV # B (71) - augmented fourth (characteristic)
|
|
48
|
+
#
|
|
49
|
+
# @see ScaleKind Abstract base class
|
|
50
|
+
# @see MajorScaleKind Major scale (with perfect 4th)
|
|
51
|
+
# @see MixolydianScaleKind Mixolydian mode
|
|
52
|
+
class LydianScaleKind < ScaleKind
|
|
53
|
+
@base_metadata = {
|
|
54
|
+
family: :greek_modes,
|
|
55
|
+
brightness: 2,
|
|
56
|
+
character: [:bright, :dreamy, :floating],
|
|
57
|
+
parent: { scale: :major, degree: 4 }
|
|
58
|
+
}.freeze
|
|
59
|
+
|
|
60
|
+
class << self
|
|
61
|
+
@@pitches =
|
|
62
|
+
[{ functions: %i[I _1 tonic first],
|
|
63
|
+
pitch: 0 },
|
|
64
|
+
{ functions: %i[II _2 supertonic second],
|
|
65
|
+
pitch: 2 },
|
|
66
|
+
{ functions: %i[III _3 mediant third],
|
|
67
|
+
pitch: 4 },
|
|
68
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
69
|
+
pitch: 6 },
|
|
70
|
+
{ functions: %i[V _5 dominant fifth],
|
|
71
|
+
pitch: 7 },
|
|
72
|
+
{ functions: %i[VI _6 submediant sixth],
|
|
73
|
+
pitch: 9 },
|
|
74
|
+
{ functions: %i[VII _7 leading seventh],
|
|
75
|
+
pitch: 11 },
|
|
76
|
+
{ functions: %i[VIII _8 eighth],
|
|
77
|
+
pitch: 12 },
|
|
78
|
+
{ functions: %i[IX _9 ninth],
|
|
79
|
+
pitch: 12 + 2 },
|
|
80
|
+
{ functions: %i[X _10 tenth],
|
|
81
|
+
pitch: 12 + 4 },
|
|
82
|
+
{ functions: %i[XI _11 eleventh],
|
|
83
|
+
pitch: 12 + 6 },
|
|
84
|
+
{ functions: %i[XII _12 twelfth],
|
|
85
|
+
pitch: 12 + 7 },
|
|
86
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
87
|
+
pitch: 12 + 9 }].freeze
|
|
88
|
+
|
|
89
|
+
# Pitch structure.
|
|
90
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
91
|
+
def pitches
|
|
92
|
+
@@pitches
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Number of diatonic degrees.
|
|
96
|
+
# @return [Integer] 7
|
|
97
|
+
def grades
|
|
98
|
+
7
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Scale kind identifier.
|
|
102
|
+
# @return [Symbol] :lydian
|
|
103
|
+
def id
|
|
104
|
+
:lydian
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
EquallyTempered12ToneScaleSystem.register LydianScaleKind
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Mixolydian mode (fifth mode of major scale).
|
|
6
|
+
#
|
|
7
|
+
# MixolydianScaleKind defines the Mixolydian mode, a major mode with a
|
|
8
|
+
# characteristic lowered seventh degree. It's built on the fifth degree
|
|
9
|
+
# of the major scale and has a bluesy, rock quality.
|
|
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)
|
|
23
|
+
# - **VII** (subtonic): **Minor seventh** (10 semitones) ← CHARACTERISTIC
|
|
24
|
+
#
|
|
25
|
+
# ## Key Difference from Major
|
|
26
|
+
#
|
|
27
|
+
# The **VII** degree is lowered from 11 semitones (major seventh) to
|
|
28
|
+
# 10 semitones (minor seventh), creating:
|
|
29
|
+
#
|
|
30
|
+
# - A bluesy, rock quality
|
|
31
|
+
# - The characteristic "Mixolydian color"
|
|
32
|
+
# - Natural dominant seventh sound
|
|
33
|
+
#
|
|
34
|
+
# ## Musical Character
|
|
35
|
+
#
|
|
36
|
+
# The Mixolydian mode:
|
|
37
|
+
#
|
|
38
|
+
# - Maintains major quality (major third)
|
|
39
|
+
# - Has a lowered 7th that removes the leading tone tension
|
|
40
|
+
# - Common in rock, blues, funk, and folk music
|
|
41
|
+
# - Natural mode for dominant seventh chords
|
|
42
|
+
#
|
|
43
|
+
# ## Usage
|
|
44
|
+
#
|
|
45
|
+
# g_mixolydian = Scales[:et12][440.0][:mixolydian][67]
|
|
46
|
+
# g_mixolydian.tonic # G (67)
|
|
47
|
+
# g_mixolydian.VII # F (77) - minor seventh (characteristic)
|
|
48
|
+
#
|
|
49
|
+
# @see ScaleKind Abstract base class
|
|
50
|
+
# @see MajorScaleKind Major scale (with major 7th)
|
|
51
|
+
# @see LydianScaleKind Lydian mode
|
|
52
|
+
class MixolydianScaleKind < ScaleKind
|
|
53
|
+
@base_metadata = {
|
|
54
|
+
family: :greek_modes,
|
|
55
|
+
brightness: 1,
|
|
56
|
+
character: [:bluesy, :rock, :dominant],
|
|
57
|
+
parent: { scale: :major, degree: 5 }
|
|
58
|
+
}.freeze
|
|
59
|
+
|
|
60
|
+
class << self
|
|
61
|
+
@@pitches =
|
|
62
|
+
[{ functions: %i[I _1 tonic first],
|
|
63
|
+
pitch: 0 },
|
|
64
|
+
{ functions: %i[II _2 supertonic second],
|
|
65
|
+
pitch: 2 },
|
|
66
|
+
{ functions: %i[III _3 mediant third],
|
|
67
|
+
pitch: 4 },
|
|
68
|
+
{ functions: %i[IV _4 subdominant fourth],
|
|
69
|
+
pitch: 5 },
|
|
70
|
+
{ functions: %i[V _5 dominant fifth],
|
|
71
|
+
pitch: 7 },
|
|
72
|
+
{ functions: %i[VI _6 submediant sixth],
|
|
73
|
+
pitch: 9 },
|
|
74
|
+
{ functions: %i[VII _7 subtonic seventh],
|
|
75
|
+
pitch: 10 },
|
|
76
|
+
{ functions: %i[VIII _8 eighth],
|
|
77
|
+
pitch: 12 },
|
|
78
|
+
{ functions: %i[IX _9 ninth],
|
|
79
|
+
pitch: 12 + 2 },
|
|
80
|
+
{ functions: %i[X _10 tenth],
|
|
81
|
+
pitch: 12 + 4 },
|
|
82
|
+
{ functions: %i[XI _11 eleventh],
|
|
83
|
+
pitch: 12 + 5 },
|
|
84
|
+
{ functions: %i[XII _12 twelfth],
|
|
85
|
+
pitch: 12 + 7 },
|
|
86
|
+
{ functions: %i[XIII _13 thirteenth],
|
|
87
|
+
pitch: 12 + 9 }].freeze
|
|
88
|
+
|
|
89
|
+
# Pitch structure.
|
|
90
|
+
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
91
|
+
def pitches
|
|
92
|
+
@@pitches
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
# Number of diatonic degrees.
|
|
96
|
+
# @return [Integer] 7
|
|
97
|
+
def grades
|
|
98
|
+
7
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Scale kind identifier.
|
|
102
|
+
# @return [Symbol] :mixolydian
|
|
103
|
+
def id
|
|
104
|
+
:mixolydian
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
EquallyTempered12ToneScaleSystem.register MixolydianScaleKind
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
end
|