Class: Tonal::Ratio

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
Comparable
Defined in:
lib/tonal/approximation.rb,
lib/tonal/ratio.rb

Direct Known Subclasses

ReducedRatio

Defined Under Namespace

Classes: Approximation

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(antecedent, consequent = nil, label: nil, equave: 2) ⇒ Tonal::Ratio

Examples:

Tonal::Ratio.new(3,2) => (3/2)

Parameters:

Raises:

  • (ArgumentError)


15
16
17
18
19
20
# File 'lib/tonal/ratio.rb', line 15

def initialize(antecedent, consequent=nil, label: nil, equave: 2/1r)
  raise ArgumentError, "Antecedent must be Numeric" unless antecedent.kind_of?(Numeric)
  raise ArgumentError, "Consequent must be Numeric or nil" unless (consequent.kind_of?(Numeric) || consequent.nil?)

  _initialize(antecedent, consequent, label:, equave:)
end

Instance Attribute Details

#antecedentObject (readonly) Also known as: numerator

Returns the value of attribute antecedent.



7
8
9
# File 'lib/tonal/ratio.rb', line 7

def antecedent
  @antecedent
end

#consequentObject (readonly) Also known as: denominator

Returns the value of attribute consequent.



7
8
9
# File 'lib/tonal/ratio.rb', line 7

def consequent
  @consequent
end

#equaveObject (readonly)

Returns the value of attribute equave.



7
8
9
# File 'lib/tonal/ratio.rb', line 7

def equave
  @equave
end

#reduced_antecedentObject (readonly)

Returns the value of attribute reduced_antecedent.



7
8
9
# File 'lib/tonal/ratio.rb', line 7

def reduced_antecedent
  @reduced_antecedent
end

#reduced_consequentObject (readonly)

Returns the value of attribute reduced_consequent.



7
8
9
# File 'lib/tonal/ratio.rb', line 7

def reduced_consequent
  @reduced_consequent
end

Class Method Details

.ed(modulo, step, equave: 2) ⇒ Tonal::Ratio

Returns the ratio of step in the modulo.

Examples:

Tonal::Ratio.ed(12, 7)
  => (4771397596969315/4503599627370496)

Parameters:

  • modulo
  • step
  • equave (defaults to: 2)

Returns:



78
79
80
# File 'lib/tonal/ratio.rb', line 78

def self.ed(modulo, step, equave: 2/1r)
  self.new(2**(step.to_f/modulo), equave: equave)
end

.random_ratio(number_of_factors = 2, within: 100, reduced: false) ⇒ Tonal::Ratio

Returns a randomly generated ratio.

Examples:

Tonal::Ratio.random_ratio => (169/1)

Parameters:

  • number_of_factors (defaults to: 2)
  • within (defaults to: 100)

Returns:



59
60
61
62
63
64
65
66
67
68
# File 'lib/tonal/ratio.rb', line 59

def self.random_ratio(number_of_factors = 2, within: 100, reduced: false)
  primes = Prime.each(within).to_a
  nums = []
  dens = []
  1.upto(number_of_factors) do
    nums << [primes[rand(10)], rand(3)]
    dens << [primes[rand(10)], rand(3)]
  end
  [nums, dens].ratio_from_prime_divisions(reduced:)
end

.superparticular(n, factor: 1, superpart: :upper) ⇒ Tonal::Ratio

Returns ratio who’s numerator and denominator are seperated by a difference of 1.

Examples:

Tonal::Ratio.superparticular(100) = (101/100)

Parameters:

  • n (Integer)

    number from which the superior part is calculated

  • factor (Rational) (defaults to: 1)

    multiplied into the resulting ratio, default 1/1

  • superpart (Symbol) (defaults to: :upper)

    assigning the superior part to the antecedent or consequent

Returns:

  • (Tonal::Ratio)

    ratio who’s numerator and denominator are seperated by a difference of 1



32
33
34
# File 'lib/tonal/ratio.rb', line 32

def self.superparticular(n, factor: 1/1r, superpart: :upper)
  superpartient(n, summand: 1, factor:, superpart:)
end

.superpartient(n, summand:, factor: 1, superpart: :upper) ⇒ Tonal::Ratio

Returns ratio who’s numerator and denominator are separated by a summand difference.

Examples:

Tonal::Ratio.superpartient(23, summand: 3) => (26/23)

