ruby-mext 0.18.3 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mext/array/pitch_class_array.rb +64 -0
- data/lib/mext/array.rb +1 -0
- data/lib/mext/music/pitch_class.rb +2 -2
- data/lib/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 615ac635788737a15b34dc6f376546de1eacd70cf117ee36d9006ed384c60132
|
4
|
+
data.tar.gz: 536b40b3cbaf894438b744f800276c54a5a2909de635e4e395e75bc056f96098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
@@ -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
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.
|
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-
|
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
|