History

[py] add note2freq to midiconv.py

Paul Brossier committed 8 years ago

Commit 6f944b51 parent 1f07bdd1 file · +24 −1Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/lib/aubio/midiconv.py+24−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 __all__ = ['note2midi', 'midi2note', 'freq2note']
55
66 import sys
7−from ._aubio import freqtomidi
7+from ._aubio import freqtomidi, miditofreq
88
99 py3 = sys.version_info[0] == 3
1010 if py3:
@@ -75,3 +75,26 @@ def freq2note(freq): · 64 unmodified lines
7575 " convert frequency in Hz to nearest note name, e.g. [0, 22050.] -> [C-1, G9] "
7676 nearest_note = int(freqtomidi(freq) + .5)
7777 return midi2note(nearest_note)
78+
79+def note2freq(note):
80+ """Convert note name to corresponding frequency, in Hz.
81+
82+ Parameters
83+ ----------
84+ note : str
85+ input note name
86+
87+ Returns
88+ -------
89+ freq : float [0, 23000[
90+ frequency, in Hz
91+
92+ Example
93+ -------
94+ >>> aubio.note2freq('A4')
95+ 440
96+ >>> aubio.note2freq('A3')
97+ 220.1
98+ """
99+ midi = note2midi(note)
100+ return miditofreq(midi)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t