デジタル信号処理での正弦波の作り方
create_func.py
import numpy as np def create_sin(amplitude,freq,frame,*,sampling = 48000): data = np.zeros(frame,dtype = np.float) for n in np.arange(1,frame): sine = amplitude * np.sin(2 * np.pi * freq * n / sampling) data[n] = sine return data def create_cos(amplitude,freq,frame,*,sampling = 48000): data = np.zeros(frame,dtype = np.float) for n in np.arange(1,frame): cosine = amplitude * np.cos(2 * np.pi * freq * n / sampling) data[n] = sine return data
使い方
import audio_func as af sinewave = cf.create_sin(1.0,1000,frame,sampling=48000)
参考文献