tonal-tools 8.3.4 → 8.5.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 +4 -4
- data/lib/tonal/attributions.rb +1 -1
- data/lib/tonal/cents.rb +11 -11
- data/lib/tonal/extensions.rb +3 -3
- data/lib/tonal/step.rb +11 -3
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 520c39d6d3f6519ad21174305aaa089babd81bccde2416ddc09e2cc22d3f5ae7
|
|
4
|
+
data.tar.gz: 03ecbc849c92b953298c804c7b43caa0c020290dd3a1f183a5cfea3a0728fdaa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 21af61fe964bff3bca95070e3796fcaa77b93e52dadc68314eb52b0dafa08932486cfa988d6bacab9a0dc86b3543d4782534f575304d752b0ad34155785b1578
|
|
7
|
+
data.tar.gz: ba8d2348c7b0d9f50bd8188051c64db63c49dd5d731ad1b2e61c473a844242978809edce8df261b761ff6efb13220f1ebcc737edf45b52a4fea2481e03299fe7
|
data/lib/tonal/attributions.rb
CHANGED
data/lib/tonal/cents.rb
CHANGED
|
@@ -15,7 +15,7 @@ class Tonal::Cents
|
|
|
15
15
|
|
|
16
16
|
# @return [Tonal::Cents]
|
|
17
17
|
# @example
|
|
18
|
-
# Tonal::Cents.new(ratio: 2**(2.0/12)) => 200.0
|
|
18
|
+
# Tonal::Cents.new(ratio: 2**(2.0/12)) => 200.0 ¢
|
|
19
19
|
# @param cents [Numeric, Tonal::Log2]
|
|
20
20
|
# @param log [Numeric, Tonal::Log2]
|
|
21
21
|
# @param ratio [Numeric, Tonal::Log2]
|
|
@@ -45,7 +45,7 @@ class Tonal::Cents
|
|
|
45
45
|
|
|
46
46
|
# @return [Tonal::Cents] the default cents tolerance
|
|
47
47
|
# @example
|
|
48
|
-
# Tonal::Cents.default_tolerance => 5
|
|
48
|
+
# Tonal::Cents.default_tolerance => 5 ¢
|
|
49
49
|
#
|
|
50
50
|
def self.default_tolerance
|
|
51
51
|
self.new(cents: TOLERANCE)
|
|
@@ -53,7 +53,7 @@ class Tonal::Cents
|
|
|
53
53
|
|
|
54
54
|
# @return [Float] value of self
|
|
55
55
|
# @example
|
|
56
|
-
# Tonal::Cents.new(ratio: 2**(1.0/12)).value => 100.00
|
|
56
|
+
# Tonal::Cents.new(ratio: 2**(1.0/12)).value => 100.00 ¢
|
|
57
57
|
#
|
|
58
58
|
def value(precision: @precision)
|
|
59
59
|
@value.round(precision)
|
|
@@ -64,7 +64,7 @@ class Tonal::Cents
|
|
|
64
64
|
# @return
|
|
65
65
|
# [Tonal::Cents] nearest hundredth cent value
|
|
66
66
|
# @example
|
|
67
|
-
# Tonal::Cents.new(cents: 701.9550008653874).nearest_hundredth => 700.0
|
|
67
|
+
# Tonal::Cents.new(cents: 701.9550008653874).nearest_hundredth => 700.0 ¢
|
|
68
68
|
#
|
|
69
69
|
def nearest_hundredth
|
|
70
70
|
self.class.new(cents: value.round(Tonal::Cents::HUNDREDTHS_ROUNDOFF).to_f)
|
|
@@ -73,7 +73,7 @@ class Tonal::Cents
|
|
|
73
73
|
# @return
|
|
74
74
|
# [Tonal::Cents] nearest hundredth cent difference
|
|
75
75
|
# @example
|
|
76
|
-
# Tonal::Cents.new(cents: 701.9550008653874).nearest_hundredth_difference => 1.96
|
|
76
|
+
# Tonal::Cents.new(cents: 701.9550008653874).nearest_hundredth_difference => 1.96 ¢
|
|
77
77
|
#
|
|
78
78
|
def nearest_hundredth_difference
|
|
79
79
|
self.class.new(cents: (value - nearest_hundredth))
|
|
@@ -91,10 +91,10 @@ class Tonal::Cents
|
|
|
91
91
|
# @return
|
|
92
92
|
# [String] the string representation of Tonal::Cents
|
|
93
93
|
# @example
|
|
94
|
-
# Tonal::Cents.new(100.0).inspect =>
|
|
94
|
+
# Tonal::Cents.new(100.0).inspect => 100.0 ¢
|
|
95
95
|
#
|
|
96
96
|
def inspect
|
|
97
|
-
"#{value.round(@precision)}"
|
|
97
|
+
"#{value.round(@precision)} ¢"
|
|
98
98
|
end
|
|
99
99
|
alias :to_s :inspect
|
|
100
100
|
|
|
@@ -102,7 +102,7 @@ class Tonal::Cents
|
|
|
102
102
|
#
|
|
103
103
|
# @return [Tonal::Cents, Numeric] result of operation
|
|
104
104
|
# @example
|
|
105
|
-
# Tonal::Cents.new(cents: 200) - Tonal::Cents.new(cents: 100) => 100.0
|
|
105
|
+
# Tonal::Cents.new(cents: 200) - Tonal::Cents.new(cents: 100) => 100.0 ¢
|
|
106
106
|
# @param rhs [Tonal::Cents, Numeric]
|
|
107
107
|
#
|
|
108
108
|
def -(rhs)
|
|
@@ -111,7 +111,7 @@ class Tonal::Cents
|
|
|
111
111
|
|
|
112
112
|
# @return [Tonal::Cents, Numeric] result of operation
|
|
113
113
|
# @example
|
|
114
|
-
# Tonal::Cents.new(cents: 100) + Tonal::Cents.new(cents: 200) => 300.0
|
|
114
|
+
# Tonal::Cents.new(cents: 100) + Tonal::Cents.new(cents: 200) => 300.0 ¢
|
|
115
115
|
# @param rhs [Tonal::Cents, Numeric]
|
|
116
116
|
#
|
|
117
117
|
def +(rhs)
|
|
@@ -120,7 +120,7 @@ class Tonal::Cents
|
|
|
120
120
|
|
|
121
121
|
# @return [Tonal::Cents, Numeric] result of operation
|
|
122
122
|
# @example
|
|
123
|
-
# Tonal::Cents.new(cents: 200) * 2 => 400.0
|
|
123
|
+
# Tonal::Cents.new(cents: 200) * 2 => 400.0 ¢
|
|
124
124
|
# @param rhs [Tonal::Cents, Numeric]
|
|
125
125
|
#
|
|
126
126
|
def *(rhs)
|
|
@@ -129,7 +129,7 @@ class Tonal::Cents
|
|
|
129
129
|
|
|
130
130
|
# @return [Tonal::Cents, Numeric] result of operation
|
|
131
131
|
# @example
|
|
132
|
-
# Tonal::Cents.new(cents: 400) / 2 => 200.0
|
|
132
|
+
# Tonal::Cents.new(cents: 400) / 2 => 200.0 ¢
|
|
133
133
|
# @param rhs [Tonal::Cents, Numeric]
|
|
134
134
|
#
|
|
135
135
|
def /(rhs)
|
data/lib/tonal/extensions.rb
CHANGED
|
@@ -142,11 +142,11 @@ class Numeric
|
|
|
142
142
|
#
|
|
143
143
|
def wilson_height(reduced: false, equave: 2/1r, prime_rejects: [2]) = ratio(reduced:, equave:).wilson_height(prime_rejects:)
|
|
144
144
|
|
|
145
|
-
# @return [
|
|
145
|
+
# @return [Tonal::Cents] the cents difference between self and its step in the given modulo
|
|
146
146
|
# @example
|
|
147
|
-
# (3/2r).efficiency(12) => -1.96
|
|
147
|
+
# (3/2r).efficiency(12) => -1.96 ¢
|
|
148
148
|
# @example
|
|
149
|
-
# (3/2r).efficiency(12, is_step_efficiency: true) => 1.96
|
|
149
|
+
# (3/2r).efficiency(12, is_step_efficiency: true) => 1.96 ¢
|
|
150
150
|
# @param modulo against which the difference of self is compared
|
|
151
151
|
# @param reduced if true, self is reduced to the octave before calculating efficiency
|
|
152
152
|
# @param is_step_efficiency if true, calculates the efficiency of the step instead of the ratio (self). If the step efficiency is X cents, then the ratio efficiency is -X cents.
|
data/lib/tonal/step.rb
CHANGED
|
@@ -78,15 +78,23 @@ class Tonal::Scale
|
|
|
78
78
|
|
|
79
79
|
# @return [Tonal::Cents] the difference between the step and the ratio
|
|
80
80
|
# @example
|
|
81
|
-
# Tonal::Scale::Step.new(ratio: 3/2r, modulo: 31).efficiency
|
|
82
|
-
# => 5.19
|
|
81
|
+
# Tonal::Scale::Step.new(ratio: 3/2r, modulo: 31).efficiency => 5.19 ¢
|
|
83
82
|
#
|
|
84
83
|
def efficiency
|
|
85
|
-
# We want the efficiency from the step (self).
|
|
84
|
+
# We want the efficiency from the step (self). The step is the tempered approximation of the ratio, so we want to know how far off the step is from the ratio. So we take the ratio and subtract the step.
|
|
86
85
|
ratio_to_cents - step_to_cents
|
|
87
86
|
end
|
|
88
87
|
alias :cents_difference :efficiency
|
|
89
88
|
|
|
89
|
+
# @return [Boolean] true if the step is coprime to the modulo
|
|
90
|
+
# @example
|
|
91
|
+
# Tonal::Scale::Step.new(step: 5, modulo: 12).coprime? => true
|
|
92
|
+
# Tonal::Scale::Step.new(step: 6, modulo: 12).coprime? => false
|
|
93
|
+
#
|
|
94
|
+
def coprime?
|
|
95
|
+
step.coprime?(modulo)
|
|
96
|
+
end
|
|
97
|
+
|
|
90
98
|
def +(rhs)
|
|
91
99
|
self.class.new(step: (rhs % modulo), modulo: modulo)
|
|
92
100
|
end
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: tonal-tools
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 8.
|
|
4
|
+
version: 8.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jose Hales-Garcia
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-05-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: yaml
|
|
@@ -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: 4.0.
|
|
195
|
+
rubygems_version: 4.0.8
|
|
196
196
|
specification_version: 4
|
|
197
197
|
summary: Tonal tools
|
|
198
198
|
test_files: []
|