Skip to content

@ttm /vibrato.py
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Vibrato in PCM audio (fixed!)
#-*- coding: utf8 -*-
#FIXED!!!
import numpy as n, pylab as p, scikits.audiolab as a
fa=44100 # sample rate
Dv=2048 # length of the table
fv=6. # vibrato frequency
nu=.2 # depth in semitones
f=440. # freq of the sound itself
x=n.linspace(0,2*n.pi,Dv,endpoint=False)
tabv=n.sin(x) # sin table
ii=n.arange(fa * 2) # 2 seconds
gv=n.array(ii*fv*float(Dv)/fa, n.int) # indexes of the vibrato pattern
tv=tabv[gv%Dv]*nu # instant semitones deviation for each PCM sample
fi=f*( 2.**( tv/12. ) ) # instant freq in Hz of the sound
dD=fi*(Dv/float(fa))
gi=n.cumsum(dD,0,n.int)%Dv
ti=tabv[gi]
a.wavwrite(ti,"vibrato.wav",fa)
ff=n.ones(ii.shape[0])*f
gi=n.array( ii * (Dv/float(fa)) * ff , n.int ) % Dv
t=tabv[ gi ]
a.wavwrite(t,"original.wav",fa)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.