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
|
@@ -1,523 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
#
|
|
18
|
-
# Defines standard interval names using semitone distances:
|
|
19
|
-
#
|
|
20
|
-
# { P0: 0, m2: 1, M2: 2, m3: 3, M3: 4, P4: 5, TT: 6,
|
|
21
|
-
# P5: 7, m6: 8, M6: 9, m7: 10, M7: 11, P8: 12 }
|
|
22
|
-
#
|
|
23
|
-
# @abstract Subclasses must implement {frequency_of_pitch}
|
|
24
|
-
# @see EquallyTempered12ToneScaleSystem Concrete equal temperament implementation
|
|
25
|
-
class TwelveSemitonesScaleSystem < ScaleSystem
|
|
26
|
-
class << self
|
|
27
|
-
@@intervals = { P0: 0, m2: 1, M2: 2, m3: 3, M3: 4, P4: 5, TT: 6, P5: 7, m6: 8, M6: 9, m7: 10, M7: 11, P8: 12 }
|
|
28
|
-
|
|
29
|
-
# System identifier.
|
|
30
|
-
# @return [Symbol] :et12
|
|
31
|
-
def id
|
|
32
|
-
:et12
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# Number of distinct notes per octave.
|
|
36
|
-
# @return [Integer] 12
|
|
37
|
-
def notes_in_octave
|
|
38
|
-
12
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# Size of smallest pitch division.
|
|
42
|
-
# @return [Integer] 1 (semitone)
|
|
43
|
-
def part_of_tone_size
|
|
44
|
-
1
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
# Interval definitions.
|
|
48
|
-
#
|
|
49
|
-
# @return [Hash{Symbol => Integer}] interval name to semitones mapping
|
|
50
|
-
#
|
|
51
|
-
# @example
|
|
52
|
-
# intervals[:P5] # => 7 (perfect fifth)
|
|
53
|
-
# intervals[:M3] # => 4 (major third)
|
|
54
|
-
def intervals
|
|
55
|
-
@@intervals
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
# Equal temperament 12-tone scale system.
|
|
61
|
-
#
|
|
62
|
-
# EquallyTempered12ToneScaleSystem implements the standard equal temperament
|
|
63
|
-
# tuning where each semitone has exactly the same frequency ratio: 2^(1/12).
|
|
64
|
-
# This is the most common tuning system in modern Western music.
|
|
65
|
-
#
|
|
66
|
-
# ## Frequency Calculation
|
|
67
|
-
#
|
|
68
|
-
# Uses the equal temperament formula based on A440 concert pitch:
|
|
69
|
-
#
|
|
70
|
-
# frequency = a_frequency × 2^((pitch - 69) / 12)
|
|
71
|
-
#
|
|
72
|
-
# Where:
|
|
73
|
-
#
|
|
74
|
-
# - **a_frequency**: Reference A frequency (typically 440 Hz)
|
|
75
|
-
# - **pitch**: MIDI pitch number (69 = A4)
|
|
76
|
-
#
|
|
77
|
-
# ## Historical Pitch Standards
|
|
78
|
-
#
|
|
79
|
-
# Different A frequencies represent different historical standards:
|
|
80
|
-
#
|
|
81
|
-
# - **440 Hz**: Modern concert pitch (ISO 16)
|
|
82
|
-
# - **442 Hz**: Used by some orchestras (brighter sound)
|
|
83
|
-
# - **415 Hz**: Baroque pitch (approximately A=415)
|
|
84
|
-
# - **432 Hz**: Alternative tuning (some claim harmonic benefits)
|
|
85
|
-
#
|
|
86
|
-
# ## Registration
|
|
87
|
-
#
|
|
88
|
-
# This system is registered as the default scale system, accessible via:
|
|
89
|
-
#
|
|
90
|
-
# Scales[:et12] # By ID
|
|
91
|
-
# Scales.default_system # As default
|
|
92
|
-
#
|
|
93
|
-
# ## Usage
|
|
94
|
-
#
|
|
95
|
-
# # Get system with standard A440 tuning
|
|
96
|
-
# system = Scales[:et12][440.0]
|
|
97
|
-
#
|
|
98
|
-
# # Get system with baroque tuning
|
|
99
|
-
# baroque = Scales[:et12][415.0]
|
|
100
|
-
#
|
|
101
|
-
# # Access scale kinds
|
|
102
|
-
# c_major = system[:major][60]
|
|
103
|
-
# a_minor = system[:minor][69]
|
|
104
|
-
#
|
|
105
|
-
# @see TwelveSemitonesScaleSystem Abstract base class
|
|
106
|
-
# @see ScaleSystem#frequency_of_pitch Abstract method implemented here
|
|
107
|
-
class EquallyTempered12ToneScaleSystem < TwelveSemitonesScaleSystem
|
|
108
|
-
class << self
|
|
109
|
-
# Calculates frequency for a pitch using equal temperament.
|
|
110
|
-
#
|
|
111
|
-
# Implements the equal temperament tuning formula where each semitone
|
|
112
|
-
# has a frequency ratio of 2^(1/12) ≈ 1.059463.
|
|
113
|
-
#
|
|
114
|
-
# @param pitch [Integer] MIDI pitch number
|
|
115
|
-
# @param _root_pitch [Integer] unused (required by interface)
|
|
116
|
-
# @param a_frequency [Numeric] reference A4 frequency in Hz
|
|
117
|
-
# @return [Float] frequency in Hz
|
|
118
|
-
#
|
|
119
|
-
# @example Standard A440 tuning
|
|
120
|
-
# frequency_of_pitch(69, nil, 440.0) # => 440.0 (A4)
|
|
121
|
-
# frequency_of_pitch(60, nil, 440.0) # => 261.63 (C4, middle C)
|
|
122
|
-
#
|
|
123
|
-
# @example Baroque tuning
|
|
124
|
-
# frequency_of_pitch(69, nil, 415.0) # => 415.0 (A4)
|
|
125
|
-
def frequency_of_pitch(pitch, _root_pitch, a_frequency)
|
|
126
|
-
(a_frequency * Rational(2)**Rational(pitch - 69, 12)).to_f
|
|
127
|
-
end
|
|
128
|
-
end
|
|
129
|
-
|
|
130
|
-
Scales.register EquallyTempered12ToneScaleSystem, default: true
|
|
131
|
-
end
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
# Chromatic scale kind (all 12 semitones).
|
|
135
|
-
#
|
|
136
|
-
# ChromaticScaleKind defines the chromatic scale containing all 12 semitones
|
|
137
|
-
# of the octave. It's used as a fallback for chromatic (non-diatonic) notes
|
|
138
|
-
# and for atonal or twelve-tone compositions.
|
|
139
|
-
#
|
|
140
|
-
# ## Pitch Structure
|
|
141
|
-
#
|
|
142
|
-
# Contains 12 pitch classes, one for each semitone:
|
|
143
|
-
#
|
|
144
|
-
# - Degrees: _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12
|
|
145
|
-
# - Pitches: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 (semitones from root)
|
|
146
|
-
#
|
|
147
|
-
# ## Special Properties
|
|
148
|
-
#
|
|
149
|
-
# - **chromatic?**: Returns true (only scale kind with this property)
|
|
150
|
-
# - Used automatically when accessing non-diatonic notes in diatonic scales
|
|
151
|
-
#
|
|
152
|
-
# ## Usage
|
|
153
|
-
#
|
|
154
|
-
# chromatic = Scales[:et12][440.0][:chromatic][60]
|
|
155
|
-
# chromatic._1 # C
|
|
156
|
-
# chromatic._2 # C#/Db
|
|
157
|
-
# chromatic._3 # D
|
|
158
|
-
# # ... all 12 semitones
|
|
159
|
-
#
|
|
160
|
-
# @see ScaleKind Abstract base class
|
|
161
|
-
# @see MajorScaleKind Major scale (7 notes)
|
|
162
|
-
# @see MinorNaturalScaleKind Minor scale (7 notes)
|
|
163
|
-
class ChromaticScaleKind < ScaleKind
|
|
164
|
-
class << self
|
|
165
|
-
@@pitches =
|
|
166
|
-
[{ functions: [:_1], pitch: 0 },
|
|
167
|
-
{ functions: [:_2], pitch: 1 },
|
|
168
|
-
{ functions: [:_3], pitch: 2 },
|
|
169
|
-
{ functions: [:_4], pitch: 3 },
|
|
170
|
-
{ functions: [:_5], pitch: 4 },
|
|
171
|
-
{ functions: [:_6], pitch: 5 },
|
|
172
|
-
{ functions: [:_7], pitch: 6 },
|
|
173
|
-
{ functions: [:_8], pitch: 7 },
|
|
174
|
-
{ functions: [:_9], pitch: 8 },
|
|
175
|
-
{ functions: [:_10], pitch: 9 },
|
|
176
|
-
{ functions: [:_11], pitch: 10 },
|
|
177
|
-
{ functions: [:_12], pitch: 11 }].freeze
|
|
178
|
-
|
|
179
|
-
# Pitch structure.
|
|
180
|
-
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
181
|
-
def pitches
|
|
182
|
-
@@pitches
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
# Scale kind identifier.
|
|
186
|
-
# @return [Symbol] :chromatic
|
|
187
|
-
def id
|
|
188
|
-
:chromatic
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# Indicates if this is a chromatic scale.
|
|
192
|
-
# @return [Boolean] true
|
|
193
|
-
def chromatic?
|
|
194
|
-
true
|
|
195
|
-
end
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
EquallyTempered12ToneScaleSystem.register ChromaticScaleKind
|
|
199
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Equal temperament 12-tone scale system and scale kinds.
|
|
4
|
+
#
|
|
5
|
+
# This file loads the complete ET12 scale system including:
|
|
6
|
+
# - TwelveSemitonesScaleSystem (base class)
|
|
7
|
+
# - EquallyTempered12ToneScaleSystem (concrete implementation)
|
|
8
|
+
# - All standard scale kinds (chromatic, major, minor, harmonic minor)
|
|
9
|
+
# - All Greek/church modes (dorian, phrygian, lydian, mixolydian, locrian)
|
|
10
|
+
# - Pentatonic scales (major, minor)
|
|
11
|
+
# - Blues scales (blues, blues major)
|
|
12
|
+
# - Symmetric scales (whole tone, diminished)
|
|
13
|
+
# - Melodic minor modes (melodic minor, dorian b2, lydian augmented, etc.)
|
|
14
|
+
# - Harmonic major
|
|
15
|
+
# - Ethnic scales (double harmonic, hungarian minor, phrygian dominant, etc.)
|
|
16
|
+
# - Bebop scales (dominant, major, minor)
|
|
200
17
|
|
|
201
|
-
|
|
202
|
-
#
|
|
203
|
-
# MajorScaleKind defines the major scale, the fundamental scale of Western
|
|
204
|
-
# tonal music. It follows the pattern: W-W-H-W-W-W-H (whole-half steps)
|
|
205
|
-
# or intervals: M2-M2-m2-M2-M2-M2-m2 from the root.
|
|
206
|
-
#
|
|
207
|
-
# ## Pitch Structure
|
|
208
|
-
#
|
|
209
|
-
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
210
|
-
#
|
|
211
|
-
# **Scale Degrees** (Roman numerals, uppercase for major):
|
|
212
|
-
#
|
|
213
|
-
# - **I** (tonic): Root (0 semitones)
|
|
214
|
-
# - **II** (supertonic): Major second (2 semitones)
|
|
215
|
-
# - **III** (mediant): Major third (4 semitones)
|
|
216
|
-
# - **IV** (subdominant): Perfect fourth (5 semitones)
|
|
217
|
-
# - **V** (dominant): Perfect fifth (7 semitones)
|
|
218
|
-
# - **VI** (submediant): Major sixth (9 semitones, relative minor)
|
|
219
|
-
# - **VII** (leading): Major seventh (11 semitones)
|
|
220
|
-
#
|
|
221
|
-
# **Extended degrees** (for extended harmony):
|
|
222
|
-
#
|
|
223
|
-
# - VIII-XIII: Compound intervals (8th, 9th, 10th, 11th, 12th, 13th)
|
|
224
|
-
#
|
|
225
|
-
# ## Function Aliases
|
|
226
|
-
#
|
|
227
|
-
# Each degree has multiple function names:
|
|
228
|
-
#
|
|
229
|
-
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7 (ordinal)
|
|
230
|
-
# - **Roman**: I, II, III, IV, V, VI, VII (harmonic analysis)
|
|
231
|
-
# - **Function**: tonic, supertonic, mediant, subdominant, dominant,
|
|
232
|
-
# submediant, leading
|
|
233
|
-
# - **Ordinal**: first, second, third, fourth, fifth, sixth, seventh
|
|
234
|
-
# - **Special**: relative/relative_minor for VI (relative minor root)
|
|
235
|
-
#
|
|
236
|
-
# ## Usage
|
|
237
|
-
#
|
|
238
|
-
# c_major = Scales[:et12][440.0][:major][60]
|
|
239
|
-
# c_major.tonic # C (60)
|
|
240
|
-
# c_major.dominant # G (67)
|
|
241
|
-
# c_major.VI # A (69) - relative minor root
|
|
242
|
-
# c_major.relative_minor.scale(:minor) # A minor scale
|
|
243
|
-
#
|
|
244
|
-
# @see ScaleKind Abstract base class
|
|
245
|
-
# @see MinorNaturalScaleKind Natural minor scale
|
|
246
|
-
# @see ChromaticScaleKind Chromatic scale
|
|
247
|
-
class MajorScaleKind < ScaleKind
|
|
248
|
-
class << self
|
|
249
|
-
@@pitches =
|
|
250
|
-
[{ functions: %i[I _1 tonic first],
|
|
251
|
-
pitch: 0 },
|
|
252
|
-
{ functions: %i[II _2 supertonic second],
|
|
253
|
-
pitch: 2 },
|
|
254
|
-
{ functions: %i[III _3 mediant third],
|
|
255
|
-
pitch: 4 },
|
|
256
|
-
{ functions: %i[IV _4 subdominant fourth],
|
|
257
|
-
pitch: 5 },
|
|
258
|
-
{ functions: %i[V _5 dominant fifth],
|
|
259
|
-
pitch: 7 },
|
|
260
|
-
{ functions: %i[VI _6 submediant relative relative_minor sixth],
|
|
261
|
-
pitch: 9 },
|
|
262
|
-
{ functions: %i[VII _7 leading seventh],
|
|
263
|
-
pitch: 11 },
|
|
264
|
-
{ functions: %i[VIII _8 eighth],
|
|
265
|
-
pitch: 12 },
|
|
266
|
-
{ functions: %i[IX _9 ninth],
|
|
267
|
-
pitch: 12 + 2 },
|
|
268
|
-
{ functions: %i[X _10 tenth],
|
|
269
|
-
pitch: 12 + 4 },
|
|
270
|
-
{ functions: %i[XI _11 eleventh],
|
|
271
|
-
pitch: 12 + 5 },
|
|
272
|
-
{ functions: %i[XII _12 twelfth],
|
|
273
|
-
pitch: 12 + 7 },
|
|
274
|
-
{ functions: %i[XIII _13 thirteenth],
|
|
275
|
-
pitch: 12 + 9 }].freeze
|
|
276
|
-
|
|
277
|
-
# Pitch structure.
|
|
278
|
-
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
279
|
-
def pitches
|
|
280
|
-
@@pitches
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
# Number of diatonic degrees.
|
|
284
|
-
# @return [Integer] 7
|
|
285
|
-
def grades
|
|
286
|
-
7
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
# Scale kind identifier.
|
|
290
|
-
# @return [Symbol] :major
|
|
291
|
-
def id
|
|
292
|
-
:major
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
|
|
296
|
-
EquallyTempered12ToneScaleSystem.register MajorScaleKind
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
# Natural minor scale kind (Aeolian mode).
|
|
300
|
-
#
|
|
301
|
-
# MinorNaturalScaleKind defines the natural minor scale, parallel to the
|
|
302
|
-
# major scale but with a darker, melancholic character. It follows the
|
|
303
|
-
# pattern: W-H-W-W-H-W-W or intervals: M2-m2-M2-M2-m2-M2-M2 from the root.
|
|
304
|
-
#
|
|
305
|
-
# ## Pitch Structure
|
|
306
|
-
#
|
|
307
|
-
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
308
|
-
#
|
|
309
|
-
# **Scale Degrees** (Roman numerals, lowercase for minor):
|
|
310
|
-
#
|
|
311
|
-
# - **i** (tonic): Root (0 semitones)
|
|
312
|
-
# - **ii** (supertonic): Major second (2 semitones)
|
|
313
|
-
# - **iii** (mediant): Minor third (3 semitones, relative major)
|
|
314
|
-
# - **iv** (subdominant): Perfect fourth (5 semitones)
|
|
315
|
-
# - **v** (dominant): Perfect fifth (7 semitones)
|
|
316
|
-
# - **vi** (submediant): Minor sixth (8 semitones)
|
|
317
|
-
# - **vii** (subtonic): Minor seventh (10 semitones, NOT leading tone)
|
|
318
|
-
#
|
|
319
|
-
# **Extended degrees**: viii-xiii (compound intervals)
|
|
320
|
-
#
|
|
321
|
-
# ## Differences from Major
|
|
322
|
-
#
|
|
323
|
-
# Compared to major scale (same tonic):
|
|
324
|
-
#
|
|
325
|
-
# - **iii**: Flatted third (minor third instead of major)
|
|
326
|
-
# - **vi**: Flatted sixth (minor sixth instead of major)
|
|
327
|
-
# - **vii**: Flatted seventh (minor seventh instead of major)
|
|
328
|
-
#
|
|
329
|
-
# ## Relative Major
|
|
330
|
-
#
|
|
331
|
-
# The **iii** degree is the root of the relative major scale (shares same
|
|
332
|
-
# notes but different tonic). For example:
|
|
333
|
-
#
|
|
334
|
-
# - A minor (natural) relative major: C major
|
|
335
|
-
# - C major relative minor: A minor
|
|
336
|
-
#
|
|
337
|
-
# ## Function Aliases
|
|
338
|
-
#
|
|
339
|
-
# Similar to major but with lowercase Roman numerals:
|
|
340
|
-
#
|
|
341
|
-
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7
|
|
342
|
-
# - **Roman**: i, ii, iii, iv, v, vi, vii
|
|
343
|
-
# - **Function**: tonic, supertonic, mediant, subdominant, dominant, submediant
|
|
344
|
-
# - **Ordinal**: first, second, third, fourth, fifth, sixth, seventh
|
|
345
|
-
# - **Special**: relative/relative_major for iii
|
|
346
|
-
#
|
|
347
|
-
# ## Usage
|
|
348
|
-
#
|
|
349
|
-
# a_minor = Scales[:et12][440.0][:minor][69]
|
|
350
|
-
# a_minor.tonic # A (69)
|
|
351
|
-
# a_minor.dominant # E (76)
|
|
352
|
-
# a_minor.iii # C (72) - relative major root
|
|
353
|
-
# a_minor.relative_major.scale(:major) # C major scale
|
|
354
|
-
#
|
|
355
|
-
# @see ScaleKind Abstract base class
|
|
356
|
-
# @see MajorScaleKind Major scale
|
|
357
|
-
# @see MinorHarmonicScaleKind Harmonic minor (with raised 7th)
|
|
358
|
-
class MinorNaturalScaleKind < ScaleKind
|
|
359
|
-
class << self
|
|
360
|
-
@@pitches =
|
|
361
|
-
[{ functions: %i[i _1 tonic first],
|
|
362
|
-
pitch: 0 },
|
|
363
|
-
{ functions: %i[ii _2 supertonic second],
|
|
364
|
-
pitch: 2 },
|
|
365
|
-
{ functions: %i[iii _3 mediant relative relative_major third],
|
|
366
|
-
pitch: 3 },
|
|
367
|
-
{ functions: %i[iv _4 subdominant fourth],
|
|
368
|
-
pitch: 5 },
|
|
369
|
-
{ functions: %i[v _5 dominant fifth],
|
|
370
|
-
pitch: 7 },
|
|
371
|
-
{ functions: %i[vi _6 submediant sixth],
|
|
372
|
-
pitch: 8 },
|
|
373
|
-
{ functions: %i[vii _7 seventh],
|
|
374
|
-
pitch: 10 },
|
|
375
|
-
{ functions: %i[viii _8 eighth],
|
|
376
|
-
pitch: 12 },
|
|
377
|
-
{ functions: %i[ix _9 ninth],
|
|
378
|
-
pitch: 12 + 2 },
|
|
379
|
-
{ functions: %i[x _10 tenth],
|
|
380
|
-
pitch: 12 + 3 },
|
|
381
|
-
{ functions: %i[xi _11 eleventh],
|
|
382
|
-
pitch: 12 + 5 },
|
|
383
|
-
{ functions: %i[xii _12 twelfth],
|
|
384
|
-
pitch: 12 + 7 },
|
|
385
|
-
{ functions: %i[xiii _13 thirteenth],
|
|
386
|
-
pitch: 12 + 8 }].freeze
|
|
387
|
-
|
|
388
|
-
# Pitch structure.
|
|
389
|
-
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
390
|
-
def pitches
|
|
391
|
-
@@pitches
|
|
392
|
-
end
|
|
393
|
-
|
|
394
|
-
# Number of diatonic degrees.
|
|
395
|
-
# @return [Integer] 7
|
|
396
|
-
def grades
|
|
397
|
-
7
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
# Scale kind identifier.
|
|
401
|
-
# @return [Symbol] :minor
|
|
402
|
-
def id
|
|
403
|
-
:minor
|
|
404
|
-
end
|
|
405
|
-
end
|
|
406
|
-
|
|
407
|
-
EquallyTempered12ToneScaleSystem.register MinorNaturalScaleKind
|
|
408
|
-
end
|
|
409
|
-
|
|
410
|
-
# Harmonic minor scale kind.
|
|
411
|
-
#
|
|
412
|
-
# MinorHarmonicScaleKind defines the harmonic minor scale, a variation of
|
|
413
|
-
# the natural minor with a raised seventh degree. This creates a leading
|
|
414
|
-
# tone (major seventh) that resolves strongly to the tonic, giving the
|
|
415
|
-
# scale a more directed, dramatic character.
|
|
416
|
-
#
|
|
417
|
-
# ## Pitch Structure
|
|
418
|
-
#
|
|
419
|
-
# 7 diatonic degrees plus extended harmony (8th-13th):
|
|
420
|
-
#
|
|
421
|
-
# **Scale Degrees** (Roman numerals, lowercase for minor):
|
|
422
|
-
#
|
|
423
|
-
# - **i** (tonic): Root (0 semitones)
|
|
424
|
-
# - **ii** (supertonic): Major second (2 semitones)
|
|
425
|
-
# - **iii** (mediant): Minor third (3 semitones, relative major)
|
|
426
|
-
# - **iv** (subdominant): Perfect fourth (5 semitones)
|
|
427
|
-
# - **v** (dominant): Perfect fifth (7 semitones)
|
|
428
|
-
# - **vi** (submediant): Minor sixth (8 semitones)
|
|
429
|
-
# - **vii** (leading): **Major seventh** (11 semitones) ← RAISED from natural minor
|
|
430
|
-
#
|
|
431
|
-
# **Extended degrees**: viii-xiii (compound intervals)
|
|
432
|
-
#
|
|
433
|
-
# ## Key Difference from Natural Minor
|
|
434
|
-
#
|
|
435
|
-
# The **vii** degree is raised from 10 semitones (minor seventh) to
|
|
436
|
-
# 11 semitones (major seventh), creating:
|
|
437
|
-
#
|
|
438
|
-
# - A **leading tone** that resolves strongly upward to the tonic
|
|
439
|
-
# - An **augmented second** interval between vi and vii (3 semitones)
|
|
440
|
-
# - A **dominant seventh chord** (v7) with strong resolution to i
|
|
441
|
-
#
|
|
442
|
-
# ## Musical Character
|
|
443
|
-
#
|
|
444
|
-
# The harmonic minor scale:
|
|
445
|
-
#
|
|
446
|
-
# - Maintains minor quality (minor third)
|
|
447
|
-
# - Provides strong dominant-to-tonic resolution
|
|
448
|
-
# - Creates exotic sound due to augmented second (vi-vii)
|
|
449
|
-
# - Common in classical, jazz, and Middle Eastern music
|
|
450
|
-
#
|
|
451
|
-
# ## Function Aliases
|
|
452
|
-
#
|
|
453
|
-
# Same as natural minor:
|
|
454
|
-
#
|
|
455
|
-
# - **Numeric**: _1, _2, _3, _4, _5, _6, _7
|
|
456
|
-
# - **Roman**: i, ii, iii, iv, v, vi, vii
|
|
457
|
-
# - **Function**: tonic, supertonic, mediant, subdominant, dominant,
|
|
458
|
-
# submediant, leading
|
|
459
|
-
# - **Special**: relative/relative_major for iii
|
|
460
|
-
#
|
|
461
|
-
# ## Usage
|
|
462
|
-
#
|
|
463
|
-
# a_harmonic_minor = Scales[:et12][440.0][:minor_harmonic][69]
|
|
464
|
-
# a_harmonic_minor.vii # G# (80) - raised 7th, not G (79)
|
|
465
|
-
# a_harmonic_minor.vi # F (77)
|
|
466
|
-
# # Augmented second: F to G# = 3 semitones
|
|
467
|
-
#
|
|
468
|
-
# @see ScaleKind Abstract base class
|
|
469
|
-
# @see MinorNaturalScaleKind Natural minor (with minor 7th)
|
|
470
|
-
# @see MajorScaleKind Major scale
|
|
471
|
-
class MinorHarmonicScaleKind < ScaleKind
|
|
472
|
-
class << self
|
|
473
|
-
@@pitches =
|
|
474
|
-
[{ functions: %i[i _1 tonic],
|
|
475
|
-
pitch: 0 },
|
|
476
|
-
{ functions: %i[ii _2 supertonic],
|
|
477
|
-
pitch: 2 },
|
|
478
|
-
{ functions: %i[iii _3 mediant relative relative_major],
|
|
479
|
-
pitch: 3 },
|
|
480
|
-
{ functions: %i[iv _4 subdominant],
|
|
481
|
-
pitch: 5 },
|
|
482
|
-
{ functions: %i[v _5 dominant],
|
|
483
|
-
pitch: 7 },
|
|
484
|
-
{ functions: %i[vi _6 submediant],
|
|
485
|
-
pitch: 8 },
|
|
486
|
-
{ functions: %i[vii _7 leading],
|
|
487
|
-
pitch: 11 },
|
|
488
|
-
{ functions: %i[viii _8],
|
|
489
|
-
pitch: 12 },
|
|
490
|
-
{ functions: %i[ix _9],
|
|
491
|
-
pitch: 12 + 2 },
|
|
492
|
-
{ functions: %i[x _10],
|
|
493
|
-
pitch: 12 + 3 },
|
|
494
|
-
{ functions: %i[xi _11],
|
|
495
|
-
pitch: 12 + 5 },
|
|
496
|
-
{ functions: %i[xii _12],
|
|
497
|
-
pitch: 12 + 7 },
|
|
498
|
-
{ functions: %i[xiii _13],
|
|
499
|
-
pitch: 12 + 8 }].freeze
|
|
500
|
-
|
|
501
|
-
# Pitch structure.
|
|
502
|
-
# @return [Array<Hash>] pitch definitions with functions and offsets
|
|
503
|
-
def pitches
|
|
504
|
-
@@pitches
|
|
505
|
-
end
|
|
506
|
-
|
|
507
|
-
# Number of diatonic degrees.
|
|
508
|
-
# @return [Integer] 7
|
|
509
|
-
def grades
|
|
510
|
-
7
|
|
511
|
-
end
|
|
512
|
-
|
|
513
|
-
# Scale kind identifier.
|
|
514
|
-
# @return [Symbol] :minor_harmonic
|
|
515
|
-
def id
|
|
516
|
-
:minor_harmonic
|
|
517
|
-
end
|
|
518
|
-
end
|
|
18
|
+
require_relative 'scales'
|
|
519
19
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
20
|
+
# Scale systems
|
|
21
|
+
require_relative 'scale_systems/twelve_semitones_scale_system'
|
|
22
|
+
require_relative 'scale_systems/equally_tempered_12_tone_scale_system'
|
|
23
|
+
|
|
24
|
+
# Core scale kinds
|
|
25
|
+
require_relative 'scale_kinds/chromatic_scale_kind'
|
|
26
|
+
require_relative 'scale_kinds/major_scale_kind'
|
|
27
|
+
require_relative 'scale_kinds/minor_natural_scale_kind'
|
|
28
|
+
require_relative 'scale_kinds/minor_harmonic_scale_kind'
|
|
29
|
+
|
|
30
|
+
# Greek/church modes
|
|
31
|
+
require_relative 'scale_kinds/modes/dorian_scale_kind'
|
|
32
|
+
require_relative 'scale_kinds/modes/phrygian_scale_kind'
|
|
33
|
+
require_relative 'scale_kinds/modes/lydian_scale_kind'
|
|
34
|
+
require_relative 'scale_kinds/modes/mixolydian_scale_kind'
|
|
35
|
+
require_relative 'scale_kinds/modes/locrian_scale_kind'
|
|
36
|
+
|
|
37
|
+
# Pentatonic scales
|
|
38
|
+
require_relative 'scale_kinds/pentatonic/pentatonic_major_scale_kind'
|
|
39
|
+
require_relative 'scale_kinds/pentatonic/pentatonic_minor_scale_kind'
|
|
40
|
+
|
|
41
|
+
# Blues scales
|
|
42
|
+
require_relative 'scale_kinds/blues/blues_scale_kind'
|
|
43
|
+
require_relative 'scale_kinds/blues/blues_major_scale_kind'
|
|
44
|
+
|
|
45
|
+
# Symmetric scales
|
|
46
|
+
require_relative 'scale_kinds/symmetric/whole_tone_scale_kind'
|
|
47
|
+
require_relative 'scale_kinds/symmetric/diminished_hw_scale_kind'
|
|
48
|
+
require_relative 'scale_kinds/symmetric/diminished_wh_scale_kind'
|
|
49
|
+
|
|
50
|
+
# Melodic minor and modes
|
|
51
|
+
require_relative 'scale_kinds/melodic_minor/melodic_minor_scale_kind'
|
|
52
|
+
require_relative 'scale_kinds/melodic_minor/dorian_b2_scale_kind'
|
|
53
|
+
require_relative 'scale_kinds/melodic_minor/lydian_augmented_scale_kind'
|
|
54
|
+
require_relative 'scale_kinds/melodic_minor/lydian_dominant_scale_kind'
|
|
55
|
+
require_relative 'scale_kinds/melodic_minor/mixolydian_b6_scale_kind'
|
|
56
|
+
require_relative 'scale_kinds/melodic_minor/locrian_sharp2_scale_kind'
|
|
57
|
+
require_relative 'scale_kinds/melodic_minor/altered_scale_kind'
|
|
58
|
+
|
|
59
|
+
# Harmonic major
|
|
60
|
+
require_relative 'scale_kinds/harmonic_major/harmonic_major_scale_kind'
|
|
61
|
+
|
|
62
|
+
# Ethnic/exotic scales
|
|
63
|
+
require_relative 'scale_kinds/ethnic/double_harmonic_scale_kind'
|
|
64
|
+
require_relative 'scale_kinds/ethnic/hungarian_minor_scale_kind'
|
|
65
|
+
require_relative 'scale_kinds/ethnic/phrygian_dominant_scale_kind'
|
|
66
|
+
require_relative 'scale_kinds/ethnic/neapolitan_minor_scale_kind'
|
|
67
|
+
require_relative 'scale_kinds/ethnic/neapolitan_major_scale_kind'
|
|
68
|
+
|
|
69
|
+
# Bebop scales
|
|
70
|
+
require_relative 'scale_kinds/bebop/bebop_dominant_scale_kind'
|
|
71
|
+
require_relative 'scale_kinds/bebop/bebop_major_scale_kind'
|
|
72
|
+
require_relative 'scale_kinds/bebop/bebop_minor_scale_kind'
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Musa
|
|
4
|
+
module Scales
|
|
5
|
+
# Bebop dominant scale kind.
|
|
6
|
+
#
|
|
7
|
+
# BebopDominantScaleKind defines the bebop dominant scale, an eight-note
|
|
8
|
+
# scale that adds a chromatic passing tone (major 7th) to the Mixolydian
|
|
9
|
+
# mode. This allows chord tones to fall on downbeats during eighth-note runs.
|
|
10
|
+
#
|
|
11
|
+
# ## Pitch Structure
|
|
12
|
+
#
|
|
13
|
+
# 8 degrees plus extended:
|
|
14
|
+
#
|
|
15
|
+
# **Scale Degrees** (uppercase for major quality):
|
|
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)
|
|
24
|
+
# - **VII#** (leading): Major seventh (11 semitones) ← PASSING TONE
|
|
25
|
+
#
|
|
26
|
+
# ## Bebop Principle
|
|
27
|
+
#
|
|
28
|
+
# The added chromatic note ensures that:
|
|
29
|
+
# - Chord tones (1, 3, 5, b7) fall on strong beats
|
|
30
|
+
# - Non-chord tones fall on weak beats
|
|
31
|
+
# - Creates smooth voice leading at tempo
|
|
32
|
+
#
|
|
33
|
+
# ## Musical Character
|
|
34
|
+
#
|
|
35
|
+
# The bebop dominant scale:
|
|
36
|
+
#
|
|
37
|
+
# - Essential for jazz improvisation over dominant 7th chords
|
|
38
|
+
# - Creates characteristic bebop sound at fast tempos
|
|
39
|
+
# - Used by Charlie Parker, Dizzy Gillespie, and bebop masters
|
|
40
|
+
#
|
|
41
|
+
# ## Usage
|
|
42
|
+
#
|
|
43
|
+
# g_bebop = Scales[:et12][440.0][:bebop_dominant][67]
|
|
44
|
+
# g_bebop[0].pitch # G (67) - root
|
|
45
|
+
# g_bebop[6].pitch # F (77) - minor 7th
|
|
46
|
+
# g_bebop[7].pitch # F# (78) - major 7th (chromatic passing)
|
|
47
|
+
#
|
|
48
|
+
# @see ScaleKind Abstract base class
|
|
49
|
+
# @see MixolydianScaleKind Mixolydian (7-note parent)
|
|
50
|
+
# @see BebopMajorScaleKind Bebop major scale
|
|
51
|
+
class BebopDominantScaleKind < ScaleKind
|
|
52
|
+
@base_metadata = {
|
|
53
|
+
family: :bebop,
|
|
54
|
+
brightness: 1,
|
|
55
|
+
character: [:jazz, :chromatic_passing, :dominant],
|
|
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: 9 },
|
|
73
|
+
{ functions: %i[VII _7 subtonic seventh],
|
|
74
|
+
pitch: 10 },
|
|
75
|
+
{ functions: %i[VII# _8 leading eighth],
|
|
76
|
+
pitch: 11 },
|
|
77
|
+
{ functions: %i[VIII _9 ninth],
|
|
78
|
+
pitch: 12 },
|
|
79
|
+
{ functions: %i[IX _10 tenth],
|
|
80
|
+
pitch: 12 + 2 },
|
|
81
|
+
{ functions: %i[X _11 eleventh],
|
|
82
|
+
pitch: 12 + 4 },
|
|
83
|
+
{ functions: %i[XI _12 twelfth],
|
|
84
|
+
pitch: 12 + 5 },
|
|
85
|
+
{ functions: %i[XII _13 thirteenth],
|
|
86
|
+
pitch: 12 + 7 },
|
|
87
|
+
{ functions: %i[XIII _14 fourteenth],
|
|
88
|
+
pitch: 12 + 9 },
|
|
89
|
+
{ functions: %i[XIV _15 fifteenth],
|
|
90
|
+
pitch: 12 + 10 },
|
|
91
|
+
{ functions: %i[XV _16 sixteenth],
|
|
92
|
+
pitch: 12 + 11 }].freeze
|
|
93
|
+
|
|
94
|
+
def pitches
|
|
95
|
+
@@pitches
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def grades
|
|
99
|
+
8
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def id
|
|
103
|
+
:bebop_dominant
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
EquallyTempered12ToneScaleSystem.register BebopDominantScaleKind
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|