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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ea2efb7d874b85dd67a1838102d76409ce6a1bf9989707af68ad4909eccc9e5
4
- data.tar.gz: c45d1a2683f49adcadb70a0eb29965ad7af7e5fd9f1ec6966c1daacacb1ade95
3
+ metadata.gz: f33a752be0b413a020045e15277d598f679a99e8a02cff2e90d7678a8def945e
4
+ data.tar.gz: 69f384290299e50524c717f71baa2fa4760468553ef4b603c0303ddb75d364e0
5
5
  SHA512:
6
- metadata.gz: '087c6dc3413b35fd1c1b4cb729630bb2c11b2497a5506aa1a7168df15878cce5732e831f04f165dcee32891b06c31d456bd08a758ba83ffc1e428882b7ac9970'
7
- data.tar.gz: 23122c1670d39472bd93059b350520697f31abd5b2738b2738e07079b72abe3c44065d7d74a38568111399f3a646cc78264304c262e6501815f8dab478795773
6
+ metadata.gz: 9fa8bd4a2eae4959cd980a8865f88a367b2781df9836357b34b91f0d79cd6970dc71389f5e29c8b1b72cd0c68d633721da4a4e189bb8210193c41c12cc20bc0c
7
+ data.tar.gz: 9f953d75afacaccc35e8a688eeff8606ec854600281fb6636e44ed3fcd3155afefc5eb4ecf13a53a97b0facaf4e32d516b32c690b3d5653fa596dac2096ca914
data/.rubocop.yml CHANGED
@@ -14,3 +14,16 @@ AllCops:
14
14
 
15
15
  RSpec:
16
16
  Enabled: true
17
+
18
+ RSpec/ContextWording:
19
+ Prefixes:
20
+ - when
21
+ - with
22
+ - without
23
+ - given
24
+ - and
25
+ - for
26
+ - by
27
+
28
+ RSpec/NestedGroups:
29
+ Max: 4
@@ -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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeadMusic
4
- VERSION = "0.28.0"
4
+ VERSION = "1.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: head_music
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Head