Parameters:

  • n (Integer)

    number from which the superior part is calculated

  • summand (Integer)

    term added to the superior part

  • factor (Rational) (defaults to: 1)

    multiplied into the resulting ratio, default 1/1

  • superpart (Symbol) (defaults to: :upper)

    assigning the superior part to the antecedent or consequent

Returns:

  • (Tonal::Ratio)

    ratio who’s numerator and denominator are separated by a summand difference



44
45
46
47
48
49
50
51
# File 'lib/tonal/ratio.rb', line 44

def self.superpartient(n, summand:, factor: 1/1r, superpart: :upper)
  case superpart.to_sym.downcase
  when :lower, :consequent, :denominator
    self.new(n*factor.numerator, (n+summand)*factor.denominator)
  else
    self.new((n+summand)*factor.numerator, n*factor.denominator)
  end
end

.within_cents?(cents1, cents2, within) ⇒ Boolean

Returns if pair of ratios are within the given cents limit.

Examples:

Tonal::Ratio.within_cents?(100, 105, 2) => true

Parameters:

  • cents1
  • cents2
  • within

Returns:

  • (Boolean)

    if pair of ratios are within the given cents limit



89
90
91
# File 'lib/tonal/ratio.rb', line 89

def self.within_cents?(cents1, cents2, within)
  (cents1 - cents2).abs <= within
end

Instance Method Details

#*(rhs) ⇒ Object



486
487
488
# File 'lib/tonal/ratio.rb', line 486

def *(rhs)
  self.class.new(antecedent * rhs.antecedent, consequent * rhs.consequent)
end

#**(rhs) ⇒ Object



494
495
496
# File 'lib/tonal/ratio.rb', line 494

def **(rhs)
  operate(rhs, :**)
end

#+(rhs) ⇒ Object



478
479
480
# File 'lib/tonal/ratio.rb', line 478

def +(rhs)
  operate(rhs, :+)
end

#-(rhs) ⇒ Object



482
483
484
# File 'lib/tonal/ratio.rb', line 482

def -(rhs)
  operate(rhs, :-)
end

#/(rhs) ⇒ Object



490
491
492
# File 'lib/tonal/ratio.rb', line 490

def /(rhs)
  self.class.new(antecedent * rhs.consequent, consequent * rhs.antecedent)
end

#<=>(rhs) ⇒ Object



540
541
542
543
544
# File 'lib/tonal/ratio.rb', line 540

def <=>(rhs)
  left = consequent == 0 ? Float::INFINITY : Rational(antecedent, consequent)
  right = rhs.denominator == 0 ? Float::INFINITY : Rational(rhs.numerator, rhs.denominator)
  left <=> right
end

#approximateTonal::Ratio::Approximation

Returns self’s approximation instance.

Returns:



101
102
103
# File 'lib/tonal/ratio.rb', line 101

def approximate
  @approximation
end

#benedetti_heightInteger Also known as: product_complexity

Returns the product complexity of self.

Examples:

Tonal::ReducedRatio.new(3/2r).benedetti_height => 6

Returns:

  • (Integer)

    the product complexity of self



379
380
381
# File 'lib/tonal/ratio.rb', line 379

def benedetti_height
  reduced_antecedent * reduced_consequent
end

#cent_diff(other_ratio) ⇒ Tonal::Cents

Returns cent difference between self and other ratio.

Examples:

Tonal::ReducedRatio.new(3,2).cent_diff(4/3r) => 203.92

Parameters:

Returns:

  • (Tonal::Cents)

    cent difference between self and other ratio



456
457
458
# File 'lib/tonal/ratio.rb', line 456

def cent_diff(other_ratio)
  cents - other_ratio.ratio.cents
end

#combinationInteger Also known as: comb

Returns the sum of antecedent and consequent.

Examples:

Tonal::ReducedRatio.new(3,2).combination => 5

Returns:

  • (Integer)

    the sum of antecedent and consequent



535
536
537
# File 'lib/tonal/ratio.rb', line 535

def combination
  antecedent + consequent
end

#differenceInteger Also known as: diff

Returns the difference between antecedent and consequent.

Examples:

Tonal::ReducedRatio.new(3,2).difference => 1

Returns:

  • (Integer)

    the difference between antecedent and consequent



