1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
#! /usr/bin/env python
# encoding: utf-8
"""
Display the sonogram of a sound using a PyoMatrixObject.
A better display can be achieved by using a custom drawing.
After the playback ending, call "m.view()" from the
interpreter widget of the Server window to show the spectrum.
"""
from pyo import *
s = Server(duplex=0).boot()
son = "../snds/baseballmajeur_m.aif"
info = sndinfo(son)
a = SfPlayer(son, mul=0.25).mix(1).out()
size = 512
m = NewMatrix(width=size, height=info[0] // size)
fin = FFT(a * 100, overlaps=1)
mag = Sqrt(fin["real"] * fin["real"] + fin["imag"] * fin["imag"])
rec = MatrixRec(mag * 2 - 1, m, 0).play()
s.gui(locals())
|