stave 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 298ec095fbd8df1e9ee1f77db4708598d0fbb433a3d364810884787451dcec21
4
- data.tar.gz: 1c89449bb41bdabb016ef555b0cc8962eb9d6cf99fe90f35e689632c326ff48a
3
+ metadata.gz: 8dbd5c1307918d3c9af4689f6126d374ab8d7a31b03777f0bc3e9a32cf127188
4
+ data.tar.gz: 985afcf77f58ea34b29e1f16f3ee98b01b711ae2701d0c7f0b084586ca553b64
5
5
  SHA512:
6
- metadata.gz: 134a5a015273135682beec053a9985eb6f0084e972a516f26da08a221b3c16edee37c3d4ac1ec46c2ffedc4d7b77206ccd539b041a772214ca31ae295ead4c64
7
- data.tar.gz: 3d7b9d994d481785c8625757caa253fd4ae2f70e1f9a24531758a7ed392bccbe24a10912069ed2fa2ef51f13be4bf22d09a7c93ad72e267ee487773547435140
6
+ metadata.gz: 0d318f7a0cf99045f8e7191734c8d0adb6f41af1d7fc0d63e91176ca2c60328cbe8c731011a2697736068bf0e4326d6032eb287ee818928ef06f900fdb2326b9
7
+ data.tar.gz: 26f57ce7d59c8b333c2f4db3988763eb46c1ec1ab2c36cea23df1ac387ebd2104fc15e24293fe41929f37c3018136fc0c84701e78fc55b734952344ee8ea5d0a
@@ -1,6 +1,6 @@
1
1
  module Stave
2
2
  module Theory
3
- class Note < Core::Lookup
3
+ class Note < Core::Lookup # rubocop:disable Metrics/ClassLength
4
4
  class PitchClass < Core::Lookup
5
5
  variant :c, index: 0, symbol: "C", to_i: 0
6
6
  variant :d, index: 1, symbol: "D", to_i: 2
@@ -26,59 +26,157 @@ module Stave
26
26
  end
27
27
 
28
28
  with_options pitch_class: PitchClass.a do
29
- variant :a_double_flat, accidental: Accidental.double_flat
30
- variant :a_flat, accidental: Accidental.flat
31
- variant :a_natural, accidental: Accidental.natural
32
- variant :a_sharp, accidental: Accidental.sharp
33
- variant :a_double_sharp, accidental: Accidental.double_sharp
29
+ variant :a_double_flat,
30
+ accidental: Accidental.double_flat,
31
+ circle_of_fifths?: false
32
+
33
+ variant :a_flat,
34
+ accidental: Accidental.flat,
35
+ circle_of_fifths?: true
36
+
37
+ variant :a_natural,
38
+ accidental: Accidental.natural,
39
+ circle_of_fifths?: true
40
+
41
+ variant :a_sharp,
42
+ accidental: Accidental.sharp,
43
+ circle_of_fifths?: false
44
+
45
+ variant :a_double_sharp,
46
+ accidental: Accidental.double_sharp,
47
+ circle_of_fifths?: false
34
48
  end
35
49
 
36
50
  with_options pitch_class: PitchClass.b do
37
- variant :b_double_flat, accidental: Accidental.double_flat
38
- variant :b_flat, accidental: Accidental.flat
39
- variant :b_natural, accidental: Accidental.natural
40
- variant :b_sharp, accidental: Accidental.sharp
41
- variant :b_double_sharp, accidental: Accidental.double_sharp
51
+ variant :b_double_flat,
52
+ accidental: Accidental.double_flat,
53
+ circle_of_fifths?: false
54
+
55
+ variant :b_flat,
56
+ accidental: Accidental.flat,
57
+ circle_of_fifths?: true
58
+
59
+ variant :b_natural,
60
+ accidental: Accidental.natural,
61
+ circle_of_fifths?: true
62
+
63
+ variant :b_sharp,
64
+ accidental: Accidental.sharp,
65
+ circle_of_fifths?: false
66
+
67
+ variant :b_double_sharp,
68
+ accidental: Accidental.double_sharp,
69
+ circle_of_fifths?: false
42
70
  end
43
71
 
44
72
  with_options pitch_class: PitchClass.c do
