jeudi 22 janvier 2015

concatenate sinusoids of varying frequency

It's my first time working with audio and I'm trying to concatenate sinusoids of arbitrary (data-driven) frequencies, and can't get rid of the clicking noises caused by discontinuities in between the sins.


I was reading this thread on making frequency a function of phase in order to increase the frequency of a wave linearly, but couldn't figure out how to adapt this for arbitrarily shifting frequencies.


I was playing around with calculating the phase shift from the previous sinusoid, and then trying to shift the next one accordingly, but this just seemed to make the sound more high pitched and didn't remove the clicking.



def audio_map(data):
p=[]
phase = 0
for point in data:
if point[0]<0:
f=100*np.abs(point[0])
else:
f=100*point[0]
#Do something with the phase to shift the sinusoid below???
p=np.concatenate((p,np.sin((4*np.pi*f/sampling_rate)*np.arange(sampling_rate*np.pi/(16)))))
phase=f*np.pi/16

return p


Thanks for any help!!


Aucun commentaire:

Enregistrer un commentaire