Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Yell at the mic, see the frequencies on the terminal
from aubio import source, pitch, freqtomidi, sink
from pysoundcard import Stream
if __name__ == '__main__':
win_s = 1024 #fft size
hop_s = 512 #hop size. Whatever that means
s = Stream(block_length = hop_s)
#Use yin algorithm. Better than normal fft and
#more aligned with human perception of sound
pitch_o = pitch("yin", win_s, hop_s, 44100)
while True:
vec =
#s.input_channels =1. Creating a mono vector in
#case there is more than 1 channel
mono_vec = vec.sum(-1)/float(s.input_channels)
samples = mono_vec
pitch = pitch_o(samples)[0]
print pitch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.