526
527
528
# File 'lib/tonal/ratio.rb', line 526

def difference
  antecedent - consequent
end

#div_times(ratio) ⇒ Array

Returns the results of ratio dividing and multiplying self.

Examples:

Tonal::ReducedRatio.new(3/2r).div_times(5/4r) => [(6/5), (15/8)]

Parameters:

  • ratio

Returns:

  • (Array)

    the results of ratio dividing and multiplying self



435
436
437
438
# File 'lib/tonal/ratio.rb', line 435

def div_times(ratio)
  ratio = ratio.ratio
  [self / ratio, self * ratio]
end

#efficiency(modulo) ⇒ Tonal::Cents

Returns the cents difference between self and its step in the given modulo.

Examples:

Tonal::ReducedRatio.new(3,2).efficiency(12) => -1.955000865387433

Parameters:

  • modulo

Returns:

  • (Tonal::Cents)

    the cents difference between self and its step in the given modulo



424
425
426
427
428
# File 'lib/tonal/ratio.rb', line 424

def efficiency(modulo)
  # We want the efficiency from the ratio, instead of from the step.
  # If step efficiency is X cents, then ratio efficiency is -X cents.
  step(modulo).efficiency * -1.0
end

#equave_reduce(equave = 2) ⇒ Tonal::Ratio Also known as: reduce, reduced

Returns copy of self reduced to the given equave.

Examples:

Tonal::Ratio.new(48,14).equave_reduce(3) => (8/7)

Parameters:

  • equave (defaults to: 2)

    Numeric

Returns:

  • (Tonal::Ratio)

    copy of self reduced to the given equave



210
211
212
# File 'lib/tonal/ratio.rb', line 210

def equave_reduce(equave=2/1r)
  self.class.new(*_equave_reduce(equave))
end

#equave_reduce!(equave = 2) ⇒ Tonal::Ratio Also known as: reduce!, reduced!

Returns self reduced to the given equave.

Examples:

Tonal::Ratio.new(48,14).equave_reduce!(3) => (8/7)

Parameters:

  • equave (defaults to: 2)

    Numeric

Returns:



221
222
223
224
# File 'lib/tonal/ratio.rb', line 221

def equave_reduce!(equave=2/1r)
  @antecedent, @consequent = _equave_reduce(equave)
  self
end

#fraction_reduceTonal::Ratio

Returns copy of self rationally reduced.

Examples:

Tonal::Ratio.new(16,14).fraction_reduce => (8/7)

Returns:

See Also:



201
202
203
# File 'lib/tonal/ratio.rb', line 201

def fraction_reduce
  self.class.new(to_r)
end

#inspectString Also known as: to_s

Returns the string representation of Tonal::Ratio.

Examples:

Tonal::Ratio.new(3, 2).inspect => "(3/2)"

Returns:

  • (String)

    the string representation of Tonal::Ratio



473
474
475
# File 'lib/tonal/ratio.rb', line 473

def inspect
  "(#{antecedent}/#{consequent})"
end

#invertTonal::Ratio Also known as: reflect

Returns copy of self with the antecedent and precedent switched.

Examples:

Tonal::Ratio.new(3,2).invert => (2/3)

Returns:

  • (Tonal::Ratio)

    copy of self with the antecedent and precedent switched



241
242
243
# File 'lib/tonal/ratio.rb', line 241

def invert
  self.class.new(consequent, antecedent)
end

#invert!Tonal::Ratio

Returns with antecedent and precedent switched.

Examples:

Tonal::Ratio.new(3,2).invert! => (2/3)

Returns:



250
251
252
253
# File 'lib/tonal/ratio.rb', line 250

def invert!
  _initialize(consequent, antecedent, label: label, equave: equave)
  self
end

#labelString

Returns symbolic representation of Tonal::Ratio.

Returns:

  • (String)

    symbolic representation of Tonal::Ratio



462
463
464
465
466
467
# File 'lib/tonal/ratio.rb', line 462

def label
  # Return label, if defined; or,
  # Return the "antecedent/consequent", if antecedent is less than 7 digits long; or
  # Return the floating point representation rounded to 2 digits of precision
  (@label || ((Math.log10(antecedent).to_i + 1) <= 6 ? "#{antecedent}/#{consequent}" : to_f.round(Tonal::Cents::PRECISION))).to_s
end

#lcm(lhs) ⇒ Integer

