head_music 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/head_music/clef.rb +8 -2
- data/lib/head_music/grand_staff.rb +53 -0
- data/lib/head_music/instrument.rb +51 -0
- data/lib/head_music/staff.rb +12 -0
- data/lib/head_music/utilities/hash_key.rb +9 -0
- data/lib/head_music/version.rb +1 -1
- data/lib/head_music.rb +4 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 823f43abc378e376a7302ceb5338ba72e2a29ed6
|
4
|
+
data.tar.gz: 0f4759f0ab0699dabca8510df197e7c19141011b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54cb6e28840e3578e3ec278410be1f79c919943153f7d20b99ffcf9c5e856b326ddd7123a833ed4df469205d9919b8aa35a81f2c5e4d905bfe58407218d38955
|
7
|
+
data.tar.gz: 847ee46aebc7cb4b415641bfd94eb4826959f55d754bee89006c9dab3c86c7b923e18317396b75fc3d421bf40ff1b97f2f66420bbe2e2eb28823ffa32b86cc61
|
data/lib/head_music/clef.rb
CHANGED
@@ -20,14 +20,16 @@ class HeadMusic::Clef
|
|
20
20
|
def self.get(name)
|
21
21
|
name = name.to_s
|
22
22
|
@clefs ||= {}
|
23
|
-
|
23
|
+
key = HeadMusic::Utilities::HashKey.for(name)
|
24
|
+
@clefs[key] ||= new(name)
|
24
25
|
end
|
25
26
|
|
26
27
|
attr_reader :name, :pitch, :line
|
28
|
+
delegate :to_s, to: :name
|
27
29
|
|
28
30
|
def initialize(name)
|
29
31
|
@name = name.to_s
|
30
|
-
clef_data = CLEFS.detect { |clef| clef[:names].include?(name) }
|
32
|
+
clef_data = CLEFS.detect { |clef| clef[:names].map(&:downcase).include?(name.downcase) }
|
31
33
|
@pitch = HeadMusic::Pitch.get(clef_data[:pitch])
|
32
34
|
@line = clef_data[:line]
|
33
35
|
end
|
@@ -51,4 +53,8 @@ class HeadMusic::Clef
|
|
51
53
|
pitch.natural_steps(steps)
|
52
54
|
end
|
53
55
|
end
|
56
|
+
|
57
|
+
def ==(other)
|
58
|
+
to_s == other.to_s
|
59
|
+
end
|
54
60
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
class HeadMusic::GrandStaff
|
2
|
+
GRAND_STAVES = {
|
3
|
+
piano: {
|
4
|
+
instrument: :piano,
|
5
|
+
staves: [
|
6
|
+
{ clef: :treble, instrument: :piano },
|
7
|
+
{ clef: :bass, instrument: :piano }
|
8
|
+
]
|
9
|
+
},
|
10
|
+
organ: {
|
11
|
+
instrument: :organ,
|
12
|
+
staves: [
|
13
|
+
{ clef: :treble, instrument: :organ },
|
14
|
+
{ clef: :bass, instrument: :organ },
|
15
|
+
{ clef: :bass, instrument: :pedals }
|
16
|
+
]
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
def self.get(name)
|
21
|
+
@grand_staves ||= {}
|
22
|
+
hash_key = HeadMusic::Utilities::HashKey.for(name)
|
23
|
+
return nil unless GRAND_STAVES.keys.include?(hash_key)
|
24
|
+
@grand_staves[hash_key] ||= new(hash_key)
|
25
|
+
end
|
26
|
+
|
27
|
+
attr_reader :identifier, :data
|
28
|
+
|
29
|
+
def initialize(name)
|
30
|
+
@identifier = HeadMusic::Utilities::HashKey.for(name)
|
31
|
+
@data = GRAND_STAVES[identifier]
|
32
|
+
end
|
33
|
+
|
34
|
+
def instrument
|
35
|
+
@instrument ||= HeadMusic::Instrument.get(data[:instrument])
|
36
|
+
end
|
37
|
+
|
38
|
+
def staves
|
39
|
+
@staves ||= begin
|
40
|
+
data[:staves].map { |staff|
|
41
|
+
HeadMusic::Staff.new(staff[:clef], instrument: staff[:instrument] || instrument)
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def brace_staves_index_first
|
47
|
+
0
|
48
|
+
end
|
49
|
+
|
50
|
+
def brace_staves_index_last
|
51
|
+
1
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
class HeadMusic::Instrument
|
2
|
+
INSTRUMENTS = {
|
3
|
+
violin: {
|
4
|
+
name: "violin",
|
5
|
+
family: :string,
|
6
|
+
default_clef: :treble
|
7
|
+
},
|
8
|
+
piano: {
|
9
|
+
name: "piano",
|
10
|
+
family: :string,
|
11
|
+
default_system: [:treble, :bass]
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
def self.get(name)
|
16
|
+
@instruments ||= {}
|
17
|
+
key = HeadMusic::Utilities::HashKey.for(name)
|
18
|
+
@instruments[key] ||= new(name.to_s)
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :name
|
22
|
+
delegate :to_s, to: :name
|
23
|
+
|
24
|
+
def initialize(name)
|
25
|
+
@name = name.to_s
|
26
|
+
end
|
27
|
+
|
28
|
+
def data
|
29
|
+
@data ||= INSTRUMENTS[hash_key]
|
30
|
+
end
|
31
|
+
|
32
|
+
def hash_key
|
33
|
+
HeadMusic::Utilities::HashKey.for(name)
|
34
|
+
end
|
35
|
+
|
36
|
+
def family
|
37
|
+
data[:family]
|
38
|
+
end
|
39
|
+
|
40
|
+
def default_system
|
41
|
+
data[:default_system]
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_clef
|
45
|
+
data[:default_clef]
|
46
|
+
end
|
47
|
+
|
48
|
+
def ==(other)
|
49
|
+
to_s == other.to_s
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class HeadMusic::Staff
|
2
|
+
DEFAULT_LINE_COUNT = 5
|
3
|
+
|
4
|
+
attr_reader :default_clef, :line_count, :instrument
|
5
|
+
alias_method :clef, :default_clef
|
6
|
+
|
7
|
+
def initialize(default_clef, instrument: nil, line_count: nil)
|
8
|
+
@default_clef = HeadMusic::Clef.get(default_clef)
|
9
|
+
@line_count = line_count || DEFAULT_LINE_COUNT
|
10
|
+
@instrument = HeadMusic::Instrument.get(instrument) if instrument
|
11
|
+
end
|
12
|
+
end
|
data/lib/head_music/version.rb
CHANGED
data/lib/head_music.rb
CHANGED
@@ -9,6 +9,8 @@ require 'head_music/circle'
|
|
9
9
|
require 'head_music/clef'
|
10
10
|
require 'head_music/consonance'
|
11
11
|
require 'head_music/functional_interval'
|
12
|
+
require 'head_music/grand_staff'
|
13
|
+
require 'head_music/instrument'
|
12
14
|
require 'head_music/interval'
|
13
15
|
require 'head_music/key_signature'
|
14
16
|
require 'head_music/letter_name'
|
@@ -23,6 +25,8 @@ require 'head_music/rhythmic_value'
|
|
23
25
|
require 'head_music/scale'
|
24
26
|
require 'head_music/scale_type'
|
25
27
|
require 'head_music/spelling'
|
28
|
+
require 'head_music/staff'
|
29
|
+
require 'head_music/utilities/hash_key'
|
26
30
|
|
27
31
|
module HeadMusic
|
28
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: head_music
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rob Head
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -119,6 +119,8 @@ files:
|
|
119
119
|
- lib/head_music/clef.rb
|
120
120
|
- lib/head_music/consonance.rb
|
121
121
|
- lib/head_music/functional_interval.rb
|
122
|
+
- lib/head_music/grand_staff.rb
|
123
|
+
- lib/head_music/instrument.rb
|
122
124
|
- lib/head_music/interval.rb
|
123
125
|
- lib/head_music/key_signature.rb
|
124
126
|
- lib/head_music/letter_name.rb
|
@@ -133,6 +135,8 @@ files:
|
|
133
135
|
- lib/head_music/scale.rb
|
134
136
|
- lib/head_music/scale_type.rb
|
135
137
|
- lib/head_music/spelling.rb
|
138
|
+
- lib/head_music/staff.rb
|
139
|
+
- lib/head_music/utilities/hash_key.rb
|
136
140
|
- lib/head_music/version.rb
|
137
141
|
homepage: https://github.com/roberthead/head_music
|
138
142
|
licenses:
|