MCPcopy Create free account
hub / github.com/bspaans/python-mingus / from_hertz

Method from_hertz

mingus/containers/note.py:235–246  ·  view source on GitHub ↗

Set the Note name and pitch, calculated from the hertz value. The standard_pitch argument can be used to set the pitch of A-4, from which the rest is calculated.

(self, hertz, standard_pitch=440)

Source from the content-addressed store, hash-verified

233 return 2 ** (diff / 12.0) * standard_pitch
234
235 def from_hertz(self, hertz, standard_pitch=440):
236 """Set the Note name and pitch, calculated from the hertz value.
237
238 The standard_pitch argument can be used to set the pitch of A-4,
239 from which the rest is calculated.
240 """
241 value = (
242 log((float(hertz) * 1024) / standard_pitch, 2) + 1.0 / 24
243 ) * 12 + 9 # notes.note_to_int("A")
244 self.name = notes.int_to_note(int(value) % 12)
245 self.octave = int(value / 12) - 6
246 return self
247
248 def to_shorthand(self):
249 """Give the traditional Helmhotz pitch notation.

Callers 1

test_from_hertzMethod · 0.95

Calls

no outgoing calls

Tested by 1

test_from_hertzMethod · 0.76