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

61 visualizaciones (últimos 30 días)
Tsuduri
Tsuduri el 23 de Jul. de 2022
Comentada: Tsuduri el 24 de Jul. de 2022
[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')

Respuesta aceptada

Atsushi Ueno
Atsushi Ueno el 23 de Jul. de 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列ある
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 comentario
Tsuduri
Tsuduri el 24 de Jul. de 2022
サンプルを使った分かり易い説明ありがとうございます。自分のコードに反映してみます。

Iniciar sesión para comentar.

Más respuestas (1)

Hernia Baby
Hernia Baby el 23 de Jul. de 2022
ステレオかモノラルの違いだと思います。
size(y)
で確認してみてください。
一つにする場合は大体meanにして両耳からとれるデータの平均をとったりします。
  1 comentario
Tsuduri
Tsuduri el 24 de Jul. de 2022
なるほど、確認してみますね。

Iniciar sesión para comentar.

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!