ruby-mext 0.18.3 → 0.19.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1f9e5f94cd8ceca1eccad111b0782ae457571e107850f0964a8a186e7aa9ad53
4
- data.tar.gz: 49a30dd4fbddf629598344f117a9220131d4fb7c6551ff788b6112cc685d322d
3
+ metadata.gz: 615ac635788737a15b34dc6f376546de1eacd70cf117ee36d9006ed384c60132
4
+ data.tar.gz: 536b40b3cbaf894438b744f800276c54a5a2909de635e4e395e75bc056f96098
5
5
  SHA512:
6
- metadata.gz: 777d1879eaa3460a3a8233cab4431d5f0b2072b5c7d5f710fdb00f336001398574899c400e40f3bc43f194fde1ccd03ffd42056a584bbbbe5acd58f4a72301bf
7
- data.tar.gz: fe69260624613aa5702c04af49c0e543c5ac4909148cfff70eb54b7dc587d194c45b7a445ea74dd8b3e1ef4b32c87fd3f46f5df7c7ee1dc8fe665063968b6b49
6
+ metadata.gz: 19c265c862ea434755591d0fa1b50b889cb0ede8420d0ae6b3853020ad32238c0c3b43cd92217782cde5d4ce2264bb80d6bd37e9a187bda343dd8c5a582b94c4
7
+ data.tar.gz: 50c9ca95f623dc9895a17583eb49edc41f35d74886263a91b2d5707cdc500ccfdbc29a7556fc46faf5ba67638b9d8c538e7a40bfd6cbff7e049a14353b1acff1
@@ -0,0 +1,64 @@
1
+ module Mext
2
+
3
+ #
4
+ # +Mext::PitchClassArray+
5
+ #
6
+ # a kind of +Mext::EndlessArray+ which
7
+ # has a secondary +Mext::EndlessArray+ of the interval
8
+ # relations among
9
+ # or the previous value in an endless fashion (i.e. +mod'ding+
10
+ # the current index)
11
+ #
12
+ class PitchClassArray < EndlessArray
13
+
14
+ attr_reader :intervals
15
+
16
+ #
17
+ # +Mext::PitchClassArray.new(me = [], rv = 0)+
18
+ #
19
+ # create an endless array which is supposed to
20
+ # be filled up with pitch classes
21
+ #
22
+ def initialize(me = [], rv = 0)
23
+ super
24
+ condition_pitches!
25
+ @intervals = create_interval_array
26
+ end
27
+
28
+ private
29
+
30
+ #
31
+ # +condition_pitches!+ transform all numbers in pitch classes
32
+ # for further processing. We check that n is not nil to manage
33
+ # rests and so on.
34
+ #
35
+ def condition_pitches!
36
+ self.each_index do
37
+ |idx|
38
+ if self[idx]
39
+ tmp = Mext::Music::PitchClass.new(self[idx].to_f)
40
+ self[idx] = tmp
41
+ end
42
+ end
43
+ end
44
+
45
+ #
46
+ # the interval array is an array of semitones (not pitch classes)
47
+ #
48
+ def create_interval_array
49
+ res = EndlessArray.new
50
+ last_pch = self.first
51
+ unless self.empty?
52
+ self[1..-1].each do
53
+ |pch|
54
+ intv = last_pch && pch ? (pch - last_pch).to_semitones : nil
55
+ res << intv
56
+ last_pch = pch
57
+ end
58
+ end
59
+ res
60
+ end
61
+
62
+ end
63
+
64
+ end
data/lib/mext/array.rb CHANGED
@@ -11,4 +11,5 @@ end
11
11
  scalarop
12
12
  fill
13
13
  endless_array
14
+ pitch_class_array
14
15
  ).each { |f| require File.join(Mext::ARRAY_PATH, f) }
@@ -195,7 +195,7 @@ module Mext
195
195
  # negative to subtract.
196
196
  #
197
197
  def add_semitones(semi)
198
- self.class.create_from_semitones((self.inner_representation + semi).cround)
198
+ self.class.create_from_semitones((self.inner_representation + semi.to_f).cround)
199
199
  end
200
200
 
201
201
  #:doc:
@@ -208,7 +208,7 @@ module Mext
208
208
  # negative to subtract.
209
209
  #:nodoc:
210
210
  def add_semitones!(semi)
211
- @semi += semi
211
+ @semi += semi.to_f
212
212
  self
213
213
  end
214
214
 
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mext
2
- VERSION = '0.18.3'
2
+ VERSION = '0.19.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-mext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.3
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicola Bernardini
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-27 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: wavefile
@@ -147,6 +147,7 @@ files:
147
147
  - lib/mext/array/dotop.rb
148
148
  - lib/mext/array/endless_array.rb
149
149
  - lib/mext/array/fill.rb
150
+ - lib/mext/array/pitch_class_array.rb
150
151
  - lib/mext/array/scalarop.rb
151
152
  - lib/mext/array/vectorize.rb
152
153
  - lib/mext/exceptions.rb