tonal-tools 8.6.0 → 8.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 25126d841103214bbe0a1fe1dcd861460ff4bf7b108ac3e0854032e037f64ab1
4
- data.tar.gz: 3f3941c9a097f937d08f5c0b9fc1edec5df331b45d12599b0dcedfaa275ed6b4
3
+ metadata.gz: 65ae90958bc67835b5792e9d248eebf51ef5625f5bf3e1fa2da75064f76865d9
4
+ data.tar.gz: b9620ff46f3ded909da90d12af35326fa85387000f1432b768d8377b205f78c4
5
5
  SHA512:
6
- metadata.gz: 4c8828863ca77987db6837fbbff67a8f74029d8b817418596a3a0ce6959fbd09ffb174a7dc4142a1d67ed8fadc5d85e3694ee87155c1ea064b6760cf73d3baae
7
- data.tar.gz: 54122f26528a2fa0866abc7e9c2e23ffee7dbb64a8d9ed192c48c205b233b365b9064847d667a7e95cfd90b23f0424bc9799ff098426e27b4be727d45cc6c489
6
+ metadata.gz: d73630cb8dec599a68d9f85731f676c3193d0f4f038f5757ace29a77ae8af65b5c74a5808f808605baa0e7392137b3200a4241b22f73870a788de4afb6c4f11a
7
+ data.tar.gz: 18977208ddb36b81b446e5559acf7e1618baf360fdf49f75b567e0c6407727077840846b0ce0ada874a428e1c2ae3d281abe484d4f0d27c115c905cc76c1b191
@@ -1,4 +1,4 @@
1
1
  module Tonal
2
2
  TOOLS_PRODUCER = "mTonal"
3
- TOOLS_VERSION = "8.6.0"
3
+ TOOLS_VERSION = "8.7.0"
4
4
  end
data/lib/tonal/midi.rb CHANGED
@@ -4,6 +4,7 @@ module Tonal::Midi
4
4
 
5
5
  REFERENCE_FREQUENCY = 440.0
6
6
  A4_MIDI_NUMBER = 69
7
+ C4_MIDI_NUMBER = 60
7
8
 
8
9
  attr_reader :number, :frequency
9
10
 
@@ -32,7 +33,7 @@ module Tonal::Midi
32
33
  end
33
34
 
34
35
  def <=>(other)
35
- number <=> other.number
36
+ number <=> (other.kind_of?(self.class) ? other.number : other)
36
37
  end
37
38
  end
38
39
  end
data/lib/tonal/step.rb CHANGED
@@ -58,6 +58,22 @@ class Tonal::Scale
58
58
  Tonal::Ratio.new(step, modulo)
59
59
  end
60
60
 
61
+ # @return the [Tonal::Midi::Note] representation of the step
62
+ #
63
+ # @example
64
+ # Tonal::Scale::Step.new(ratio: 3/2r, modulo: 31).step_to_midi
65
+ # => 78
66
+ # Tonal::Scale::Step.new(ratio: 3/2r, modulo: 12).step_to_midi
67
+ # => 67
68
+ # Tonal::Scale::Step.new(ratio: 3/2r, modulo: 12).step_to_midi(midi_root: Tonal::Midi::Note::A4_MIDI_NUMBER)
69
+ # => 76
70
+ #
71
+ # @param midi_root [Integer] the MIDI number that corresponds to the 0 step of the scale. Default is C4 (60 MIDI).
72
+ #
73
+ def step_to_midi(midi_root: Tonal::Midi::Note::C4_MIDI_NUMBER)
74
+ Tonal::Midi::Note.new(number: step + midi_root)
75
+ end
76
+
61
77
  # @return the [Rational] representation of the ratio of self
62
78
  # @example
63
79
  # Tonal::Scale::Step.new(ratio: 3/2r, modulo: 31).ratio_to_r
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.6.0
4
+ version: 8.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Hales-Garcia
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-05-26 00:00:00.000000000 Z
10
+ date: 2026-06-02 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: yaml