Returns the least common multiple with self’s denominator and the given number’s denominator.

Examples:

Tonal::Ratio.new(3/2r).lcm(5/4r) => 4

Parameters:

Returns:

  • (Integer)

    the least common multiple with self’s denominator and the given number’s denominator



518
519
520
# File 'lib/tonal/ratio.rb', line 518

def lcm(lhs)
  [self.denominator, lhs.denominator].lcm
end

#log_weil_heightTonal::Log2

Returns the log of Weil height.

Examples:

Tonal::ReducedRatio.new(3/2r).log_weil_height => 1.5849625007211563

Returns:



407
408
409
# File 'lib/tonal/ratio.rb', line 407

def log_weil_height
  Tonal::Log2.new(logarithmand: weil_height)
end

#max_primeInteger

Returns the maximum prime factor of self.

Examples:

Tonal::Ratio.new(31/30r).max_prime => 31

Returns:

  • (Integer)

    the maximum prime factor of self



359
360
361
# File 'lib/tonal/ratio.rb', line 359

def max_prime
  prime_divisions.flatten(1).map(&:first).max
end

#mediant_sum(number) ⇒ Tonal::Ratio Also known as: mediant, farey_sum

Returns the mediant (Farey) sum of self and another number.

Examples:

Tonal::Ratio.new(3,2).mediant_sum(4/3r) => (7/5)

Parameters:

Returns:

  • (Tonal::Ratio)

    the mediant (Farey) sum of self and another number



503
504
505
# File 'lib/tonal/ratio.rb', line 503

def mediant_sum(number)
  self.class.new(antecedent + number.numerator, consequent + number.denominator)
end

#min_primeInteger

Returns the minimum prime factor of self.

Examples:

Tonal::Ratio.new(31/30r).min_prime => 2

Returns:

  • (Integer)

    the minimum prime factor of self



367
368
369
# File 'lib/tonal/ratio.rb', line 367

def min_prime
  prime_divisions.flatten(1).map(&:first).min
end

#mirror(axis = 1) ⇒ Tonal::Ratio

Returns the mirror of self along the axis (default 1/1).

Examples:

Tonal::Ratio.new(4,3).mirror => (3/2)

Parameters:

  • axis (defaults to: 1)

Returns:

  • (Tonal::Ratio)

    the mirror of self along the axis (default 1/1)



260
261
262
# File 'lib/tonal/ratio.rb', line 260

def mirror(axis=1/1r)
  (self.class.new(axis) ** 2) / self
end

#negativeTonal::ReducedRatio

Returns the Ernst Levy negative of self.

Examples:

Tonal::ReducedRatio.new(7/4r).negative => (12/7)

Returns:



268
269
270
# File 'lib/tonal/ratio.rb', line 268

def negative
  self.class.new(3/2r) / self
end

#period_degrees(round: 2) ⇒ Float

Returns degrees.

Examples:

Tonal::Ratio.new(3,2).period_degrees => 210.59

Parameters:

  • round (defaults to: 2)

Returns:

  • (Float)

    degrees



183
184
185
# File 'lib/tonal/ratio.rb', line 183

def period_degrees(round: 2)
  (360.0 * Math.log(to_f, equave)).round(round)
end

#period_radians(round: 2) ⇒ Float

Returns radians.

Examples:

Tonal::Ratio.new(3,2).period_radians => 3.68

Parameters:

  • round (defaults to: 2)

Returns:

  • (Float)

    radians



192
193
194
# File 'lib/tonal/ratio.rb', line 192

def period_radians(round: 2)
  (2 * Math::PI * Math.log(to_f, equave)).round(round)
end

#planar_degrees(round: 2) ⇒ Float

Returns degrees of antecedent (x) and consequent (y) on a 2D plane.

Examples:

Tonal::Ratio.new(3,2).planar_degrees => 33.69

Parameters:

  • round (defaults to: 2)

Returns:

  • (Float)

    degrees of antecedent (x) and consequent (y) on a 2D plane



316
317
318
# File 'lib/tonal/ratio.rb', line 316

def planar_degrees(round: 2)
  (Math.atan2(consequent, antecedent) * 180/Math::PI).round(round)
end

#planar_radians(round: 2) ⇒ Float

Returns radians.

Examples:

Tonal::Ratio.new(3,2).planar_radians => 0.59

