plotを使用して音声ファイルの波形を表示した際、音源によって1色のグラフと2色のグラフが描かれるのですが、それぞれ何が違うのか、また1色のグラフに直すにはどうしたらよいのか教えていただきたいです。
    25 views (last 30 days)
  
       Show older comments
    
[y,Fs] = audioread(['filename'])
info = audioinfo('filename')
t = 0:seconds(1/Fs):seconds(info.Duration)
t = t(1:end-1)
plot(t,y)
xlabel('Time')
ylabel('Audio Signal')
0 Comments
Accepted Answer
  Atsushi Ueno
      
 on 23 Jul 2022
        > それぞれ何が違うのか ⇒ おそらく、モノラル(1ch) / ステレオ(2ch)の違いです
> 1色のグラフに直すにはどうしたらよいのか ⇒ グラフの描画色を変更すれば良いです
2色のグラフが描かれるステレオ(2ch)の場合を下記に再現しました。
x1 = sin(0:0.01:8*pi)'; % 1chのサンプルデータ(正弦波) 注:音声として聞き取れません
x2 = cos(0:0.01:8*pi)'; % 2chのサンプルデータ(余弦波) 注:音声として聞き取れません
audiowrite('sample.wav', [x1 x2], 8192); % サンプル音声ファイルの作成
[y,Fs] = audioread('sample.wav');
y' % ステレオ音声なので音声データyが2列ある
info = audioinfo('sample.wav');
t = 0:seconds(1/Fs):seconds(info.Duration);
t = t(1:end-1);
plot(t,y,'b'); % ライン色を一律青に設定
xlabel('Time')
ylabel('Audio Signal')
More Answers (1)
See Also
Categories
				Find more on Measurements and Spatial Audio in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!