musa-dsl 0.30.2 → 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.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -1
  3. data/.version +6 -0
  4. data/.yardopts +7 -0
  5. data/Gemfile +0 -1
  6. data/README.md +227 -6
  7. data/docs/README.md +83 -0
  8. data/docs/api-reference.md +86 -0
  9. data/docs/getting-started/quick-start.md +93 -0
  10. data/docs/getting-started/tutorial.md +58 -0
  11. data/docs/subsystems/core-extensions.md +316 -0
  12. data/docs/subsystems/datasets.md +465 -0
  13. data/docs/subsystems/generative.md +290 -0
  14. data/docs/subsystems/matrix.md +63 -0
  15. data/docs/subsystems/midi.md +123 -0
  16. data/docs/subsystems/music.md +544 -0
  17. data/docs/subsystems/musicxml-builder.md +264 -0
  18. data/docs/subsystems/neumas.md +71 -0
  19. data/docs/subsystems/repl.md +135 -0
  20. data/docs/subsystems/sequencer.md +98 -0
  21. data/docs/subsystems/series.md +302 -0
  22. data/docs/subsystems/transcription.md +152 -0
  23. data/docs/subsystems/transport.md +177 -0
  24. data/lib/musa-dsl/core-ext/array-explode-ranges.rb +68 -0
  25. data/lib/musa-dsl/core-ext/arrayfy.rb +110 -0
  26. data/lib/musa-dsl/core-ext/attribute-builder.rb +91 -30
  27. data/lib/musa-dsl/core-ext/deep-copy.rb +125 -2
  28. data/lib/musa-dsl/core-ext/dynamic-proxy.rb +78 -0
  29. data/lib/musa-dsl/core-ext/extension.rb +53 -0
  30. data/lib/musa-dsl/core-ext/hashify.rb +162 -1
  31. data/lib/musa-dsl/core-ext/inspect-nice.rb +154 -0
  32. data/lib/musa-dsl/core-ext/smart-proc-binder.rb +117 -0
  33. data/lib/musa-dsl/core-ext/with.rb +114 -0
  34. data/lib/musa-dsl/datasets/dataset.rb +109 -0
  35. data/lib/musa-dsl/datasets/delta-d.rb +78 -0
  36. data/lib/musa-dsl/datasets/e.rb +186 -2
  37. data/lib/musa-dsl/datasets/gdv.rb +279 -2
  38. data/lib/musa-dsl/datasets/gdvd.rb +201 -0
  39. data/lib/musa-dsl/datasets/helper.rb +75 -0
  40. data/lib/musa-dsl/datasets/p.rb +177 -2
  41. data/lib/musa-dsl/datasets/packed-v.rb +91 -0
  42. data/lib/musa-dsl/datasets/pdv.rb +136 -1
  43. data/lib/musa-dsl/datasets/ps.rb +134 -4
  44. data/lib/musa-dsl/datasets/score/queriable.rb +143 -1
  45. data/lib/musa-dsl/datasets/score/render.rb +105 -1
  46. data/lib/musa-dsl/datasets/score/to-mxml/process-pdv.rb +138 -1
  47. data/lib/musa-dsl/datasets/score/to-mxml/process-ps.rb +111 -0
  48. data/lib/musa-dsl/datasets/score/to-mxml/process-time.rb +200 -1
  49. data/lib/musa-dsl/datasets/score/to-mxml/to-mxml.rb +145 -1
  50. data/lib/musa-dsl/datasets/score.rb +279 -0
  51. data/lib/musa-dsl/datasets/v.rb +88 -0
  52. data/lib/musa-dsl/generative/darwin.rb +215 -1
  53. data/lib/musa-dsl/generative/generative-grammar.rb +387 -0
  54. data/lib/musa-dsl/generative/markov.rb +135 -3
  55. data/lib/musa-dsl/generative/rules.rb +312 -4
  56. data/lib/musa-dsl/generative/variatio.rb +286 -2
  57. data/lib/musa-dsl/logger/logger.rb +267 -2
  58. data/lib/musa-dsl/matrix/matrix.rb +256 -10
  59. data/lib/musa-dsl/midi/midi-recorder.rb +113 -2
  60. data/lib/musa-dsl/midi/midi-voices.rb +275 -4
  61. data/lib/musa-dsl/music/chord-definition.rb +233 -1
  62. data/lib/musa-dsl/music/chord-definitions.rb +33 -6
  63. data/lib/musa-dsl/music/chords.rb +353 -2
  64. data/lib/musa-dsl/music/equally-tempered-12-tone-scale-system.rb +70 -206
  65. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_dominant_scale_kind.rb +110 -0
  66. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_major_scale_kind.rb +110 -0
  67. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_minor_scale_kind.rb +110 -0
  68. data/lib/musa-dsl/music/scale_kinds/blues/blues_major_scale_kind.rb +100 -0
  69. data/lib/musa-dsl/music/scale_kinds/blues/blues_scale_kind.rb +99 -0
  70. data/lib/musa-dsl/music/scale_kinds/chromatic_scale_kind.rb +79 -0
  71. data/lib/musa-dsl/music/scale_kinds/ethnic/double_harmonic_scale_kind.rb +102 -0
  72. data/lib/musa-dsl/music/scale_kinds/ethnic/hungarian_minor_scale_kind.rb +102 -0
  73. data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_major_scale_kind.rb +102 -0
  74. data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_minor_scale_kind.rb +101 -0
  75. data/lib/musa-dsl/music/scale_kinds/ethnic/phrygian_dominant_scale_kind.rb +103 -0
  76. data/lib/musa-dsl/music/scale_kinds/harmonic_major/harmonic_major_scale_kind.rb +104 -0
  77. data/lib/musa-dsl/music/scale_kinds/major_scale_kind.rb +110 -0
  78. data/lib/musa-dsl/music/scale_kinds/melodic_minor/altered_scale_kind.rb +106 -0
  79. data/lib/musa-dsl/music/scale_kinds/melodic_minor/dorian_b2_scale_kind.rb +104 -0
  80. data/lib/musa-dsl/music/scale_kinds/melodic_minor/locrian_sharp2_scale_kind.rb +103 -0
  81. data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_augmented_scale_kind.rb +103 -0
  82. data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_dominant_scale_kind.rb +106 -0
  83. data/lib/musa-dsl/music/scale_kinds/melodic_minor/melodic_minor_scale_kind.rb +104 -0
  84. data/lib/musa-dsl/music/scale_kinds/melodic_minor/mixolydian_b6_scale_kind.rb +103 -0
  85. data/lib/musa-dsl/music/scale_kinds/minor_harmonic_scale_kind.rb +125 -0
  86. data/lib/musa-dsl/music/scale_kinds/minor_natural_scale_kind.rb +123 -0
  87. data/lib/musa-dsl/music/scale_kinds/modes/dorian_scale_kind.rb +111 -0
  88. data/lib/musa-dsl/music/scale_kinds/modes/locrian_scale_kind.rb +114 -0
  89. data/lib/musa-dsl/music/scale_kinds/modes/lydian_scale_kind.rb +111 -0
  90. data/lib/musa-dsl/music/scale_kinds/modes/mixolydian_scale_kind.rb +111 -0
  91. data/lib/musa-dsl/music/scale_kinds/modes/phrygian_scale_kind.rb +111 -0
  92. data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_major_scale_kind.rb +93 -0
  93. data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_minor_scale_kind.rb +99 -0
  94. data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_hw_scale_kind.rb +110 -0
  95. data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_wh_scale_kind.rb +110 -0
  96. data/lib/musa-dsl/music/scale_kinds/symmetric/whole_tone_scale_kind.rb +99 -0
  97. data/lib/musa-dsl/music/scale_systems/equally_tempered_12_tone_scale_system.rb +80 -0
  98. data/lib/musa-dsl/music/scale_systems/twelve_semitones_scale_system.rb +60 -0
  99. data/lib/musa-dsl/music/scales.rb +1384 -40
  100. data/lib/musa-dsl/musicxml/builder/attributes.rb +483 -3
  101. data/lib/musa-dsl/musicxml/builder/backup-forward.rb +166 -1
  102. data/lib/musa-dsl/musicxml/builder/direction.rb +243 -0
  103. data/lib/musa-dsl/musicxml/builder/helper.rb +240 -0
  104. data/lib/musa-dsl/musicxml/builder/measure.rb +284 -0
  105. data/lib/musa-dsl/musicxml/builder/note-complexities.rb +324 -8
  106. data/lib/musa-dsl/musicxml/builder/note.rb +285 -0
  107. data/lib/musa-dsl/musicxml/builder/part-group.rb +108 -1
  108. data/lib/musa-dsl/musicxml/builder/part.rb +139 -0
  109. data/lib/musa-dsl/musicxml/builder/pitched-note.rb +124 -0
  110. data/lib/musa-dsl/musicxml/builder/rest.rb +93 -0
  111. data/lib/musa-dsl/musicxml/builder/score-partwise.rb +276 -0
  112. data/lib/musa-dsl/musicxml/builder/typed-text.rb +62 -1
  113. data/lib/musa-dsl/musicxml/builder/unpitched-note.rb +83 -0
  114. data/lib/musa-dsl/neumalang/neumalang.rb +675 -0
  115. data/lib/musa-dsl/neumas/array-to-neumas.rb +149 -0
  116. data/lib/musa-dsl/neumas/neuma-decoder.rb +253 -0
  117. data/lib/musa-dsl/neumas/neuma-gdv-decoder.rb +142 -2
  118. data/lib/musa-dsl/neumas/neuma-gdvd-decoder.rb +82 -0
  119. data/lib/musa-dsl/neumas/neumas.rb +67 -0
  120. data/lib/musa-dsl/neumas/string-to-neumas.rb +233 -1
  121. data/lib/musa-dsl/repl/repl.rb +550 -0
  122. data/lib/musa-dsl/sequencer/base-sequencer-implementation-every.rb +118 -2
  123. data/lib/musa-dsl/sequencer/base-sequencer-implementation-move.rb +149 -2
  124. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-helper.rb +296 -0
  125. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play-timed.rb +88 -2
  126. data/lib/musa-dsl/sequencer/base-sequencer-implementation-play.rb +161 -0
  127. data/lib/musa-dsl/sequencer/base-sequencer-implementation.rb +263 -0
  128. data/lib/musa-dsl/sequencer/base-sequencer-tick-based.rb +173 -1
  129. data/lib/musa-dsl/sequencer/base-sequencer-tickless-based.rb +177 -0
  130. data/lib/musa-dsl/sequencer/base-sequencer.rb +710 -10
  131. data/lib/musa-dsl/sequencer/sequencer-dsl.rb +210 -0
  132. data/lib/musa-dsl/sequencer/timeslots.rb +79 -0
  133. data/lib/musa-dsl/series/array-to-serie.rb +37 -1
  134. data/lib/musa-dsl/series/base-series.rb +843 -5
  135. data/lib/musa-dsl/series/buffer-serie.rb +54 -0
  136. data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +64 -0
  137. data/lib/musa-dsl/series/main-serie-constructors.rb +398 -2
  138. data/lib/musa-dsl/series/main-serie-operations.rb +538 -16
  139. data/lib/musa-dsl/series/proxy-serie.rb +67 -0
  140. data/lib/musa-dsl/series/quantizer-serie.rb +57 -7
  141. data/lib/musa-dsl/series/queue-serie.rb +78 -0
  142. data/lib/musa-dsl/series/series-composer.rb +701 -0
  143. data/lib/musa-dsl/series/timed-serie.rb +473 -28
  144. data/lib/musa-dsl/transcription/from-gdv-to-midi.rb +404 -1
  145. data/lib/musa-dsl/transcription/from-gdv-to-musicxml.rb +118 -0
  146. data/lib/musa-dsl/transcription/from-gdv.rb +84 -1
  147. data/lib/musa-dsl/transcription/transcription.rb +265 -0
  148. data/lib/musa-dsl/transport/clock.rb +125 -0
  149. data/lib/musa-dsl/transport/dummy-clock.rb +89 -2
  150. data/lib/musa-dsl/transport/external-tick-clock.rb +91 -0
  151. data/lib/musa-dsl/transport/input-midi-clock.rb +133 -1
  152. data/lib/musa-dsl/transport/timer-clock.rb +183 -1
  153. data/lib/musa-dsl/transport/timer.rb +83 -0
  154. data/lib/musa-dsl/transport/transport.rb +318 -0
  155. data/lib/musa-dsl/version.rb +2 -1
  156. data/lib/musa-dsl.rb +132 -25
  157. data/musa-dsl.gemspec +25 -18
  158. metadata +158 -16