Parameters:

  • round (defaults to: 2)

Returns:

  • (Float)

    radians



325
326
327
# File 'lib/tonal/ratio.rb', line 325

def planar_radians(round: 2)
  Math.atan2(consequent, antecedent).round(round)
end

#plus_minus(ratio) ⇒ Array Also known as: min_plus

Returns the results of ratio subtracted and added to self.

Examples:

Tonal::ReducedRatio.new(3/2r).plus_minus(5/4r) => [(1/1), (11/8)]

Parameters:

  • ratio

Returns:

  • (Array)

    the results of ratio subtracted and added to self



445
446
447
448
# File 'lib/tonal/ratio.rb', line 445

def plus_minus(ratio)
  ratio = ratio.ratio
  [self - ratio, self + ratio]
end

#prime_divisionsArray

Returns , self decomposed into its prime factors.

Examples:

Tonal::Ratio.new(31/30r).prime_divisions => [[[31, 1]], [[2, 1], [3, 1], [5, 1]]]

Returns:

  • (Array)

    , self decomposed into its prime factors



333
334
335
336
# File 'lib/tonal/ratio.rb', line 333

def prime_divisions
  return [[[2, 1]], [[2, 1]]] if antecedent == 1
  [antecedent.prime_division, consequent.prime_division]
end

#prime_vectorVector Also known as: monzo

Returns , self represented as a prime vector.

Examples:

Tonal::Ratio.new(3/2r).prime_vector => Vector[-1, 1]

Returns:

  • (Vector)

    , self represented as a prime vector



342
343
344
345
346
347
348
349
350
351
352
# File 'lib/tonal/ratio.rb', line 342

def prime_vector
  pds = prime_divisions
  max = [pds.first.max{|p| p.first}, pds.last.max{|p| p.first}].max.first

  pds.last.collect!{|i| [i.first, -i.last]}

  p_arr = Prime.each(max).to_a
  Array.new(p_arr.count, 0).tap do |arr|
    pds.flatten(1).each{|e| arr[p_arr.find_index(e.first)] = e.last}
  end.to_vector
end

#ratioTonal::Ratio

Returns convenience method returning self.

Returns:



95
96
97
# File 'lib/tonal/ratio.rb', line 95

def ratio
  self
end

#scale(a, b = a) ⇒ Tonal::Ratio

Returns self scaled by given arguments.

Examples:

Tonal::Ratio.new(3,2).scale(2**5) => (96/64)

Parameters:

Returns:



295
296
297
298
# File 'lib/tonal/ratio.rb', line 295

def scale(a, b=a)
  raise_if_negative(a,b)
  self.class.new(*(Matrix[[a, 0],[0, b]] * Vector[antecedent, consequent]))
end

#shear(a, b = a) ⇒ Tonal::Ratio

Returns self sheared by given arguments.

Examples:

Tonal::Ratio.new(3,2).shear(1, 3) => (9/11)

Parameters:

Returns:



306
307
308
309
# File 'lib/tonal/ratio.rb', line 306

def shear(a, b=a)
  raise_if_negative(a,b)
  self.class.new(*((Matrix[[1,a],[0,1]] * Matrix[[1,0], [b,1]]) * Vector[antecedent, consequent]))
end

#step(modulo = 12) ⇒ Integer

Returns the step of self in the given modulo.

Examples:

Tonal::ReducedRatio.new(3,2).step(12) => 7

Returns:

  • (Integer)

    the step of self in the given modulo



174
175
176
# File 'lib/tonal/ratio.rb', line 174

def step(modulo=12)
  Tonal::Step.new(ratio: to_r, modulo: modulo)
end

#tenney_heightTonal::Log2 Also known as: log_product_complexity, harmonic_distance

Returns the log product complexity of self.

Examples:

Tonal::ReducedRatio.new(3/2r).tenney_height => 2.584962500721156

Returns:



388
389
390
# File 'lib/tonal/ratio.rb', line 388

def tenney_height
  Tonal::Log2.new(logarithmand: benedetti_height)
end

#to_aArray

Returns antecedent and consequent as elements of Array.

Examples:

Tonal::Ratio.new(3,2).to_a => [3, 2]

Returns:

  • (Array)

    antecedent and consequent as elements of Array



113
114
115
# File 'lib/tonal/ratio.rb', line 113

