plotを使用して音​声ファイルの波形を表​示した際、音源によっ​て1色のグラフと2色​のグラフが描かれるの​ですが、それぞれ何が​違うのか、また1色の​グラフに直すにはどう​したらよいのか教えて​いただきたいです。

[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')

 Accepted Answer

> それぞれ何が​違うのか ⇒ おそらく、モノラル(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列ある
ans = 2×2514
0 0.0100 0.0200 0.0300 0.0400 0.0500 0.0599 0.0699 0.0799 0.0899 0.0998 0.1098 0.1197 0.1296 0.1395 0.1494 0.1593 0.1692 0.1790 0.1888 0.1986 0.2084 0.2182 0.2280 0.2377 0.2474 0.2571 0.2667 0.2763 0.2859 1.0000 0.9999 0.9998 0.9995 0.9992 0.9987 0.9982 0.9975 0.9968 0.9959 0.9950 0.9939 0.9928 0.9915 0.9902 0.9888 0.9872 0.9856 0.9838 0.9820 0.9800 0.9780 0.9759 0.9737 0.9713 0.9689 0.9664 0.9637 0.9610 0.9582
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')

1 Comment

Tsuduri
Tsuduri on 24 Jul 2022
サンプルを使った分かり易い説明ありがとうございます。自分のコードに反映してみます。

Sign in to comment.

More Answers (1)

Hernia Baby
Hernia Baby on 23 Jul 2022

0 votes

ステレオかモノラルの違いだと思います。
size(y)
で確認してみてください。
一つにする場合は大体meanにして両耳からとれるデータの平均をとったりします。

1 Comment

Tsuduri
Tsuduri on 24 Jul 2022
なるほど、確認してみますね。

Sign in to comment.

Categories

Find more on Measurements and Spatial Audio in Help Center and File Exchange

Products

Release

R2022a

Tags

Asked:

on 23 Jul 2022

Commented:

on 24 Jul 2022

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!