tonal-tools 5.1.1 → 5.1.3
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 +4 -4
- data/data/commas.yml +8 -6
- data/lib/tonal/approximation.rb +2 -24
- data/lib/tonal/attributions.rb +1 -1
- data/lib/tonal/cents.rb +1 -0
- data/lib/tonal/comma.rb +5 -11
- 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/data/commas.yml
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
commas:
|
2
|
-
# Interval between two enharmonically equivalent notes, as B# and C, in the Pythogorean tuning. ~23 cents
|
3
|
-
ditonic: 531441/524288
|
4
|
-
# The interval between a just major third (5:4) and a Pythogorean third (81:64). ~22 cents
|
5
|
-
syntonic: 81/80
|
6
|
-
# Difference between the syntonic and ditonic commas. ~2 cents
|
7
|
-
schisma: 32805/32768
|
8
2
|
diaschisma: 2048/2025
|
3
|
+
# Interval between 16/15 and 10/9, 27/25 and 9/8, 6/5 and 5/4, 8/5 and 5/3, 16/9 and 50/27, 9/5 and 15/8. ~71¢
|
4
|
+
dicot: 25/24
|
9
5
|
dieses1: 648/625
|
10
6
|
dieses2: 128/125
|
7
|
+
# Interval between two enharmonically equivalent notes, as B# and C, in the Pythogorean tuning. ~23¢
|
8
|
+
ditonic: 531441/524288
|
9
|
+
# Difference between the syntonic and ditonic commas. ~2¢
|
10
|
+
schisma: 32805/32768
|
11
11
|
septimal: 64/63
|
12
|
+
# The interval between a just major third (5:4) and a Pythogorean third (81:64). ~22¢
|
13
|
+
syntonic: 81/80
|
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/cents.rb
CHANGED
data/lib/tonal/comma.rb
CHANGED
@@ -2,9 +2,9 @@ class Tonal::Comma
|
|
2
2
|
# @return [Hash] of comma key/value pairs
|
3
3
|
# @example
|
4
4
|
# Tonal::Comma.commas
|
5
|
-
# => {"
|
6
|
-
# "
|
7
|
-
# "
|
5
|
+
# => {"diaschisma"=>"2048/2025",
|
6
|
+
# "dicot"=>"25/24",
|
7
|
+
# "dieses1"=>"648/625",
|
8
8
|
# ...}
|
9
9
|
#
|
10
10
|
def self.commas
|
@@ -14,10 +14,7 @@ class Tonal::Comma
|
|
14
14
|
# @return [Array] of comma values
|
15
15
|
# @example
|
16
16
|
# Tonal::Comma.values
|
17
|
-
# => [(
|
18
|
-
# (81/80),
|
19
|
-
# (32805/32768),
|
20
|
-
# ...]
|
17
|
+
# => [(2048/2025), (25/24), (648/625), ...]
|
21
18
|
#
|
22
19
|
def self.values
|
23
20
|
@values ||= commas.values.map(&:to_r)
|
@@ -26,10 +23,7 @@ class Tonal::Comma
|
|
26
23
|
# @return [Array] of comma keys
|
27
24
|
# @example
|
28
25
|
# Tonal::Comma.keys
|
29
|
-
# => ["
|
30
|
-
# "syntonic",
|
31
|
-
# "schisma",
|
32
|
-
# ...]
|
26
|
+
# => ["diaschisma", "dicot", "dieses1", ...]
|
33
27
|
#
|
34
28
|
def self.keys
|
35
29
|
@keys ||= commas.keys
|
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
|