def to_a
  [antecedent, consequent]
end

#to_centsTonal::Cents Also known as: cents

Returns cents value of self.

Examples:

Tonal::Ratio.new(3,2).to_cents => 701.96

Returns:



165
166
167
# File 'lib/tonal/ratio.rb', line 165

def to_cents
  Tonal::Cents.new(ratio: to_r)
end

#to_fFloat

Returns self as a Float.

Examples:

Tonal::Ratio.new(3,2).to_f => 1.5

Returns:

  • (Float)

    self as a Float



138
139
140
# File 'lib/tonal/ratio.rb', line 138

def to_f
  antecedent.to_f / consequent.to_f
end

#to_log(base = 2) ⇒ Tonal::Log Also known as: log

Returns Math.log of self in given base.

Examples:

Tonal::Ratio.new(3,2).log(3) => 0.3690702464285425

Parameters:

  • base (defaults to: 2)

Returns:



147
148
149
# File 'lib/tonal/ratio.rb', line 147

def to_log(base=2)
  Tonal::Log.new(logarithmand: to_r, base: base)
end

#to_log2Tonal::Log2 Also known as: log2

Returns Math.log2 of self.

Examples:

Tonal::ReducedRatio.new(3,2).to_log2 => 0.5849625007211562

Returns:



156
157
158
# File 'lib/tonal/ratio.rb', line 156

def to_log2
  Tonal::Log2.new(logarithmand: to_r)
end

#to_rRational

Returns self as a Rational.

Examples:

Tonal::Ratio.new(3,2).to_r => (3/2)

Returns:

  • (Rational)

    self as a Rational



129
130
131
132
# File 'lib/tonal/ratio.rb', line 129

def to_r
  return Float::INFINITY if consequent.zero? || !antecedent.finite?
  Rational(antecedent, consequent)
end

#to_reduced_ratioTonal::ReducedRatio Also known as: reduced_ratio

Returns of self.

Examples:

Tonal::Ratio.new(1,9).to_reduced_ratio => (16/9)

Returns:



232
233
234
# File 'lib/tonal/ratio.rb', line 232

def to_reduced_ratio
  Tonal::ReducedRatio.new(reduced_antecedent, reduced_consequent, equave: equave)
end

#to_vVector

Returns antecedent and consequent as elements of Vector.

Examples:

Tonal::Ratio.new(3,2).to_v => Vector[3, 2]

Returns:

  • (Vector)

    antecedent and consequent as elements of Vector



121
122
123
# File 'lib/tonal/ratio.rb', line 121

def to_v
  Vector[antecedent, consequent]
end

#translate(x = 1, y = 0) ⇒ Tonal::Ratio

Ratio grid transformations numerator mapped on x-axis, denominator mapped on y-axis

Examples:

Tonal::Ratio.new(3,2).translate(3,3) => (6/5)

Parameters:

Returns:

  • (Tonal::Ratio)

    with the antecedent and consequent translated by x and y



284
285
286
287
# File 'lib/tonal/ratio.rb', line 284

def translate(x=1, y=0)
  raise_if_negative(x,y)
  self.class.new(*(Vector[antecedent, consequent] + Vector[x, y]))
end

#weil_heightInteger

Returns the Weil height.

Examples:

Tonal::ReducedRatio.new(3/2r).weil_height => 3

Returns:



398
399
400
# File 'lib/tonal/ratio.rb', line 398

def weil_height
  [reduced_antecedent, reduced_consequent].max
end

#wilson_height(prime_rejects: [2]) ⇒ Integer

Returns the Wilson height. The sum of self’s prime factors (greater than 2) times the absolute values of their exponents.

Examples:

Tonal::ReducedRatio.new(14/9r).wilson_height => 13

Returns:

  • (Integer)

    the Wilson height. The sum of self’s prime factors (greater than 2) times the absolute values of their exponents



415
416
417
# File 'lib/tonal/ratio.rb', line 415

def wilson_height(prime_rejects: [2])
  benedetti_height.prime_division.reject{|p| prime_rejects.include?(p.first) }.sum{|p| p.first * p.last }
end

#within_prime?(prime) ⇒ Boolean

Returns:

  • (Boolean)


371
372
373
# File 'lib/tonal/ratio.rb', line 371

def within_prime?(prime)
  max_prime <= prime
end