> #ライブラリの読み込み。wavファイルのプレイソフト名の登録
> library(tuneR)
tuneR >= 1.0 has changed its Wave class definition.
Use updateWave(object) to convert Wave objects saved with previous versions of tuneR.
> library(seewave)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Welcome to seewave !
The package is regularly updated, please check for new version [http://r...content-available-to-author-only...n.fr/seewave]
Thanks to use the right reference when citing seewave in publications
See citation('seewave')
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> setWavPlayer("play")
>
> #波形作成
> t <- seq(0,2,1/44100) # 時間 44100サンプル/秒 のデータを2秒分
> s1 <- (2^15-1)*sin(2*pi*t*440)*(1:length(t))/length(t) # 440Hzのsin波を時間とともに振幅線形的に増大
> s2 <- (2^15-1)*sin(2*pi*t*880)*(length(t):1)/length(t) # 880Hzのsin波を時間とともに振幅線形的に減少
>
> # 音データを作成
> w <- Wave(s1+s2,bit=16)
警告メッセージ:
In .local(left, ...) : 'samp.rate' not specified, assuming 44100Hz
> writeWave(w,"test002.wav") # wavファイルとして書きだし。
警告メッセージ:
In writeWave(w, "test002.wav") :
channels' data will be rounded to integers for writing the wave file
>
> # 演奏
> play(w)
/tmp/RtmpkVHVFa/tuneRtemp.wav:
File Size: 176k Bit Rate: 706k
Encoding: Signed PCM
Channels: 1 @ 16-bit
Samplerate: 44100Hz
Replaygain: off
Duration: 00:00:02.00
In:0.00% 00:00:00.00 [00:00:02.00] Out:0 [ | ] Clip:0
In:46.4% 00:00:00.93 [00:00:01.07] Out:41.0k [!=====|=====!] Clip:0
In:55.7% 00:00:01.11 [00:00:00.89] Out:49.2k [======|======] Hd:0.0 Clip:0
In:65.0% 00:00:01.30 [00:00:00.70] Out:57.3k [======|======] Hd:0.0 Clip:0
In:74.3% 00:00:01.49 [00:00:00.51] Out:65.5k [======|======] Hd:0.0 Clip:0
In:83.6% 00:00:01.67 [00:00:00.33] Out:73.7k [!=====|=====!] Hd:0.0 Clip:0
In:92.9% 00:00:01.86 [00:00:00.14] Out:81.9k [!=====|=====!] Hd:0.0 Clip:0
In:100% 00:00:02.00 [00:00:00.00] Out:88.2k [!=====|=====!] Hd:0.0 Clip:0
In:100% 00:00:02.00 [00:00:00.00] Out:88.2k [ | ] Hd:0.0 Clip:0
Done.
警告メッセージ:
In writeWave(object, filename) :
channels' data will be rounded to integers for writing the wave file
>
> # スペクトル解析
> png('test002.png');
> d <- spectro(w,osc=T);
> title('test002');
> dev.off()
null device
1
>
> # spectroのかえりち。このなかのampを使いたい。
> str(d)
List of 3
$ time: num [1:172] 0 0.0117 0.0234 0.0351 0.0468 ...
$ freq: num [1:256] 0 0.0861 0.1723 0.2584 0.3445 ...
$ amp : num [1:256, 1:172] -74.2 -72.9 -69.9 -65.9 -53.1 ...
> a<-d["amp"] # or a<-d[3]