tonal-tools 0.2.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tonal/approximations.rb +1 -1
- data/lib/tonal/comma.rb +28 -0
- data/lib/tonal/ratio.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc35954dbfa03dfe0acca0efda8508d06cffc3259fd7f9d959ff260e099c2de5
|
4
|
+
data.tar.gz: 1de6de9804f88b954ec67720e5b29a3de83a6c6d49577de5a679745b5f4491ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f9cd04eab65b20ddf0263910c661337c6a02d47ebabc5277eeaf7358e686f38283d1158ef985ee238625330b338acca9090021d22c10128d92955b3d5f59891
|
7
|
+
data.tar.gz: '0858ee0672ee37381878371622d7b46471341e56e7c85bceae5c447a3112199330d59931f5ba070fb5a82d6fd9e1e42d8f66838edb229707c9afbdadb13222cd'
|
data/lib/tonal/approximations.rb
CHANGED
@@ -30,7 +30,7 @@ class Tonal::Ratio
|
|
30
30
|
self_in_cents = to_cents
|
31
31
|
within = cents_tolerance.kind_of?(Tonal::Cents) ? cents_tolerance : Tonal::Cents.new(cents: cents_tolerance)
|
32
32
|
[].tap do |results|
|
33
|
-
ContinuedFraction.new(antecedent.to_f/consequent, conv_limit).
|
33
|
+
ContinuedFraction.new(antecedent.to_f/consequent, conv_limit).convergents.each do |convergent|
|
34
34
|
ratio2 = ratio.class.new(convergent.numerator,convergent.denominator)
|
35
35
|
results << ratio2 if ratio.class.within_cents?(self_in_cents, ratio2.to_cents, within) && ratio2.within_prime?(max_prime)
|
36
36
|
break if results.length >= depth
|
data/lib/tonal/comma.rb
CHANGED
@@ -1,16 +1,44 @@
|
|
1
1
|
class Tonal::Comma
|
2
|
+
# @return [Hash] of comma key/value pairs
|
3
|
+
# @example
|
4
|
+
# Tonal::Comma.commas
|
5
|
+
# => {"ditonic"=>"531441/524288",
|
6
|
+
# "syntonic"=>"81/80",
|
7
|
+
# "schisma"=>"32805/32768",
|
8
|
+
# ...}
|
9
|
+
#
|
2
10
|
def self.commas
|
3
11
|
@commas ||= JSON.parse(YAML::load_file("#{__dir__}/../../data/commas.yml", aliases: true).to_json)["commas"]
|
4
12
|
end
|
5
13
|
|
14
|
+
# @return [Array] of comma values
|
15
|
+
# @example
|
16
|
+
# Tonal::Comma.values
|
17
|
+
# => [(531441/524288),
|
18
|
+
# (81/80),
|
19
|
+
# (32805/32768),
|
20
|
+
# ...]
|
21
|
+
#
|
6
22
|
def self.values
|
7
23
|
@values ||= commas.values.map(&:to_r)
|
8
24
|
end
|
9
25
|
|
26
|
+
# @return [Array] of comma keys
|
27
|
+
# @example
|
28
|
+
# Tonal::Comma.keys
|
29
|
+
# => ["ditonic",
|
30
|
+
# "syntonic",
|
31
|
+
# "schisma",
|
32
|
+
# ...]
|
33
|
+
#
|
10
34
|
def self.keys
|
11
35
|
@keys ||= commas.keys
|
12
36
|
end
|
13
37
|
|
38
|
+
# @return [Rational] the comma found in the repo
|
39
|
+
# @example
|
40
|
+
# Tonal::Comma.ditonic => (531441/524288)
|
41
|
+
#
|
14
42
|
def self.method_missing(comma)
|
15
43
|
commas[comma.to_s].to_r
|
16
44
|
end
|
data/lib/tonal/ratio.rb
CHANGED
@@ -474,7 +474,7 @@ class Tonal::Ratio
|
|
474
474
|
|
475
475
|
# @return [String] the string representation of Tonal::Ratio
|
476
476
|
# @example
|
477
|
-
# Tonal::Ratio.new(3, 2).inspect => "
|
477
|
+
# Tonal::Ratio.new(3, 2).inspect => "(3/2)"
|
478
478
|
#
|
479
479
|
def inspect
|
480
480
|
"(#{antecedent}/#{consequent})"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonal-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Hales-Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-12-
|
11
|
+
date: 2023-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yaml
|
@@ -86,28 +86,28 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '2.0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '2.0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: fraction-tree
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '1.0'
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '1.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -188,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
requirements:
|
189
189
|
- - ">="
|
190
190
|
- !ruby/object:Gem::Version
|
191
|
-
version: '
|
191
|
+
version: '3.1'
|
192
192
|
requirements: []
|
193
193
|
rubygems_version: 3.4.22
|
194
194
|
signing_key:
|