@@ -0,0 +1,106 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Lydian dominant scale kind (fourth mode of melodic minor).
6
+ #
7
+ # LydianDominantScaleKind defines the Lydian dominant scale (also called
8
+ # Lydian b7, Overtone scale, or Bartók scale), the fourth mode of the
9
+ # melodic minor scale. It combines the Lydian's raised fourth with a
10
+ # dominant seventh.
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): Augmented fourth (6 semitones) ← LYDIAN (#4)
22
+ # - **V** (dominant): Perfect fifth (7 semitones)
23
+ # - **VI** (submediant): Major sixth (9 semitones)
24
+ # - **VII** (subtonic): Minor seventh (10 semitones) ← DOMINANT (b7)
25
+ #
26
+ # ## Relationship to Other Modes
27
+ #
28
+ # - Lydian with lowered 7th
29
+ # - Mixolydian with raised 4th
30
+ # - 4th mode of melodic minor
31
+ # - Matches the harmonic series closely
32
+ #
33
+ # ## Musical Character
34
+ #
35
+ # The Lydian dominant scale:
36
+ #
37
+ # - Bright but with dominant tension
38
+ # - Used over 7#11 chords
39
+ # - Common in jazz, Béla Bartók's music
40
+ # - Creates sophisticated dominant sound
41
+ #
42
+ # ## Usage
43
+ #
44
+ # f_lyd_dom = Scales[:et12][440.0][:lydian_dominant][65]
45
+ # f_lyd_dom.tonic # F (65)
46
+ # f_lyd_dom.IV # B (71) - augmented fourth
47
+ # f_lyd_dom.VII # Eb (75) - minor seventh
48
+ #
49
+ # @see ScaleKind Abstract base class
50
+ # @see LydianScaleKind Lydian mode (with major 7th)
51
+ # @see MixolydianScaleKind Mixolydian mode (with perfect 4th)
52
+ # @see MelodicMinorScaleKind Parent melodic minor scale
53
+ class LydianDominantScaleKind < ScaleKind
54
+ @base_metadata = {
55
+ family: :melodic_minor_modes,
56
+ brightness: 1,
57
+ character: [:bright, :dominant, :fusion],
58
+ parent: { scale: :minor_melodic, degree: 4 }
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: 2 },
67
+ { functions: %i[III _3 mediant third],
68
+ pitch: 4 },
69
+ { functions: %i[IV _4 subdominant fourth],
70
+ pitch: 6 },
71
+ { functions: %i[V _5 dominant fifth],
72
+ pitch: 7 },
73
+ { functions: %i[VI _6 submediant sixth],
74
+ pitch: 9 },
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 + 2 },
81
+ { functions: %i[X _10 tenth],
82
+ pitch: 12 + 4 },
83
+ { functions: %i[XI _11 eleventh],
84
+ pitch: 12 + 6 },
85
+ { functions: %i[XII _12 twelfth],
86
+ pitch: 12 + 7 },
87
+ { functions: %i[XIII _13 thirteenth],
88
+ pitch: 12 + 9 }].freeze
89
+
90
+ def pitches
91
+ @@pitches
92
+ end
93
+
94
+ def grades
95
+ 7
96
+ end
97
+
98
+ def id
99
+ :lydian_dominant
100
+ end
101
+ end
102
+
103
+ EquallyTempered12ToneScaleSystem.register LydianDominantScaleKind
104
+ end
105
+ end
106
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Melodic minor scale kind (ascending form).
6
+ #
7
+ # MelodicMinorScaleKind defines the melodic minor scale in its ascending
8
+ # form (also called jazz minor). It has a minor third but major sixth and
9
+ # seventh, creating a unique hybrid between minor and major qualities.
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): Major second (2 semitones)
19
+ # - **iii** (mediant): Minor third (3 semitones) ← MINOR
20
+ # - **iv** (subdominant): Perfect fourth (5 semitones)
21
+ # - **v** (dominant): Perfect fifth (7 semitones)
22
+ # - **vi** (submediant): Major sixth (9 semitones) ← MAJOR
23
+ # - **vii** (leading): Major seventh (11 semitones) ← MAJOR
24
+ #
25
+ # ## Relationship to Other Scales
26
+ #
27
+ # - Minor third (like natural minor)
28
+ # - Major 6th and 7th (like major scale)
29
+ # - Parent scale for many jazz modes (Lydian Dominant, Altered, etc.)
30
+ #
31
+ # ## Musical Character
32
+ #
33
+ # The melodic minor scale:
34
+ #
35
+ # - Minor quality with major upper structure
36
+ # - Essential in jazz harmony
37
+ # - Less dark than harmonic minor (no augmented 2nd)
38
+ # - Smooth melodic contour
39
+ #
40
+ # ## Usage
41
+ #
42
+ # c_mel_min = Scales[:et12][440.0][:minor_melodic][60]
43
+ # c_mel_min.tonic # C (60)
44
+ # c_mel_min.mediant # Eb (63) - minor third
45
+ # c_mel_min.leading # B (71) - major seventh
46
+ #
47
+ # @see ScaleKind Abstract base class
48
+ # @see MinorNaturalScaleKind Natural minor
49
+ # @see MinorHarmonicScaleKind Harmonic minor
50
+ # @see AlteredScaleKind Altered scale (7th mode of melodic minor)
51
+ class MelodicMinorScaleKind < ScaleKind
52
+ @base_metadata = {
53
+ family: :melodic_minor_modes,
54
+ brightness: -1,
55
+ character: [:minor, :ascending, :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: 3 },
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 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 + 3 },
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
+ def pitches
89
+ @@pitches
90
+ end
91
+
92
+ def grades
93
+ 7
94
+ end
95
+
96
+ def id
97
+ :minor_melodic
98
+ end
99
+ end
100
+
101
+ EquallyTempered12ToneScaleSystem.register MelodicMinorScaleKind
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Mixolydian b6 scale kind (fifth mode of melodic minor).
6
+ #
7
+ # MixolydianB6ScaleKind defines the Mixolydian b6 scale (also called
8
+ # Melodic Major, Hindu scale, or Aeolian Dominant), the fifth mode of
9
+ # the melodic minor scale. It combines the Mixolydian's major quality
10
+ # with a minor sixth.
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** (subtonic): Minor seventh (10 semitones)
25
+ #
26
+ # ## Relationship to Other Modes
27
+ #
28
+ # - Mixolydian with lowered 6th
29
+ # - Major scale with b6 and b7
30
+ # - 5th mode of melodic minor
31
+ #
32
+ # ## Musical Character
33
+ #
34
+ # The Mixolydian b6 scale:
35
+ #
36
+ # - Melancholic major quality
37
+ # - Used over dominant 7th with b13 (V7b13)
38
+ # - Creates a beautiful tension in the upper structure
39
+ # - Common in jazz and contemporary music
40
+ #
41
+ # ## Usage
42
+ #
43
+ # g_mix_b6 = Scales[:et12][440.0][:mixolydian_b6][67]
44
+ # g_mix_b6.tonic # G (67)
45
+ # g_mix_b6.VI # Eb (75) - minor sixth
46
+ #
47
+ # @see ScaleKind Abstract base class
48
+ # @see MixolydianScaleKind Mixolydian mode (with major 6th)
49
+ # @see MelodicMinorScaleKind Parent melodic minor scale
50
+ class MixolydianB6ScaleKind < ScaleKind
51
+ @base_metadata = {
52
+ family: :melodic_minor_modes,
53
+ brightness: 0,
54
+ character: [:hindu, :dominant, :melodic],
55
+ parent: { scale: :minor_melodic, 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: 2 },
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 + 2 },
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
+ :mixolydian_b6
97
+ end
98
+ end
99
+
100
+ EquallyTempered12ToneScaleSystem.register MixolydianB6ScaleKind
101
+ end
102
+ end
103
+ end
@@ -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