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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/Gemfile +0 -1
  4. data/docs/subsystems/music.md +326 -15
  5. data/lib/musa-dsl/generative/darwin.rb +36 -1
  6. data/lib/musa-dsl/generative/generative-grammar.rb +28 -0
  7. data/lib/musa-dsl/generative/markov.rb +2 -0
  8. data/lib/musa-dsl/generative/rules.rb +54 -0
  9. data/lib/musa-dsl/generative/variatio.rb +69 -0
  10. data/lib/musa-dsl/midi/midi-recorder.rb +4 -0
  11. data/lib/musa-dsl/midi/midi-voices.rb +10 -0
  12. data/lib/musa-dsl/music/chords.rb +54 -9
  13. data/lib/musa-dsl/music/equally-tempered-12-tone-scale-system.rb +70 -521
  14. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_dominant_scale_kind.rb +110 -0
  15. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_major_scale_kind.rb +110 -0
  16. data/lib/musa-dsl/music/scale_kinds/bebop/bebop_minor_scale_kind.rb +110 -0
  17. data/lib/musa-dsl/music/scale_kinds/blues/blues_major_scale_kind.rb +100 -0
  18. data/lib/musa-dsl/music/scale_kinds/blues/blues_scale_kind.rb +99 -0
  19. data/lib/musa-dsl/music/scale_kinds/chromatic_scale_kind.rb +79 -0
  20. data/lib/musa-dsl/music/scale_kinds/ethnic/double_harmonic_scale_kind.rb +102 -0
  21. data/lib/musa-dsl/music/scale_kinds/ethnic/hungarian_minor_scale_kind.rb +102 -0
  22. data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_major_scale_kind.rb +102 -0
  23. data/lib/musa-dsl/music/scale_kinds/ethnic/neapolitan_minor_scale_kind.rb +101 -0
  24. data/lib/musa-dsl/music/scale_kinds/ethnic/phrygian_dominant_scale_kind.rb +103 -0
  25. data/lib/musa-dsl/music/scale_kinds/harmonic_major/harmonic_major_scale_kind.rb +104 -0
  26. data/lib/musa-dsl/music/scale_kinds/major_scale_kind.rb +110 -0
  27. data/lib/musa-dsl/music/scale_kinds/melodic_minor/altered_scale_kind.rb +106 -0
  28. data/lib/musa-dsl/music/scale_kinds/melodic_minor/dorian_b2_scale_kind.rb +104 -0
  29. data/lib/musa-dsl/music/scale_kinds/melodic_minor/locrian_sharp2_scale_kind.rb +103 -0
  30. data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_augmented_scale_kind.rb +103 -0
  31. data/lib/musa-dsl/music/scale_kinds/melodic_minor/lydian_dominant_scale_kind.rb +106 -0
  32. data/lib/musa-dsl/music/scale_kinds/melodic_minor/melodic_minor_scale_kind.rb +104 -0
  33. data/lib/musa-dsl/music/scale_kinds/melodic_minor/mixolydian_b6_scale_kind.rb +103 -0
  34. data/lib/musa-dsl/music/scale_kinds/minor_harmonic_scale_kind.rb +125 -0
  35. data/lib/musa-dsl/music/scale_kinds/minor_natural_scale_kind.rb +123 -0
  36. data/lib/musa-dsl/music/scale_kinds/modes/dorian_scale_kind.rb +111 -0
  37. data/lib/musa-dsl/music/scale_kinds/modes/locrian_scale_kind.rb +114 -0
  38. data/lib/musa-dsl/music/scale_kinds/modes/lydian_scale_kind.rb +111 -0
  39. data/lib/musa-dsl/music/scale_kinds/modes/mixolydian_scale_kind.rb +111 -0
  40. data/lib/musa-dsl/music/scale_kinds/modes/phrygian_scale_kind.rb +111 -0
  41. data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_major_scale_kind.rb +93 -0
  42. data/lib/musa-dsl/music/scale_kinds/pentatonic/pentatonic_minor_scale_kind.rb +99 -0
  43. data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_hw_scale_kind.rb +110 -0
  44. data/lib/musa-dsl/music/scale_kinds/symmetric/diminished_wh_scale_kind.rb +110 -0
  45. data/lib/musa-dsl/music/scale_kinds/symmetric/whole_tone_scale_kind.rb +99 -0
  46. data/lib/musa-dsl/music/scale_systems/equally_tempered_12_tone_scale_system.rb +80 -0
  47. data/lib/musa-dsl/music/scale_systems/twelve_semitones_scale_system.rb +60 -0
  48. data/lib/musa-dsl/music/scales.rb +427 -0
  49. data/lib/musa-dsl/series/buffer-serie.rb +6 -0
  50. data/lib/musa-dsl/series/hash-or-array-serie-splitter.rb +23 -0
  51. data/lib/musa-dsl/series/quantizer-serie.rb +12 -0
  52. data/lib/musa-dsl/series/queue-serie.rb +13 -0
  53. data/lib/musa-dsl/version.rb +2 -1
  54. data/musa-dsl.gemspec +20 -15
  55. metadata +85 -22
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Bebop major scale kind.
6
+ #
7
+ # BebopMajorScaleKind defines the bebop major scale, an eight-note
8
+ # scale that adds a chromatic passing tone (#5) to the major scale.
9
+ # 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
+ # - **V#** (passing): Augmented fifth (8 semitones) ← PASSING TONE
23
+ # - **VI** (submediant): Major sixth (9 semitones)
24
+ # - **VII** (leading): Major seventh (11 semitones)
25
+ #
26
+ # ## Bebop Principle
27
+ #
28
+ # The added #5 chromatic note ensures that:
29
+ # - Chord tones (1, 3, 5, 7) fall on strong beats
30
+ # - Non-chord tones fall on weak beats
31
+ # - Smooth chromatic connection between 5 and 6
32
+ #
33
+ # ## Musical Character
34
+ #
35
+ # The bebop major scale:
36
+ #
37
+ # - Used over major 7th and major 6th chords
38
+ # - Creates flowing eighth-note lines
39
+ # - Common in bebop and jazz standards
40
+ #
41
+ # ## Usage
42
+ #
43
+ # c_bebop_maj = Scales[:et12][440.0][:bebop_major][60]
44
+ # c_bebop_maj[4].pitch # G (67) - perfect 5th
45
+ # c_bebop_maj[5].pitch # G# (68) - augmented 5th (passing)
46
+ # c_bebop_maj[6].pitch # A (69) - major 6th
47
+ #
48
+ # @see ScaleKind Abstract base class
49
+ # @see MajorScaleKind Major scale (7-note parent)
50
+ # @see BebopDominantScaleKind Bebop dominant scale
51
+ class BebopMajorScaleKind < ScaleKind
52
+ @base_metadata = {
53
+ family: :bebop,
54
+ brightness: 0,
55
+ character: [:jazz, :chromatic_passing, :major],
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[V# _6 sixth],
72
+ pitch: 8 },
73
+ { functions: %i[VI _7 submediant seventh],
74
+ pitch: 9 },
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[XII# _14 fourteenth],
88
+ pitch: 12 + 8 },
89
+ { functions: %i[XIII _15 fifteenth],
90
+ pitch: 12 + 9 },
91
+ { functions: %i[XIV _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_major
104
+ end
105
+ end
106
+
107
+ EquallyTempered12ToneScaleSystem.register BebopMajorScaleKind
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,110 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Bebop minor scale kind.
6
+ #
7
+ # BebopMinorScaleKind defines the bebop minor scale, an eight-note
8
+ # scale that adds a chromatic passing tone (major 7th) to the Dorian
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** (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): Perfect fourth (5 semitones)
21
+ # - **v** (dominant): Perfect fifth (7 semitones)
22
+ # - **vi** (submediant): Major sixth (9 semitones) ← DORIAN
23
+ # - **vii** (subtonic): Minor seventh (10 semitones)
24
+ # - **vii#** (leading): Major seventh (11 semitones) ← PASSING TONE
25
+ #
26
+ # ## Bebop Principle
27
+ #
28
+ # The added major 7th chromatic note ensures that:
29
+ # - Chord tones (1, b3, 5, b7) fall on strong beats
30
+ # - Non-chord tones fall on weak beats
31
+ # - Smooth chromatic connection from b7 to root
32
+ #
33
+ # ## Musical Character
34
+ #
35
+ # The bebop minor scale:
36
+ #
37
+ # - Used over minor 7th chords
38
+ # - Based on Dorian mode (bright minor)
39
+ # - Common in jazz ii-V-I progressions
40
+ #
41
+ # ## Usage
42
+ #
43
+ # d_bebop_min = Scales[:et12][440.0][:bebop_minor][62]
44
+ # d_bebop_min[6].pitch # C (72) - minor 7th
45
+ # d_bebop_min[7].pitch # C# (73) - major 7th (passing)
46
+ # d_bebop_min[8].pitch # D (74) - octave
47
+ #
48
+ # @see ScaleKind Abstract base class
49
+ # @see DorianScaleKind Dorian mode (7-note parent)
50
+ # @see BebopDominantScaleKind Bebop dominant scale
51
+ class BebopMinorScaleKind < ScaleKind
52
+ @base_metadata = {
53
+ family: :bebop,
54
+ brightness: -1,
55
+ character: [:jazz, :chromatic_passing, :minor],
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 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 + 3 },
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_minor
104
+ end
105
+ end
106
+
107
+ EquallyTempered12ToneScaleSystem.register BebopMinorScaleKind
108
+ end
109
+ end
110
+ end
@@ -0,0 +1,100 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Musa
4
+ module Scales
5
+ # Major blues scale kind.
6
+ #
7
+ # BluesMajorScaleKind defines the major blues scale, a six-note scale
8
+ # that adds the "blue note" (b3) to the major pentatonic scale.
9
+ # It provides a brighter blues sound than the minor blues scale.
10
+ #
11
+ # ## Pitch Structure
12
+ #
13
+ # 6 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
+ # - **blue** (blue note): Minor third (3 semitones) ← CHARACTERISTIC
20
+ # - **III** (mediant): Major third (4 semitones)
21
+ # - **V** (dominant): Perfect fifth (7 semitones)
22
+ # - **VI** (submediant): Major sixth (9 semitones)
23
+ #
24
+ # ## The Blue Note
25
+ #
26
+ # The b3 (minor third) is the blue note in the major blues scale.
27
+ # It creates tension that resolves up to the major third, providing
28
+ # the characteristic "bend" sound in blues guitar and vocals.
29
+ #
30
+ # ## Musical Character
31
+ #
32
+ # The major blues scale:
33
+ #
34
+ # - Brighter alternative to minor blues
35
+ # - Works well over major and dominant 7th chords
36
+ # - Common in country blues and jazz
37
+ # - The b3 to natural 3 movement is essential
38
+ #
39
+ # ## Usage
40
+ #
41
+ # c_blues_maj = Scales[:et12][440.0][:blues_major][60]
42
+ # c_blues_maj.tonic # C (60)
43
+ # c_blues_maj.blue # Eb (63) - the blue note
44
+ # c_blues_maj.mediant # E (64) - major third
45
+ #
46
+ # @see ScaleKind Abstract base class
47
+ # @see PentatonicMajorScaleKind Major pentatonic (without blue note)
48
+ # @see BluesScaleKind Minor blues scale
49
+ class BluesMajorScaleKind < ScaleKind
50
+ @base_metadata = {
51
+ family: :blues,
52
+ brightness: 0,
53
+ character: [:bluesy, :gospel, :major],
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[blue _3 third],
64
+ pitch: 3 },
65
+ { functions: %i[III _4 mediant fourth],
66
+ pitch: 4 },
67
+ { functions: %i[V _5 dominant fifth],
68
+ pitch: 7 },
69
+ { functions: %i[VI _6 submediant sixth],
70
+ pitch: 9 },
71
+ { functions: %i[VIII _7 seventh],
72
+ pitch: 12 },
73
+ { functions: %i[IX _8 eighth],
74
+ pitch: 12 + 2 },
75
+ { functions: %i[blue2 _9 ninth],
76
+ pitch: 12 + 3 },
77
+ { functions: %i[X _10 tenth],
78
+ pitch: 12 + 4 },
79
+ { functions: %i[XII _11 eleventh],
80
+ pitch: 12 + 7 },
81
+ { functions: %i[XIII _12 twelfth],
82
+ pitch: 12 + 9 }].freeze
83
+
84
+ def pitches
85
+ @@pitches
86
+ end
87
+
88
+ def grades
89
+ 6
90
+ end
91
+
92
+ def id
93
+ :blues_major
94
+ end
95
+ end
96
+
97
+ EquallyTempered12ToneScaleSystem.register BluesMajorScaleKind
98
+ end
99
+ end
100
+ end
@@ -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