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,99 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Blues scale kind (minor blues).
6
+ #
7
+ # BluesScaleKind defines the blues scale, a six-note scale that adds
8
+ # the "blue note" (b5) to the minor pentatonic scale. This is the
9
+ # quintessential scale for blues, rock, and jazz improvisation.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 6 degrees plus extended:
14
+ #
15
+ # **Scale Degrees** (lowercase for minor quality):
16
+ #
17
+ # - **i** (tonic): Root (0 semitones)
18
+ # - **iii** (mediant): Minor third (3 semitones)
19
+ # - **iv** (subdominant): Perfect fourth (5 semitones)
20
+ # - **blue** (blue note): Diminished fifth (6 semitones) ← CHARACTERISTIC
21
+ # - **v** (dominant): Perfect fifth (7 semitones)
22
+ # - **vii** (subtonic): Minor seventh (10 semitones)
23
+ #
24
+ # ## The Blue Note
25
+ #
26
+ # The b5 (diminished fifth) is the defining characteristic of the blues
27
+ # scale. It creates tension that resolves either up to the 5th or down
28
+ # to the 4th, giving the scale its distinctive "bluesy" sound.
29
+ #
30
+ # ## Musical Character
31
+ #
32
+ # The blues scale:
33
+ #
34
+ # - Foundation of blues improvisation
35
+ # - Works over minor, dominant 7th, and even major chords
36
+ # - The blue note adds expressive tension
37
+ # - Common in blues, rock, jazz, and funk
38
+ #
39
+ # ## Usage
40
+ #
41
+ # a_blues = Scales[:et12][440.0][:blues][69]
42
+ # a_blues.tonic # A (69)
43
+ # a_blues.blue # Eb (75) - the blue note
44
+ #
45
+ # @see ScaleKind Abstract base class
46
+ # @see PentatonicMinorScaleKind Minor pentatonic (without blue note)
47
+ # @see BluesMajorScaleKind Major blues scale
48
+ class BluesScaleKind < ScaleKind
49
+ @base_metadata = {
50
+ family: :blues,
51
+ brightness: -1,
52
+ character: [:bluesy, :soulful, :minor],
53
+ parent: nil
54
+ }.freeze
55
+
56
+ class << self
57
+ @@pitches =
58
+ [{ functions: %i[i _1 tonic first],
59
+ pitch: 0 },
60
+ { functions: %i[iii _2 mediant second],
61
+ pitch: 3 },
62
+ { functions: %i[iv _3 subdominant third],
63
+ pitch: 5 },
64
+ { functions: %i[blue _4 fourth],
65
+ pitch: 6 },
66
+ { functions: %i[v _5 dominant fifth],
67
+ pitch: 7 },
68
+ { functions: %i[vii _6 subtonic sixth],
69
+ pitch: 10 },
70
+ { functions: %i[viii _7 seventh],
71
+ pitch: 12 },
72
+ { functions: %i[x _8 eighth],
73
+ pitch: 12 + 3 },
74
+ { functions: %i[xi _9 ninth],
75
+ pitch: 12 + 5 },
76
+ { functions: %i[blue2 _10 tenth],
77
+ pitch: 12 + 6 },
78
+ { functions: %i[xii _11 eleventh],
79
+ pitch: 12 + 7 },
80
+ { functions: %i[xiv _12 twelfth],
81
+ pitch: 12 + 10 }].freeze
82
+
83
+ def pitches
84
+ @@pitches
85
+ end
86
+
87
+ def grades
88
+ 6
89
+ end
90
+
91
+ def id
92
+ :blues
93
+ end
94
+ end
95
+
96
+ EquallyTempered12ToneScaleSystem.register BluesScaleKind
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,79 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Chromatic scale kind (all 12 semitones).
6
+ #
7
+ # ChromaticScaleKind defines the chromatic scale containing all 12 semitones
8
+ # of the octave. It's used as a fallback for chromatic (non-diatonic) notes
9
+ # and for atonal or twelve-tone compositions.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # Contains 12 pitch classes, one for each semitone:
14
+ #
15
+ # - Degrees: _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12
16
+ # - Pitches: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 (semitones from root)
17
+ #
18
+ # ## Special Properties
19
+ #
20
+ # - **chromatic?**: Returns true (only scale kind with this property)
21
+ # - Used automatically when accessing non-diatonic notes in diatonic scales
22
+ #
23
+ # ## Usage
24
+ #
25
+ # chromatic = Scales[:et12][440.0][:chromatic][60]
26
+ # chromatic._1 # C
27
+ # chromatic._2 # C#/Db
28
+ # chromatic._3 # D
29
+ # # ... all 12 semitones
30
+ #
31
+ # @see ScaleKind Abstract base class
32
+ # @see MajorScaleKind Major scale (7 notes)
33
+ # @see MinorNaturalScaleKind Minor scale (7 notes)
34
+ class ChromaticScaleKind < ScaleKind
35
+ @base_metadata = {
36
+ family: :chromatic,
37
+ brightness: nil,
38
+ character: [:atonal, :all_notes],
39
+ parent: nil
40
+ }.freeze
41
+
42
+ class << self
43
+ @@pitches =
44
+ [{ functions: [:_1], pitch: 0 },
45
+ { functions: [:_2], pitch: 1 },
46
+ { functions: [:_3], pitch: 2 },
47
+ { functions: [:_4], pitch: 3 },
48
+ { functions: [:_5], pitch: 4 },
49
+ { functions: [:_6], pitch: 5 },
50
+ { functions: [:_7], pitch: 6 },
51
+ { functions: [:_8], pitch: 7 },
52
+ { functions: [:_9], pitch: 8 },
53
+ { functions: [:_10], pitch: 9 },
54
+ { functions: [:_11], pitch: 10 },
55
+ { functions: [:_12], pitch: 11 }].freeze
56
+
57
+ # Pitch structure.
58
+ # @return [Array<Hash>] pitch definitions with functions and offsets
59
+ def pitches
60
+ @@pitches
61
+ end
62
+
63
+ # Scale kind identifier.
64
+ # @return [Symbol] :chromatic
65
+ def id
66
+ :chromatic
67
+ end
68
+
69
+ # Indicates if this is a chromatic scale.
70
+ # @return [Boolean] true
71
+ def chromatic?
72
+ true
73
+ end
74
+ end
75
+
76
+ EquallyTempered12ToneScaleSystem.register ChromaticScaleKind
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Double harmonic scale kind (Byzantine scale).
6
+ #
7
+ # DoubleHarmonicScaleKind defines the double harmonic scale (also called
8
+ # Byzantine scale, Arabic scale, or Gypsy Major), characterized by two
9
+ # augmented seconds that create an exotic, Middle Eastern sound.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 7 diatonic degrees plus extended harmony:
14
+ #
15
+ # **Scale Degrees** (uppercase for major quality):
16
+ #
17
+ # - **I** (tonic): Root (0 semitones)
18
+ # - **II** (supertonic): Minor second (1 semitone) ← CHARACTERISTIC
19
+ # - **III** (mediant): Major third (4 semitones)
20
+ # - **IV** (subdominant): Perfect fourth (5 semitones)
21
+ # - **V** (dominant): Perfect fifth (7 semitones)
22
+ # - **VI** (submediant): Minor sixth (8 semitones) ← CHARACTERISTIC
23
+ # - **VII** (leading): Major seventh (11 semitones)
24
+ #
25
+ # ## Two Augmented Seconds
26
+ #
27
+ # - Between II and III (b2 to 3): 3 semitones
28
+ # - Between VI and VII (b6 to 7): 3 semitones
29
+ #
30
+ # ## Musical Character
31
+ #
32
+ # The double harmonic scale:
33
+ #
34
+ # - Strongly Middle Eastern/Byzantine sound
35
+ # - Two exotic augmented second intervals
36
+ # - Major quality with dramatic colorations
37
+ # - Used in Arabic, Turkish, Greek, and Indian music
38
+ #
39
+ # ## Usage
40
+ #
41
+ # c_dbl_harm = Scales[:et12][440.0][:double_harmonic][60]
42
+ # c_dbl_harm.tonic # C (60)
43
+ # c_dbl_harm.II # Db (61) - minor second
44
+ # c_dbl_harm.III # E (64) - major third (augmented second above)
45
+ #
46
+ # @see ScaleKind Abstract base class
47
+ # @see PhrygianDominantScaleKind Spanish Phrygian (similar exotic quality)
48
+ # @see HungarianMinorScaleKind Hungarian minor
49
+ class DoubleHarmonicScaleKind < ScaleKind
50
+ @base_metadata = {
51
+ family: :ethnic,
52
+ brightness: -1,
53
+ character: [:byzantine, :arabic, :exotic],
54
+ parent: nil
55
+ }.freeze
56
+
57
+ class << self
58
+ @@pitches =
59
+ [{ functions: %i[I _1 tonic first],
60
+ pitch: 0 },
61
+ { functions: %i[II _2 supertonic second],
62
+ pitch: 1 },
63
+ { functions: %i[III _3 mediant third],
64
+ pitch: 4 },
65
+ { functions: %i[IV _4 subdominant fourth],
66
+ pitch: 5 },
67
+ { functions: %i[V _5 dominant fifth],
68
+ pitch: 7 },
69
+ { functions: %i[VI _6 submediant sixth],
70
+ pitch: 8 },
71
+ { functions: %i[VII _7 leading seventh],
72
+ pitch: 11 },
73
+ { functions: %i[VIII _8 eighth],
74
+ pitch: 12 },
75
+ { functions: %i[IX _9 ninth],
76
+ pitch: 12 + 1 },
77
+ { functions: %i[X _10 tenth],
78
+ pitch: 12 + 4 },
79
+ { functions: %i[XI _11 eleventh],
80
+ pitch: 12 + 5 },
81
+ { functions: %i[XII _12 twelfth],
82
+ pitch: 12 + 7 },
83
+ { functions: %i[XIII _13 thirteenth],
84
+ pitch: 12 + 8 }].freeze
85
+
86
+ def pitches
87
+ @@pitches
88
+ end
89
+
90
+ def grades
91
+ 7
92
+ end
93
+
94
+ def id
95
+ :double_harmonic
96
+ end
97
+ end
98
+
99
+ EquallyTempered12ToneScaleSystem.register DoubleHarmonicScaleKind
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Hungarian minor scale kind.
6
+ #
7
+ # HungarianMinorScaleKind defines the Hungarian minor scale (also called
8
+ # Gypsy minor or Double Harmonic Minor), a minor scale with two
9
+ # augmented seconds creating an exotic, Eastern European sound.
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)
20
+ # - **iv** (subdominant): Augmented fourth (6 semitones) ← CHARACTERISTIC (#4)
21
+ # - **v** (dominant): Perfect fifth (7 semitones)
22
+ # - **vi** (submediant): Minor sixth (8 semitones)
23
+ # - **vii** (leading): Major seventh (11 semitones)
24
+ #
25
+ # ## Two Augmented Seconds
26
+ #
27
+ # - Between III and IV (b3 to #4): 3 semitones
28
+ # - Between VI and VII (b6 to 7): 3 semitones
29
+ #
30
+ # ## Musical Character
31
+ #
32
+ # The Hungarian minor scale:
33
+ #
34
+ # - Dramatic, passionate, exotic
35
+ # - Common in Hungarian and Romani music
36
+ # - Used by Liszt, Brahms, and other Romantic composers
37
+ # - Creates a distinctive "gypsy" sound
38
+ #
39
+ # ## Usage
40
+ #
41
+ # a_hung_min = Scales[:et12][440.0][:hungarian_minor][69]
42
+ # a_hung_min.tonic # A (69)
43
+ # a_hung_min.iv # D# (75) - augmented fourth
44
+ # a_hung_min.vii # G# (80) - major seventh
45
+ #
46
+ # @see ScaleKind Abstract base class
47
+ # @see MinorHarmonicScaleKind Harmonic minor (one augmented second)
48
+ # @see DoubleHarmonicScaleKind Double harmonic (Byzantine)
49
+ class HungarianMinorScaleKind < ScaleKind
50
+ @base_metadata = {
51
+ family: :ethnic,
52
+ brightness: -2,
53
+ character: [:gypsy, :eastern_european, :dramatic],
54
+ parent: nil
55
+ }.freeze
56
+
57
+ class << self
58
+ @@pitches =
59
+ [{ functions: %i[i _1 tonic first],
60
+ pitch: 0 },
61
+ { functions: %i[ii _2 supertonic second],
62
+ pitch: 2 },
63
+ { functions: %i[iii _3 mediant third],
64
+ pitch: 3 },
65
+ { functions: %i[iv _4 subdominant fourth],
66
+ pitch: 6 },
67
+ { functions: %i[v _5 dominant fifth],
68
+ pitch: 7 },
69
+ { functions: %i[vi _6 submediant sixth],
70
+ pitch: 8 },
71
+ { functions: %i[vii _7 leading seventh],
72
+ pitch: 11 },
73
+ { functions: %i[viii _8 eighth],
74
+ pitch: 12 },
75
+ { functions: %i[ix _9 ninth],
76
+ pitch: 12 + 2 },
77
+ { functions: %i[x _10 tenth],
78
+ pitch: 12 + 3 },
79
+ { functions: %i[xi _11 eleventh],
80
+ pitch: 12 + 6 },
81
+ { functions: %i[xii _12 twelfth],
82
+ pitch: 12 + 7 },
83
+ { functions: %i[xiii _13 thirteenth],
84
+ pitch: 12 + 8 }].freeze
85
+
86
+ def pitches
87
+ @@pitches
88
+ end
89
+
90
+ def grades
91
+ 7
92
+ end
93
+
94
+ def id
95
+ :hungarian_minor
96
+ end
97
+ end
98
+
99
+ EquallyTempered12ToneScaleSystem.register HungarianMinorScaleKind
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Neapolitan major scale kind.
6
+ #
7
+ # NeapolitanMajorScaleKind defines the Neapolitan major scale, a
8
+ # major scale with a lowered second degree, combining the Neapolitan
9
+ # coloring with a brighter major upper structure.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 7 diatonic degrees plus extended harmony:
14
+ #
15
+ # **Scale Degrees** (uppercase for major quality):
16
+ #
17
+ # - **I** (tonic): Root (0 semitones)
18
+ # - **II** (supertonic): Minor second (1 semitone) ← NEAPOLITAN (b2)
19
+ # - **III** (mediant): Minor third (3 semitones)
20
+ # - **IV** (subdominant): Perfect fourth (5 semitones)
21
+ # - **V** (dominant): Perfect fifth (7 semitones)
22
+ # - **VI** (submediant): Major sixth (9 semitones)
23
+ # - **VII** (leading): Major seventh (11 semitones)
24
+ #
25
+ # ## Relationship to Melodic Minor
26
+ #
27
+ # Neapolitan major = Melodic minor with lowered 2nd
28
+ #
29
+ # ## Musical Character
30
+ #
31
+ # The Neapolitan major scale:
32
+ #
33
+ # - Exotic but brighter than Neapolitan minor
34
+ # - Combines Phrygian darkness with major brightness
35
+ # - Used in classical and contemporary music
36
+ # - Unique harmonic possibilities
37
+ #
38
+ # ## Usage
39
+ #
40
+ # c_neap_maj = Scales[:et12][440.0][:neapolitan_major][60]
41
+ # c_neap_maj.tonic # C (60)
42
+ # c_neap_maj.II # Db (61) - minor second (Neapolitan)
43
+ # c_neap_maj.VI # A (69) - major sixth
44
+ # c_neap_maj.VII # B (71) - leading tone
45
+ #
46
+ # @see ScaleKind Abstract base class
47
+ # @see MelodicMinorScaleKind Melodic minor (with major 2nd)
48
+ # @see NeapolitanMinorScaleKind Neapolitan minor
49
+ class NeapolitanMajorScaleKind < ScaleKind
50
+ @base_metadata = {
51
+ family: :ethnic,
52
+ brightness: -1,
53
+ character: [:neapolitan, :classical, :bright_dark],
54
+ parent: nil
55
+ }.freeze
56
+
57
+ class << self
58
+ @@pitches =
59
+ [{ functions: %i[I _1 tonic first],
60
+ pitch: 0 },
61
+ { functions: %i[II _2 supertonic second],
62
+ pitch: 1 },
63
+ { functions: %i[III _3 mediant third],
64
+ pitch: 3 },
65
+ { functions: %i[IV _4 subdominant fourth],
66
+ pitch: 5 },
67
+ { functions: %i[V _5 dominant fifth],
68
+ pitch: 7 },
69
+ { functions: %i[VI _6 submediant sixth],
70
+ pitch: 9 },
71
+ { functions: %i[VII _7 leading seventh],
72
+ pitch: 11 },
73
+ { functions: %i[VIII _8 eighth],
74
+ pitch: 12 },
75
+ { functions: %i[IX _9 ninth],
76
+ pitch: 12 + 1 },
77
+ { functions: %i[X _10 tenth],
78
+ pitch: 12 + 3 },
79
+ { functions: %i[XI _11 eleventh],
80
+ pitch: 12 + 5 },
81
+ { functions: %i[XII _12 twelfth],
82
+ pitch: 12 + 7 },
83
+ { functions: %i[XIII _13 thirteenth],
84
+ pitch: 12 + 9 }].freeze
85
+
86
+ def pitches
87
+ @@pitches
88
+ end
89
+
90
+ def grades
91
+ 7
92
+ end
93
+
94
+ def id
95
+ :neapolitan_major
96
+ end
97
+ end
98
+
99
+ EquallyTempered12ToneScaleSystem.register NeapolitanMajorScaleKind
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,101 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Neapolitan minor scale kind.
6
+ #
7
+ # NeapolitanMinorScaleKind defines the Neapolitan minor scale, a
8
+ # harmonic minor scale with a lowered second degree, named after
9
+ # the Neapolitan school of opera in the 18th century.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 7 diatonic degrees plus extended harmony:
14
+ #
15
+ # **Scale Degrees** (lowercase for minor quality):
16
+ #
17
+ # - **i** (tonic): Root (0 semitones)
18
+ # - **ii** (supertonic): Minor second (1 semitone) ← NEAPOLITAN (b2)
19
+ # - **iii** (mediant): Minor third (3 semitones)
20
+ # - **iv** (subdominant): Perfect fourth (5 semitones)
21
+ # - **v** (dominant): Perfect fifth (7 semitones)
22
+ # - **vi** (submediant): Minor sixth (8 semitones)
23
+ # - **vii** (leading): Major seventh (11 semitones)
24
+ #
25
+ # ## Relationship to Harmonic Minor
26
+ #
27
+ # Neapolitan minor = Harmonic minor with lowered 2nd
28
+ #
29
+ # ## Musical Character
30
+ #
31
+ # The Neapolitan minor scale:
32
+ #
33
+ # - Dark, dramatic, operatic
34
+ # - The Neapolitan sixth chord (bII) is characteristic
35
+ # - Used in classical and film music
36
+ # - Strong resolution tendency to tonic
37
+ #
38
+ # ## Usage
39
+ #
40
+ # a_neap_min = Scales[:et12][440.0][:neapolitan_minor][69]
41
+ # a_neap_min.tonic # A (69)
42
+ # a_neap_min.ii # Bb (70) - minor second (Neapolitan)
43
+ # a_neap_min.vii # G# (80) - leading tone
44
+ #
45
+ # @see ScaleKind Abstract base class
46
+ # @see MinorHarmonicScaleKind Harmonic minor (with major 2nd)
47
+ # @see NeapolitanMajorScaleKind Neapolitan major
48
+ class NeapolitanMinorScaleKind < ScaleKind
49
+ @base_metadata = {
50
+ family: :ethnic,
51
+ brightness: -2,
52
+ character: [:neapolitan, :classical, :dark],
53
+ parent: nil
54
+ }.freeze
55
+
56
+ class << self
57
+ @@pitches =
58
+ [{ functions: %i[i _1 tonic first],
59
+ pitch: 0 },
60
+ { functions: %i[ii _2 supertonic second],
61
+ pitch: 1 },
62
+ { functions: %i[iii _3 mediant third],
63
+ pitch: 3 },
64
+ { functions: %i[iv _4 subdominant fourth],
65
+ pitch: 5 },
66
+ { functions: %i[v _5 dominant fifth],
67
+ pitch: 7 },
68
+ { functions: %i[vi _6 submediant sixth],
69
+ pitch: 8 },
70
+ { functions: %i[vii _7 leading seventh],
71
+ pitch: 11 },
72
+ { functions: %i[viii _8 eighth],
73
+ pitch: 12 },
74
+ { functions: %i[ix _9 ninth],
75
+ pitch: 12 + 1 },
76
+ { functions: %i[x _10 tenth],
77
+ pitch: 12 + 3 },
78
+ { functions: %i[xi _11 eleventh],
79
+ pitch: 12 + 5 },
80
+ { functions: %i[xii _12 twelfth],
81
+ pitch: 12 + 7 },
82
+ { functions: %i[xiii _13 thirteenth],
83
+ pitch: 12 + 8 }].freeze
84
+
85
+ def pitches
86
+ @@pitches
87
+ end
88
+
89
+ def grades
90
+ 7
91
+ end
92
+
93
+ def id
94
+ :neapolitan_minor
95
+ end
96
+ end
97
+
98
+ EquallyTempered12ToneScaleSystem.register NeapolitanMinorScaleKind
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,103 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Phrygian dominant scale kind (Spanish Phrygian).
6
+ #
7
+ # PhrygianDominantScaleKind defines the Phrygian dominant scale (also called
8
+ # Spanish Phrygian, Freygish, or Spanish Gypsy scale), the fifth mode of
9
+ # harmonic minor. It's the quintessential flamenco scale.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 7 diatonic degrees plus extended harmony:
14
+ #
15
+ # **Scale Degrees** (uppercase for major 3rd quality):
16
+ #
17
+ # - **I** (tonic): Root (0 semitones)
18
+ # - **II** (supertonic): Minor second (1 semitone) ← PHRYGIAN
19
+ # - **III** (mediant): Major third (4 semitones) ← DOMINANT
20
+ # - **IV** (subdominant): Perfect fourth (5 semitones)
21
+ # - **V** (dominant): Perfect fifth (7 semitones)
22
+ # - **VI** (submediant): Minor sixth (8 semitones)
23
+ # - **VII** (subtonic): Minor seventh (10 semitones)
24
+ #
25
+ # ## Key Features
26
+ #
27
+ # - Phrygian's minor second (exotic)
28
+ # - Dominant's major third (strong harmonic character)
29
+ # - Creates the characteristic flamenco sound
30
+ #
31
+ # ## Musical Character
32
+ #
33
+ # The Phrygian dominant scale:
34
+ #
35
+ # - The sound of flamenco and Spanish guitar
36
+ # - Works over dominant chords resolving to minor
37
+ # - Common in klezmer and Middle Eastern music too
38
+ # - Intensely expressive and dramatic
39
+ #
40
+ # ## Usage
41
+ #
42
+ # e_phry_dom = Scales[:et12][440.0][:phrygian_dominant][64]
43
+ # e_phry_dom.tonic # E (64)
44
+ # e_phry_dom.II # F (65) - minor second (Phrygian)
45
+ # e_phry_dom.III # G# (68) - major third (Dominant)
46
+ #
47
+ # @see ScaleKind Abstract base class
48
+ # @see PhrygianScaleKind Phrygian mode (with minor 3rd)
49
+ # @see MinorHarmonicScaleKind Parent harmonic minor scale
50
+ class PhrygianDominantScaleKind < ScaleKind
51
+ @base_metadata = {
52
+ family: :ethnic,
53
+ brightness: -1,
54
+ character: [:spanish, :flamenco, :jewish],
55
+ parent: { scale: :minor_harmonic, degree: 5 }
56
+ }.freeze
57
+
58
+ class << self
59
+ @@pitches =
60
+ [{ functions: %i[I _1 tonic first],
61
+ pitch: 0 },
62
+ { functions: %i[II _2 supertonic second],
63
+ pitch: 1 },
64
+ { functions: %i[III _3 mediant third],
65
+ pitch: 4 },
66
+ { functions: %i[IV _4 subdominant fourth],
67
+ pitch: 5 },
68
+ { functions: %i[V _5 dominant fifth],
69
+ pitch: 7 },
70
+ { functions: %i[VI _6 submediant sixth],
71
+ pitch: 8 },
72
+ { functions: %i[VII _7 subtonic seventh],
73
+ pitch: 10 },
74
+ { functions: %i[VIII _8 eighth],
75
+ pitch: 12 },
76
+ { functions: %i[IX _9 ninth],
77
+ pitch: 12 + 1 },
78
+ { functions: %i[X _10 tenth],
79
+ pitch: 12 + 4 },
80
+ { functions: %i[XI _11 eleventh],
81
+ pitch: 12 + 5 },
82
+ { functions: %i[XII _12 twelfth],
83
+ pitch: 12 + 7 },
84
+ { functions: %i[XIII _13 thirteenth],
85
+ pitch: 12 + 8 }].freeze
86
+
87
+ def pitches
88
+ @@pitches
89
+ end
90
+
91
+ def grades
92
+ 7
93
+ end
94
+
95
+ def id
96
+ :phrygian_dominant
97
+ end
98
+ end
99
+
100
+ EquallyTempered12ToneScaleSystem.register PhrygianDominantScaleKind
101
+ end
102
+ end
103
+ end