MATLAB Answers

why does the sound with different sampling frequency sounds the same ?

32 ビュー (過去 30 日間)
Yanjika O
Yanjika O 2020 年 7 月 7 日
コメント済み: Akira Agata 2020 年 7 月 7 日
Dear people,
I am trying to write an audio with the following lines. However, every after I write an audio into a file and play it, they sound the same no matter what the sampling frequency is.
clear all
clc
FrequencySampling = 2500; % 2500 for safe 10000 for shock
duration =17;
repeats=1;
t = linspace(0, duration, FrequencySampling*duration+1); % Time Vector + 1 sample
t(end) = []; % remove extra sample
w = 2*pi*1000; % Radian Value To Create 1kHz Tone
for i=1:repeats
s = sin(w*t);
sound(s,FrequencySampling);
pause(5) %ITI 60 sec
end
audiowrite('shock.wav',s,FrequencySampling);
Please recommend me any possible reasons or let me know if I have done sth wrong.

  0 件のコメント

サインインしてコメントする。

採用された回答

Akira Agata
Akira Agata 2020 年 7 月 7 日
That's the basic of the 'Sampling theorem'. As long as frequency component of the signal is less than Nyquist frequency ( = sampling frequency * 0.5), the original signal can be re-generated.
Looking at your code, the signal frequency is 1 [kHz] and both sampling frequencies (2.5 [kHz] and 10 [kHz]) satisfy the Nyquist condition. So the regeneratd signal sounds the same.

  2 件のコメント

Yanjika O
Yanjika O 2020 年 7 月 7 日
Then, how to make them different in terms of sampling frequency (2.5kHz and 10kHz)?
Akira Agata
Akira Agata 2020 年 7 月 7 日
Then you need to compare one re-generated signal with sufficient sampling frequency (= satisfies Nyquist condition) and another signal with insufficient sampling frequency.
The following is an example. (please compare the two .wav files with different sampling frequency)
load handel.mat
% Sufficient sampling frequency (8192 [Hz])
audiowrite('handel_8192.wav',y,Fs);
% Insufficient sampling frequency (4096 [Hz])
audiowrite('handel_4096.wav',y(1:2:end),Fs/2);

サインインしてコメントする。

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by