45
- variant :c_double_flat, accidental: Accidental.double_flat
46
- variant :c_flat, accidental: Accidental.flat
47
- variant :c_natural, accidental: Accidental.natural
48
- variant :c_sharp, accidental: Accidental.sharp
49
- variant :c_double_sharp, accidental: Accidental.double_sharp
73
+ variant :c_double_flat,
74
+ accidental: Accidental.double_flat,
75
+ circle_of_fifths?: false
76
+
77
+ variant :c_flat,
78
+ accidental: Accidental.flat,
79
+ circle_of_fifths?: true
80
+
81
+ variant :c_natural,
82
+ accidental: Accidental.natural,
83
+ circle_of_fifths?: true
84
+
85
+ variant :c_sharp,
86
+ accidental: Accidental.sharp,
87
+ circle_of_fifths?: true
88
+
89
+ variant :c_double_sharp,
90
+ accidental: Accidental.double_sharp,
91
+ circle_of_fifths?: false
50
92
  end
51
93
 
52
94
  with_options pitch_class: PitchClass.d do
53
- variant :d_double_flat, accidental: Accidental.double_flat
54
- variant :d_flat, accidental: Accidental.flat
55
- variant :d_natural, accidental: Accidental.natural
56
- variant :d_sharp, accidental: Accidental.sharp
57
- variant :d_double_sharp, accidental: Accidental.double_sharp
95
+ variant :d_double_flat,
96
+ accidental: Accidental.double_flat,
97
+ circle_of_fifths?: false
98
+
99
+ variant :d_flat,
100
+ accidental: Accidental.flat,
101
+ circle_of_fifths?: true
102
+
103
+ variant :d_natural,
104
+ accidental: Accidental.natural,
105
+ circle_of_fifths?: true
106
+
107
+ variant :d_sharp,
108
+ accidental: Accidental.sharp,
109
+ circle_of_fifths?: false
110
+
111
+ variant :d_double_sharp,
112
+ accidental: Accidental.double_sharp,
113
+ circle_of_fifths?: false
58
114
  end
59
115
 
60
116
  with_options pitch_class: PitchClass.e do
61
- variant :e_double_flat, accidental: Accidental.double_flat
62
- variant :e_flat, accidental: Accidental.flat
63
- variant :e_natural, accidental: Accidental.natural
64
- variant :e_sharp, accidental: Accidental.sharp
65
- variant :e_double_sharp, accidental: Accidental.double_sharp
117
+ variant :e_double_flat,
118
+ accidental: Accidental.double_flat,
119
+ circle_of_fifths?: false
120
+
121
+ variant :e_flat,
122
+ accidental: Accidental.flat,
123
+ circle_of_fifths?: true
124
+
125
+ variant :e_natural,
126
+ accidental: Accidental.natural,
127
+ circle_of_fifths?: true
128
+
129
+ variant :e_sharp,
130
+ accidental: Accidental.sharp,
131
+ circle_of_fifths?: false
132
+
133
+ variant :e_double_sharp,
134
+ accidental: Accidental.double_sharp,
135
+ circle_of_fifths?: false
66
136
  end
67
137
 
68
138
  with_options pitch_class: PitchClass.f do
69
- variant :f_double_flat, accidental: Accidental.double_flat
70
- variant :f_flat, accidental: Accidental.flat
71
- variant :f_natural, accidental: Accidental.natural
72
- variant :f_sharp, accidental: Accidental.sharp
73
- variant :f_double_sharp, accidental: Accidental.double_sharp
139
+ variant :f_double_flat,
140
+ accidental: Accidental.double_flat,
141
+ circle_of_fifths?: false
142
+
143
+ variant :f_flat,
144
+ accidental: Accidental.flat,
145
+ circle_of_fifths?: false
146
+
147
+ variant :f_natural,
148
+ accidental: Accidental.natural,
149
+ circle_of_fifths?: true
150
+
151
+ variant :f_sharp,
152
+ accidental: Accidental.sharp,
153
+ circle_of_fifths?: true
154
+
155
+ variant :f_double_sharp,
156
+ accidental: Accidental.double_sharp,
157
+ circle_of_fifths?: false
74
158
  end
75
159
 
76
160
  with_options pitch_class: PitchClass.g do
