Module: StringTensions

Defined in:
lib/string_tensions.rb,
lib/string_tensions/convert.rb,
lib/string_tensions/version.rb

Defined Under Namespace

Modules: Convert

Constant Summary collapse

K =
386.4
VERSION =
"0.0.2"

Class Method Summary collapse

Class Method Details

.freq_from_pitch(pitch) ⇒ Object



27
28
29
# File 'lib/string_tensions.rb', line 27

def self.freq_from_pitch(pitch)
  NoteFrequencies.frequency_from_name(pitch)
end

.tension(uw_lbs_inch, length_in_inches, freq) ⇒ Object



9
10
11
12
# File 'lib/string_tensions.rb', line 9

def self.tension(uw_lbs_inch, length_in_inches, freq)
  # T (Tension) =  (UW  x (2 x L x F)**2) / 386.4
  (uw_lbs_inch * (2 * length_in_inches * freq)**2) / K
end

.tension_for_pitch(uw_lbs_inch, length_in_inches, pitch) ⇒ Object



14
15
16
# File 'lib/string_tensions.rb', line 14

def self.tension_for_pitch(uw_lbs_inch, length_in_inches, pitch)
  tension(uw_lbs_inch, length_in_inches, freq_from_pitch(pitch))
end

.uw(tension_lbs, length_inches, freq) ⇒ Object



18
19
20
21
# File 'lib/string_tensions.rb', line 18

def self.uw(tension_lbs, length_inches, freq)
  # UW (unit weight) =  (T x 386.4) / (2 x L x F)**2
  ((tension_lbs * K) / (2 * length_inches * freq)**2).to_f
end

.uw_for_pitch(tension_lbs, length_inches, pitch) ⇒ Object



23
24
25
# File 'lib/string_tensions.rb', line 23

def self.uw_for_pitch(tension_lbs, length_inches, pitch)
  uw(tension_lbs, length_inches, freq_from_pitch(pitch))
end