tonal-tools 6.1.0 → 6.2.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/irb_helpers.rb +1 -1
- data/lib/tonal/log.rb +3 -1
- data/lib/tonal/ratio.rb +9 -5
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 376c78c5867487f0dd93564d78de0554c5f9cd7f464b10f5f594b5654504e0f9
|
4
|
+
data.tar.gz: b8123b975596eee6a159300e959f9b4654bf61c982c31102e091c39c234a8ee9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ae64384b4cf0363870ebde93dc893b614326b0fc7aa7347629ab1cc80c7bd8ad2202b29f809f43c060ef9e813309f5ebd6839fb2951a510beb856805ed63d96
|
7
|
+
data.tar.gz: 153ac1322ec44b4d61f564a439418dec54bf38db71847d91eedf09e87080bcf6c4fff7a62f91cdb14cb4260ef04234bd17b981cb1cad2f02cd7424d67077b106
|
data/lib/tonal/attributions.rb
CHANGED
data/lib/tonal/irb_helpers.rb
CHANGED
@@ -12,7 +12,7 @@ module Tonal
|
|
12
12
|
|
13
13
|
# @return [Tonal::ReducedRatio] a reduced ratio
|
14
14
|
# @example
|
15
|
-
#
|
15
|
+
# rr(3,3) => (1/1)
|
16
16
|
# @param arg1 the ratio if only argument provided, or the numerator if two argments are provided
|
17
17
|
# @param arg2 the denominator when two arguments are provided
|
18
18
|
#
|
data/lib/tonal/log.rb
CHANGED
@@ -4,6 +4,8 @@ class Tonal::Log
|
|
4
4
|
|
5
5
|
def_delegators :@logarithmand, :ratio, :to_ratio
|
6
6
|
|
7
|
+
PRECISION = 2
|
8
|
+
|
7
9
|
attr_reader :logarithmand, :logarithm, :base
|
8
10
|
|
9
11
|
# @return [Tonal::Log]
|
@@ -72,7 +74,7 @@ class Tonal::Log
|
|
72
74
|
# Tonal::Log.new(logarithmand: 3/2r, base: 2).inspect => "0.58"
|
73
75
|
#
|
74
76
|
def inspect
|
75
|
-
"#{logarithm.round(
|
77
|
+
"#{logarithm.round(PRECISION)}"
|
76
78
|
end
|
77
79
|
|
78
80
|
def <=>(rhs)
|
data/lib/tonal/ratio.rb
CHANGED
@@ -4,8 +4,12 @@ class Tonal::Ratio
|
|
4
4
|
|
5
5
|
def_delegators :@approximation, :neighborhood
|
6
6
|
|
7
|
+
PRECISION = 2
|
8
|
+
|
7
9
|
attr_reader :antecedent, :consequent, :equave, :reduced_antecedent, :reduced_consequent
|
8
10
|
|
11
|
+
attr_accessor :label
|
12
|
+
|
9
13
|
# @return [Tonal::Ratio]
|
10
14
|
# @example
|
11
15
|
# Tonal::Ratio.new(3,2) => (3/2)
|
@@ -180,7 +184,7 @@ class Tonal::Ratio
|
|
180
184
|
# Tonal::Ratio.new(3,2).period_degrees => 210.59
|
181
185
|
# @param round
|
182
186
|
#
|
183
|
-
def period_degrees(round:
|
187
|
+
def period_degrees(round: PRECISION)
|
184
188
|
(360.0 * Math.log(to_f, equave)).round(round)
|
185
189
|
end
|
186
190
|
|
@@ -189,7 +193,7 @@ class Tonal::Ratio
|
|
189
193
|
# Tonal::Ratio.new(3,2).period_radians => 3.68
|
190
194
|
# @param round
|
191
195
|
#
|
192
|
-
def period_radians(round:
|
196
|
+
def period_radians(round: PRECISION)
|
193
197
|
(2 * Math::PI * Math.log(to_f, equave)).round(round)
|
194
198
|
end
|
195
199
|
|
@@ -313,7 +317,7 @@ class Tonal::Ratio
|
|
313
317
|
# Tonal::Ratio.new(3,2).planar_degrees => 33.69
|
314
318
|
# @param round
|
315
319
|
#
|
316
|
-
def planar_degrees(round:
|
320
|
+
def planar_degrees(round: PRECISION)
|
317
321
|
(Math.atan2(consequent, antecedent) * 180/Math::PI).round(round)
|
318
322
|
end
|
319
323
|
|
@@ -322,7 +326,7 @@ class Tonal::Ratio
|
|
322
326
|
# Tonal::Ratio.new(3,2).planar_radians => 0.59
|
323
327
|
# @param round
|
324
328
|
#
|
325
|
-
def planar_radians(round:
|
329
|
+
def planar_radians(round: PRECISION)
|
326
330
|
Math.atan2(consequent, antecedent).round(round)
|
327
331
|
end
|
328
332
|
|
@@ -468,7 +472,7 @@ class Tonal::Ratio
|
|
468
472
|
# Return label, if defined; or,
|
469
473
|
# Return the "antecedent/consequent", if antecedent is less than 7 digits long; or
|
470
474
|
# Return the floating point representation rounded to 2 digits of precision
|
471
|
-
(@label || ((Math.log10(antecedent).to_i + 1) <= 6 ? "#{antecedent}/#{consequent}" : to_f.round(
|
475
|
+
(@label || ((Math.log10(antecedent).to_i + 1) <= 6 ? "#{antecedent}/#{consequent}" : to_f.round(PRECISION))).to_s
|
472
476
|
end
|
473
477
|
|
474
478
|
# @return [String] the string representation of Tonal::Ratio
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tonal-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Hales-Garcia
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-01-11 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: yaml
|
@@ -178,7 +177,6 @@ licenses:
|
|
178
177
|
metadata:
|
179
178
|
source_code_uri: https://github.com/mTonal/tools/
|
180
179
|
documentation_uri: https://mtonal.github.io/tools/
|
181
|
-
post_install_message:
|
182
180
|
rdoc_options: []
|
183
181
|
require_paths:
|
184
182
|
- lib
|
@@ -193,8 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
193
191
|
- !ruby/object:Gem::Version
|
194
192
|
version: '3.1'
|
195
193
|
requirements: []
|
196
|
-
rubygems_version: 3.
|
197
|
-
signing_key:
|
194
|
+
rubygems_version: 3.6.2
|
198
195
|
specification_version: 4
|
199
196
|
summary: Tonal tools
|
200
197
|
test_files: []
|