77
- variant :g_double_flat, accidental: Accidental.double_flat
78
- variant :g_flat, accidental: Accidental.flat
79
- variant :g_natural, accidental: Accidental.natural
80
- variant :g_sharp, accidental: Accidental.sharp
81
- variant :g_double_sharp, accidental: Accidental.double_sharp
161
+ variant :g_double_flat,
162
+ accidental: Accidental.double_flat,
163
+ circle_of_fifths?: false
164
+
165
+ variant :g_flat,
166
+ accidental: Accidental.flat,
167
+ circle_of_fifths?: true
168
+
169
+ variant :g_natural,
170
+ accidental: Accidental.natural,
171
+ circle_of_fifths?: true
172
+
173
+ variant :g_sharp,
174
+ accidental: Accidental.sharp,
175
+ circle_of_fifths?: false
176
+
177
+ variant :g_double_sharp,
178
+ accidental: Accidental.double_sharp,
179
+ circle_of_fifths?: false
82
180
  end
83
181
 
84
182
  def +(other)
@@ -116,6 +214,10 @@ module Stave
116
214
  note_above(interval.invert!)
117
215
  end
118
216
 
217
+ def self.double_flats
218
+ where(accidental: Accidental.double_flat)
219
+ end
220
+
119
221
  def self.flats
120
222
  where(accidental: Accidental.flat)
121
223
  end
@@ -128,12 +230,16 @@ module Stave
128
230
  where(accidental: Accidental.sharp)
129
231
  end
130
232
 
233
+ def self.double_sharps
234
+ where(accidental: Accidental.double_sharp)
235
+ end
236
+
131
237
  def self.single_accidental
132
238
  flats + naturals + sharps
133
239
  end
134
240
 
135
241
  def self.circle_of_fifths
136
- Circle.new(type: CircleType.fifths, root: Note.c_natural).notes
242
+ where(circle_of_fifths?: true)
137
243
  end
138
244
  end
139
245
  end
@@ -6,13 +6,13 @@ module Stave
6
6
  end
7
7
 
8
8
  def triads
9
- return unless type.hexatonic?
9
+ return unless type.heptatonic?
10
10
 
11
11
  harmonise!(type.triad_types)
12
12
  end
13
13
 
14
14
  def sevenths
15
- return unless type.hexatonic?
15
+ return unless type.heptatonic?
16
16
 
17
17
  harmonise!(type.seventh_types)
18
18
  end
@@ -26,6 +26,10 @@ module Stave
26
26
  )
27
27
  end
28
28
 
29
+ def symbol
30
+ "#{root.symbol} #{type.symbol}"
31
+ end
32
+
29
33
  private
30
34
 
31
35
  def harmonise!(chord_types)
@@ -1,7 +1,7 @@
1
1
  module Stave
2
2
  module Theory
3
3
  class ScaleType < Core::DegreeCollection
4
- variant :major, degrees: [
4
+ variant :major, symbol: "major", degrees: [
5
5
  Degree.root,
6
6
  Degree.two,
7
7
  Degree.three,
@@ -12,7 +12,7 @@ module Stave
12
12
  Degree.octave
13
13
  ]
14
14
 
15
- variant :minor, degrees: [
15
+ variant :minor, symbol: "minor", degrees: [
16
16
  Degree.root,
17
17
  Degree.two,
18
18
  Degree.flat_three,
@@ -24,7 +24,7 @@ module Stave
24
24
  ]
25
25
 
26
26
  with_options suffix: :pentatonic do
27
- variant :major, degrees: [
27
+ variant :major, symbol: "major pentatonic", degrees: [
28
28
  Degree.root,
29
29
  Degree.two,
30
30
  Degree.three,
@@ -33,7 +33,7 @@ module Stave
33
33
  Degree.octave
34
34
  ]
35
35
 
36
- variant :minor, degrees: [
36
+ variant :minor, symbol: "minor pentatonic", degrees: [
37
37
  Degree.root,
38
38
  Degree.flat_three,
39
39
  Degree.four,
@@ -47,7 +47,7 @@ module Stave
47
47
  count == 5
48
48
  end
49
49
 
50
- def hexatonic?
50
+ def heptatonic?
51
51
  count == 7
52
52
  end
53
53
 
data/lib/stave/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Stave
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.1.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stave
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Welham
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-05 00:00:00.000000000 Z
11
+ date: 2024-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk