head_music 0.28.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +13 -0
- data/lib/head_music/content/bar.rb +4 -1
- data/lib/head_music/content/composition.rb +6 -3
- data/lib/head_music/content/note.rb +8 -5
- data/lib/head_music/content/placement.rb +7 -4
- data/lib/head_music/content/position.rb +5 -2
- data/lib/head_music/content/rhythmic_value.rb +5 -2
- data/lib/head_music/content/voice.rb +6 -3
- data/lib/head_music/harmonic_interval.rb +1 -1
- data/lib/head_music/meter.rb +2 -2
- data/lib/head_music/style/guidelines/at_least_eight_notes.rb +2 -2
- data/lib/head_music/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f33a752be0b413a020045e15277d598f679a99e8a02cff2e90d7678a8def945e
|
4
|
+
data.tar.gz: 69f384290299e50524c717f71baa2fa4760468553ef4b603c0303ddb75d364e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fa8bd4a2eae4959cd980a8865f88a367b2781df9836357b34b91f0d79cd6970dc71389f5e29c8b1b72cd0c68d633721da4a4e189bb8210193c41c12cc20bc0c
|
7
|
+
data.tar.gz: 9f953d75afacaccc35e8a688eeff8606ec854600281fb6636e44ed3fcd3155afefc5eb4ecf13a53a97b0facaf4e32d516b32c690b3d5653fa596dac2096ca914
|
data/.rubocop.yml
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# Representation of a bar in a composition
|
4
7
|
# Encapsulates meter and key signature changes
|
5
|
-
class HeadMusic::Bar
|
8
|
+
class HeadMusic::Content::Bar
|
6
9
|
attr_reader :composition
|
7
10
|
attr_accessor :key_signature, :meter
|
8
11
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A composition is musical content.
|
4
|
-
class HeadMusic::Composition
|
7
|
+
class HeadMusic::Content::Composition
|
5
8
|
attr_reader :name, :key_signature, :meter, :voices
|
6
9
|
|
7
10
|
def initialize(name: nil, key_signature: nil, meter: nil)
|
@@ -10,7 +13,7 @@ class HeadMusic::Composition
|
|
10
13
|
end
|
11
14
|
|
12
15
|
def add_voice(role: nil)
|
13
|
-
@voices << HeadMusic::Voice.new(composition: self, role: role)
|
16
|
+
@voices << HeadMusic::Content::Voice.new(composition: self, role: role)
|
14
17
|
@voices.last
|
15
18
|
end
|
16
19
|
|
@@ -27,7 +30,7 @@ class HeadMusic::Composition
|
|
27
30
|
def bars(last = latest_bar_number)
|
28
31
|
@bars ||= []
|
29
32
|
(earliest_bar_number..last).each do |bar_number|
|
30
|
-
@bars[bar_number] ||= HeadMusic::Bar.new(self)
|
33
|
+
@bars[bar_number] ||= HeadMusic::Content::Bar.new(self)
|
31
34
|
end
|
32
35
|
@bars[earliest_bar_number..last]
|
33
36
|
end
|
@@ -1,22 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A note is a pitch with a duration.
|
4
7
|
#
|
5
8
|
# Note quacks like a placement, but requires a different set of construction arguments
|
6
9
|
# - always has a pitch
|
7
10
|
# - receives a voice and position if unspecified
|
8
|
-
class HeadMusic::Note
|
11
|
+
class HeadMusic::Content::Note
|
9
12
|
attr_accessor :pitch, :rhythmic_value, :voice, :position
|
10
13
|
|
11
14
|
def initialize(pitch, rhythmic_value, voice = nil, position = nil)
|
12
15
|
@pitch = HeadMusic::Pitch.get(pitch)
|
13
|
-
@rhythmic_value = HeadMusic::RhythmicValue.get(rhythmic_value)
|
14
|
-
@voice = voice || HeadMusic::Voice.new
|
15
|
-
@position = position || HeadMusic::Position.new(@voice.composition, "1:1")
|
16
|
+
@rhythmic_value = HeadMusic::Content::RhythmicValue.get(rhythmic_value)
|
17
|
+
@voice = voice || HeadMusic::Content::Voice.new
|
18
|
+
@position = position || HeadMusic::Content::Position.new(@voice.composition, "1:1")
|
16
19
|
end
|
17
20
|
|
18
21
|
def placement
|
19
|
-
@placement ||= HeadMusic::Placement.new(voice, position, rhythmic_value, pitch)
|
22
|
+
@placement ||= HeadMusic::Content::Placement.new(voice, position, rhythmic_value, pitch)
|
20
23
|
end
|
21
24
|
|
22
25
|
def to_s
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A placement is a note or rest at a position within a voice in a composition
|
4
|
-
class HeadMusic::Placement
|
7
|
+
class HeadMusic::Content::Placement
|
5
8
|
include Comparable
|
6
9
|
|
7
10
|
attr_reader :voice, :position, :rhythmic_value, :pitch
|
@@ -54,15 +57,15 @@ class HeadMusic::Placement
|
|
54
57
|
def ensure_attributes(voice, position, rhythmic_value, pitch)
|
55
58
|
@voice = voice
|
56
59
|
ensure_position(position)
|
57
|
-
@rhythmic_value = HeadMusic::RhythmicValue.get(rhythmic_value)
|
60
|
+
@rhythmic_value = HeadMusic::Content::RhythmicValue.get(rhythmic_value)
|
58
61
|
@pitch = HeadMusic::Pitch.get(pitch)
|
59
62
|
end
|
60
63
|
|
61
64
|
def ensure_position(position)
|
62
|
-
@position = if position.is_a?(HeadMusic::Position)
|
65
|
+
@position = if position.is_a?(HeadMusic::Content::Position)
|
63
66
|
position
|
64
67
|
else
|
65
|
-
HeadMusic::Position.new(composition, position)
|
68
|
+
HeadMusic::Content::Position.new(composition, position)
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A position is a moment in time within the rhythmic framework of a composition.
|
4
|
-
class HeadMusic::Position
|
7
|
+
class HeadMusic::Content::Position
|
5
8
|
include Comparable
|
6
9
|
|
7
10
|
attr_reader :composition, :bar_number, :count, :tick
|
@@ -56,7 +59,7 @@ class HeadMusic::Position
|
|
56
59
|
end
|
57
60
|
|
58
61
|
def +(other)
|
59
|
-
other = HeadMusic::RhythmicValue.new(other) if [HeadMusic::RhythmicUnit, Symbol, String].include?(other.class)
|
62
|
+
other = HeadMusic::Content::RhythmicValue.new(other) if [HeadMusic::RhythmicUnit, Symbol, String].include?(other.class)
|
60
63
|
self.class.new(composition, bar_number, count, tick + other.ticks)
|
61
64
|
end
|
62
65
|
|
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A rhythmic value is a duration composed of a rhythmic unit, any number of dots, and a tied value.
|
4
|
-
class HeadMusic::RhythmicValue
|
7
|
+
class HeadMusic::Content::RhythmicValue
|
5
8
|
attr_reader :unit, :dots, :tied_value
|
6
9
|
|
7
10
|
delegate :name, to: :unit, prefix: true
|
@@ -9,7 +12,7 @@ class HeadMusic::RhythmicValue
|
|
9
12
|
|
10
13
|
def self.get(identifier)
|
11
14
|
case identifier
|
12
|
-
when HeadMusic::RhythmicValue
|
15
|
+
when HeadMusic::Content::RhythmicValue
|
13
16
|
identifier
|
14
17
|
when HeadMusic::RhythmicUnit
|
15
18
|
new(identifier)
|
@@ -1,8 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# A module for musical content
|
4
|
+
module HeadMusic::Content; end
|
5
|
+
|
3
6
|
# A Voice is a stream of music with some indepedence that is conceptually one part or for one performer.
|
4
7
|
# The melodic lines in counterpoint are each a voice.
|
5
|
-
class HeadMusic::Voice
|
8
|
+
class HeadMusic::Content::Voice
|
6
9
|
include Comparable
|
7
10
|
|
8
11
|
attr_reader :composition, :placements, :role
|
@@ -10,13 +13,13 @@ class HeadMusic::Voice
|
|
10
13
|
delegate :key_signature, to: :composition
|
11
14
|
|
12
15
|
def initialize(composition: nil, role: nil)
|
13
|
-
@composition = composition || HeadMusic::Composition.new
|
16
|
+
@composition = composition || HeadMusic::Content::Composition.new
|
14
17
|
@role = role
|
15
18
|
@placements = []
|
16
19
|
end
|
17
20
|
|
18
21
|
def place(position, rhythmic_value, pitch = nil)
|
19
|
-
HeadMusic::Placement.new(self, position, rhythmic_value, pitch).tap do |placement|
|
22
|
+
HeadMusic::Content::Placement.new(self, position, rhythmic_value, pitch).tap do |placement|
|
20
23
|
insert_into_placements(placement)
|
21
24
|
end
|
22
25
|
end
|
@@ -7,7 +7,7 @@ class HeadMusic::HarmonicInterval
|
|
7
7
|
def initialize(voice1, voice2, position)
|
8
8
|
@voice1 = voice1
|
9
9
|
@voice2 = voice2
|
10
|
-
@position = position.is_a?(String) ? HeadMusic::Position.new(voice1.composition, position) : position
|
10
|
+
@position = position.is_a?(String) ? HeadMusic::Content::Position.new(voice1.composition, position) : position
|
11
11
|
end
|
12
12
|
|
13
13
|
def diatonic_interval
|
data/lib/head_music/meter.rb
CHANGED
@@ -82,9 +82,9 @@ class HeadMusic::Meter
|
|
82
82
|
def beat_unit
|
83
83
|
@beat_unit ||=
|
84
84
|
if compound?
|
85
|
-
HeadMusic::RhythmicValue.new(HeadMusic::RhythmicUnit.for_denominator_value(bottom_number / 2), dots: 1)
|
85
|
+
HeadMusic::Content::RhythmicValue.new(HeadMusic::RhythmicUnit.for_denominator_value(bottom_number / 2), dots: 1)
|
86
86
|
else
|
87
|
-
HeadMusic::RhythmicValue.new(count_unit)
|
87
|
+
HeadMusic::Content::RhythmicValue.new(count_unit)
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
@@ -17,8 +17,8 @@ class HeadMusic::Style::Guidelines::AtLeastEightNotes < HeadMusic::Style::Annota
|
|
17
17
|
|
18
18
|
def no_placements_mark
|
19
19
|
HeadMusic::Style::Mark.new(
|
20
|
-
HeadMusic::Position.new(composition, "1:1"),
|
21
|
-
HeadMusic::Position.new(composition, "2:1"),
|
20
|
+
HeadMusic::Content::Position.new(composition, "1:1"),
|
21
|
+
HeadMusic::Content::Position.new(composition, "2:1"),
|
22
22
|
fitness: 0
|
23
23
|
)
|
24
24
|
end
|
data/lib/head_music/version.rb
CHANGED