tonal-tools 8.3.3 → 8.3.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e4abf5cbb165cd0add4c91cc6d4394219076e7ab5bc02ac52288f6d3f6c278e1
4
- data.tar.gz: 405af2ddb5dcbf483c3dca44a1ba6307d283f0d85b28d20b65c916178963b7d6
3
+ metadata.gz: bdb178eb44ac2841a878052e7ec184d97dbe4b992596c4fc849ba7cbd8c08538
4
+ data.tar.gz: 59043afa410a203fb83c361e8f580a60e2c81903d4b95153ed5f8a8e3285a68e
5
5
  SHA512:
6
- metadata.gz: c516d5914d93c9f563cf0b9b71d2d15c89f408c159010899ea9552d82d176d193c62cd7463ed44c6e287c67efc9091979e5ca7aa4ed3b37d0453e9bebd02690c
7
- data.tar.gz: 72ea362063ea441c121200cc0ec6b9aa6e789047f9090218a3b7d1dbe156c8f0614e88b67911ecbfbc635d7919671f32f41c0f87ea1f66938eb26bd55090e006
6
+ metadata.gz: cbc32bccbf514a8abce43f1627b1795d8517091a452be252325317958075c1c9a13a407f389b12c93426c6786feedfb00c1bb777368e0c625440de605d734cfe
7
+ data.tar.gz: 86d55133cdd853c597d07fdd1017d674aa8cc1898dbe560a31c556877ae2c1567b262bcfd43b68eab9e67f0fe44267d0f02f9c770f5032ca66d4e53a922abab4
@@ -1,4 +1,4 @@
1
1
  module Tonal
2
2
  TOOLS_PRODUCER = "mTonal"
3
- TOOLS_VERSION = "8.3.3"
3
+ TOOLS_VERSION = "8.3.4"
4
4
  end
data/lib/tonal/cents.rb CHANGED
@@ -3,6 +3,7 @@ class Tonal::Cents
3
3
  include Comparable
4
4
 
5
5
  def_delegators :@log, :logarithm, :logarithmand, :base
6
+ def_delegators :@ratio, :numerator, :denominator, :to_reduced_ratio, :to_ratio
6
7
 
7
8
  HUNDREDTHS_ROUNDOFF = -2
8
9
  FLOAT_PRECISION = 100
@@ -40,6 +41,8 @@ class Tonal::Cents
40
41
  end
41
42
  end
42
43
 
44
+ alias :reduced_ratio :to_reduced_ratio
45
+
43
46
  # @return [Tonal::Cents] the default cents tolerance
44
47
  # @example
45
48
  # Tonal::Cents.default_tolerance => 5
@@ -149,8 +152,8 @@ class Tonal::Cents
149
152
  end
150
153
 
151
154
  def derive_ratio(log: nil, ratio: nil)
152
- return Tonal::ReducedRatio.new(log.logarithmand) if log
153
- Tonal::ReducedRatio.new(ratio.numerator, ratio.denominator)
155
+ return Tonal::Ratio.new(log.logarithmand) if log
156
+ Tonal::Ratio.new(ratio.numerator, ratio.denominator)
154
157
  end
155
158
 
156
159
  def derive_cents(cents: nil, log: nil)
data/lib/tonal/hertz.rb CHANGED
@@ -15,9 +15,9 @@ class Tonal::Hertz
15
15
 
16
16
  # @return [Tonal::Hertz] 440 Hz
17
17
  # @example
18
- # Tonal::Hertz.a440 => 440.0 Hz
18
+ # Tonal::Hertz.reference => 440.0 Hz
19
19
  #
20
- def self.a440
20
+ def self.reference
21
21
  self.new(440.0)
22
22
  end
23
23
 
@@ -29,7 +29,6 @@ class Tonal::Hertz
29
29
  Rational(value)
30
30
  end
31
31
 
32
-
33
32
  # @return [Rational] self as a float
34
33
  # @example
35
34
  # Tonal::Hertz.new(440).to_f => 440.0
@@ -38,6 +37,15 @@ class Tonal::Hertz
38
37
  value.to_f
39
38
  end
40
39
 
40
+ # @return [Tonal::Cents] the cents difference between self and a reference frequency
41
+ # @example
42
+ # Tonal::Hertz.new(880).to_cents => 1200.0
43
+ # @param reference [Tonal::Hertz, Numeric] the reference frequency to compare to
44
+ #
45
+ def to_cents(reference: self.class.reference)
46
+ Tonal::Cents.new(ratio: to_r / reference.to_r)
47
+ end
48
+
41
49
  # @return [String] the string representation of Tonal::Hertz
42
50
  # @example
43
51
  # Tonal::Hertz(1000.0).inspect => "1000.0 Hz"
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.3.3
4
+ version: 8.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Hales-Garcia
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-02-26 00:00:00.000000000 Z
10
+ date: 2026-03-22 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: yaml