tonal-tools 5.1.2 → 5.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tonal/approximation.rb +2 -24
- data/lib/tonal/attributions.rb +1 -1
- data/lib/tonal/extensions.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b17d9b6d7c072e412308a4fc2c4954ae3ed4517ea052afb253d110f1eec20a5
|
4
|
+
data.tar.gz: 47e961d46ac7dadc1aff2714d1a3cac2fa1926083522bcf88b79b32fc61b795c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8dee328415918bc354b1b4456a655cd2537a4a293fa21cb7131f599567e16ff44590a31b38c00a9e328a7ba39db6255ede3f8ab2a543819293f351e98ea723bc
|
7
|
+
data.tar.gz: 7924160f12e04fee8feb4cbadcbb3f3ea3ca61d015f9e78d122dbda37423b8c0be701c3c6bc77d06590f998f18278be3c645fe21483ce8bf4d8c22f445fdafe9
|
data/lib/tonal/approximation.rb
CHANGED
@@ -41,28 +41,6 @@ class Tonal::Ratio
|
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
# @return [Tonal::Ratio::Approximation::Set] of ratios within cent tolerance of self found using a quotient walk on the fraction tree
|
45
|
-
# @example
|
46
|
-
# Tonal::Ratio.ed(12,1).approximate.by_quotient_walk(max_prime: 89)
|
47
|
-
# => (4771397596969315/4503599627370496): [(17/16), (18/17), (35/33), (53/50), (71/67), (89/84), (196/185)]
|
48
|
-
# @param cents_tolerance the cents tolerance used to scope the collection
|
49
|
-
# @param depth the maximum number of ratios in the collection
|
50
|
-
# @param max_prime the maximum prime number to allow in the collection
|
51
|
-
# @param conv_limit the number of convergents to limit the ContinuedFraction method
|
52
|
-
#
|
53
|
-
def by_quotient_walk(cents_tolerance: Tonal::Cents::TOLERANCE, depth: DEFAULT_FRACTION_TREE_DEPTH, max_prime: DEFAULT_MAX_PRIME, conv_limit: CONVERGENT_LIMIT)
|
54
|
-
self_in_cents = to_cents
|
55
|
-
within = cents_tolerance.kind_of?(Tonal::Cents) ? cents_tolerance : Tonal::Cents.new(cents: cents_tolerance)
|
56
|
-
|
57
|
-
Set.new(ratio: ratio) do |ratios|
|
58
|
-
FractionTree.quotient_walk(to_f, limit: conv_limit).each do |node|
|
59
|
-
ratio2 = ratio.class.new(node.weight)
|
60
|
-
ratios << ratio2 if ratio.class.within_cents?(self_in_cents, ratio2.to_cents, within) && ratio2.within_prime?(max_prime)
|
61
|
-
break if ratios.length >= depth
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
44
|
# @return [Tonal::Ratio::Approximation::Set] of fraction tree ratios within cent tolerance of self
|
67
45
|
# @example
|
68
46
|
# Tonal::Ratio.ed(12,1).approximate.by_tree_path(max_prime: 17)
|
@@ -75,8 +53,8 @@ class Tonal::Ratio
|
|
75
53
|
self_in_cents = to_cents
|
76
54
|
within = cents_tolerance.kind_of?(Tonal::Cents) ? cents_tolerance : Tonal::Cents.new(cents: cents_tolerance)
|
77
55
|
Set.new(ratio: ratio) do |ratios|
|
78
|
-
FractionTree.
|
79
|
-
ratio2 = ratio.class.new(node.
|
56
|
+
FractionTree.node(to_f).path.each do |node|
|
57
|
+
ratio2 = ratio.class.new(node.number)
|
80
58
|
ratios << ratio2 if ratio.class.within_cents?(self_in_cents, ratio2.to_cents, within) && ratio2.within_prime?(max_prime)
|
81
59
|
break if ratios.length >= depth
|
82
60
|
end
|
data/lib/tonal/attributions.rb
CHANGED
data/lib/tonal/extensions.rb
CHANGED
@@ -32,7 +32,7 @@ class Numeric
|
|
32
32
|
# @return [Array] a tuple of self divided and multiplied by factor
|
33
33
|
# @example
|
34
34
|
# Math::PI.div_times(3) => [1.0471975511965976, 9.42477796076938]
|
35
|
-
# @param [Numeric]
|
35
|
+
# @param factor [Numeric]
|
36
36
|
#
|
37
37
|
def div_times(factor) = [self / factor, self * factor]
|
38
38
|
|
@@ -329,7 +329,7 @@ class Array
|
|
329
329
|
# @return [Tonal::ReducedRatio] ratio reconstructed from the result of a prime factor decomposition
|
330
330
|
# @example
|
331
331
|
# [[[3, 1]], [[2, 1]]].ratio_from_prime_divisions => (3/2)
|
332
|
-
# @reduced [Boolean] if a reduced or unreduced ratio is returned
|
332
|
+
# @param reduced [Boolean] if a reduced or unreduced ratio is returned
|
333
333
|
#
|
334
334
|
def ratio_from_prime_divisions(reduced: false) = reduced ? Tonal::ReducedRatio.new(Prime.int_from_prime_division(self.first), Prime.int_from_prime_division(self.last)) : Tonal::Ratio.new(Prime.int_from_prime_division(self.first), Prime.int_from_prime_division(self.last))
|
335
335
|
|
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: 5.1.
|
4
|
+
version: 5.1.3
|
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: 2024-
|
11
|
+
date: 2024-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yaml
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '2.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: '
|
110
|
+
version: '2.0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: rspec
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -192,7 +192,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
192
192
|
- !ruby/object:Gem::Version
|
193
193
|
version: '3.1'
|
194
194
|
requirements: []
|
195
|
-
rubygems_version: 3.5.
|
195
|
+
rubygems_version: 3.5.18
|
196
196
|
signing_key:
|
197
197
|
specification_version: 4
|
198
198
|
summary: Tonal tools
|