Envelope

2003/8/23 平野拓一(東京工業大学)
2003/8/23 Takuichi Hirano (Tokyo Institute of Technology)

Wave ファイルの読み込み

In[1]:=

SetDirectory["c:/hira2/public_html/hobby/edu/sonic_wave/envelope/fig_math_doc"]

Out[1]=

c:\\hira2\\public_html\\hobby\\edu\\sonic_wave\\envelope\\fig_math_doc

In[2]:=

<< Miscellaneous`Audio` ;

In[3]:=

WaveFormPiano = ReadSoundfile["GrandPiano.wav", PrintHeader -> True] ;

Format:   Microsoft PCM WAVE RIFF

Duration:   5.500498866213152`   seconds

Channels:   1

Sampling rate:   22050

Bits per sample:   8

Data size:   121286   bytes

Number of samples:   121286

音を出して確認

In[4]:=

ListPlay[WaveFormPiano, SampleRate -> 22050, PlayRange -> {-2^16, 2^16}]

[Graphics:HTMLFiles/index_13.gif]

Out[4]=

-Sound -

時間波形を描く

In[5]:=

ListPlot[WaveFormPiano,  ImageSize -> {160, 120},  PlotRange -> {-2^16, 2^16},  PlotJoin ... gt; None,  FrameLabel -> {"Time", "Amplitude", "", ""}]

[Graphics:HTMLFiles/index_16.gif]

Out[5]=

-Graphics -

1周期を切り取る

[入力パラメータ]
smprate: wave ファイルのサンプリングレート
freq: 解析する音の周波数(うまく1周期を切り出すために指定)
n1: 切り出しを開始するリスト要素の開始番号

In[6]:=

smprate = 22050 ; freq = (27.5 * 2^3) * (2^1/12)^3 ; t = 1/freq ; n1 = 20000 ; n = Floor[(t/1) ... rameLabel -> {"Time", "Amplitude", "", ""}] ; n1 = n ;

[Graphics:HTMLFiles/index_19.gif]

離散フーリエ変換してスペクトルを描く

In[22]:=

<< Graphics`Graphics` ; FWaveFormPiano2 = Fourier[WaveFormPiano2] ; FWaveFormPiano2 = Ta ... "},  BarStyle -> {RGBColor[0, 1, 1]},  BarEdgeStyle -> {},  BarGroupSpacing -> 0] ;

[Graphics:HTMLFiles/index_21.gif]

[Graphics:HTMLFiles/index_22.gif]

切り出した1周期をいくつも並べて周期波形を作り、音を聴いてみる

In[29]:=

freq = 440 * (2^1/12)^3 ; t = 1/freq * 1 ; dur = 1.0 ; n2 = Ceiling[dur/t] ; WaveFormPiano3 =  ...  {i, 1, n2}]] ; ListPlay[WaveFormPiano3, SampleRate -> 22050, PlayRange -> {-2^16, 2^16}] ;

[Graphics:HTMLFiles/index_24.gif]

波形を選ぶ

In[35]:=

WaveForm3 = WaveFormPiano3 ;

エンベロープを作る

[Reference]
Roland SC-88 VL, 取扱説明書, p.21

In[36]:=

AttackTime = 0.01 * dur ; DecayTime = 0.9 * dur ; RelaseTime = 0.0 * dur ; AttackLevel = 1 ; S ... t; None,  FrameLabel -> {"Time", "Amplitude", "", ""}]

[Graphics:HTMLFiles/index_27.gif]

[Graphics:HTMLFiles/index_28.gif]

Out[49]=

-Graphics -

エンベロープをかける

In[50]:=

WaveForm4 = EnvelopeForm3 * WaveForm3 ;

In[51]:=

ListPlay[WaveForm4, SampleRate -> 22050, PlayRange -> {-2^16, 2^16}] ;

[Graphics:HTMLFiles/index_32.gif]

In[52]:=

ListPlot[WaveForm4,  ImageSize -> {160, 120},  PlotRange -> {-2^16, 2^16},  PlotJoined - ... gt; None,  FrameLabel -> {"Time", "Amplitude", "", ""}]

[Graphics:HTMLFiles/index_34.gif]

Out[52]=

-Graphics -


Converted by Mathematica  (August 25, 2003)