実行すると音階ドレミファソラシドを順に鳴らすようなプログラムを作成しているのですが下のコードのy部分がいろいろ試したのですがエラーを吐いてしまいうまく行きません。分かる方いたら回答お願いします。ちなみに配列として扱って音声をつなぎ合わせるようなコードを書いてます。
Python
1# -*- coding: utf-8 -*- 2 3import numpy as np 4import scipy.fftpack as spf 5 6from scipy.io.wavfile import write 7import matplotlib.pylab as plt 8 9def GenFreq(Fc, Fs, dur): 10 delta = 1./Fs 11 Nmax = Fs * dur 12 t = np.arange(Nmax) * delta 13 x = Amp * np.sin(2. * np.pi * Fc * t) 14 return x 15 16Fs = 22100. # サンプリング周波数 17Fcs = [262, 294, 330, 349, 392, 440, 494, 523] 18dur=3. # 3秒のデータ 19Amp=4000. # 振幅 20 21sound=GenFreq(Fcs[0],Fs,dur) #初め 22for i in range(7): # その後に音声をつなげていく 23 sound=np.r_[sound,GenFreq(Fcs[i+1],Fs,dur)] 24 25y= # y に音声波形を入れたものとしてファイルを保存(ここが分からない) 26fname = 'MkSnd4Test.wav' 27write(fname, Fs, y) 28
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。