next up previous
Next: A. 弦の固有振動 Up: Mathematica で Fourier 解析 Previous: 5 Dirichlet 核 のグラフを描いてみる

6 WAVEファイルの内容を FFT する

snd = Import["http://nalab.mind.meiji.ac.jp/~mk/fourier/piano-do-mi-so.wav"]

{left, right} = snd[[1, 1]];
sr = snd[[1, 2]]
take[tbl_, t1_, t2_] := Take[tbl, {Floor[t1*sr], Floor[t2*sr]}]
take1[tbl_, t_] := Take[tbl, {Floor[t*sr], Floor[t*sr] + sr - 1}]

g = ListPlot[tbl = take1[left, 1.0], PlotRange -> All]

ListPlay[tbl]
ListPlay[tbl, SampleRate -> sr]
ListPlay[tbl, SampleRate -> sr/2]
ListPlay[tbl, SampleRate -> 2*sr]
ListPlay[tbl, SampleRate -> Floor[sr*1.5]]

c = Fourier[tbl, FourierParameters -> {-1, -1}];
g = ListPlot[Abs[c], Joined -> True, PlotRange -> All]

cutoff[f_] := 
  Join[Table[1, {n, f + 1}], Table[0, {n, sr - 2*f - 1}],  Table[1, {n, f}]];

440.0*2^(-{9, 5, 2}/12)
c2 = c*cutoff[500];
g3 = ListPlot[Abs[c2], Joined -> True, PlotRange -> All]
tbl2 = Re[InverseFourier[c2, FourierParameters -> {-1, -1}]];
ListPlay[tbl2, SampleRate -> sr]

do = Re[InverseFourier[c*cutoff[300], FourierParameters -> {-1, -1}]];
domi = Re[InverseFourier[c*cutoff[360], FourierParameters -> {-1, -1}]];
domiso = Re[InverseFourier[c*cutoff[450], FourierParameters -> {-1, -1}]];
domiso2 = Re[InverseFourier[c*cutoff[900], FourierParameters -> {-1, -1}]];
original = Re[InverseFourier[c, FourierParameters -> {-1, -1}]];

ListPlay[do, SampleRate -> sr]
ListPlay[domi, SampleRate -> sr]
ListPlay[domiso, SampleRate -> sr]
ListPlay[domiso2, SampleRate -> sr]
ListPlay[original, SampleRate -> sr]


next up previous
Next: A. 弦の固有振動 Up: Mathematica で Fourier 解析 Previous: 5 Dirichlet 核 のグラフを描いてみる
桂田 祐史
2016-01-14