Wave file creation with Sine

조회 수: 8 (최근 30일)
Karthik Brs
Karthik Brs 2016년 4월 21일
댓글: Karthik Brs 2016년 4월 25일
Hello everyone, I have produced a wave sound file for a given data which contains information about the sound pressure and frequency. I am using the equation y = A sin(2*pi*f*t) to produce sound. I am using sound pressure as amplitude. What's strange is, when I produce the sound using this method, I am getting frequency components which are exactly double the original frequency values. When I remove the 2 from the Sin(2*pi*f*t), its working! Also, I observed that, when I use interpolated values for frequency(from 'interp1'), I am getting this 'double frequency' problem, without the interpolation, Sin(2*pi*f*t) works fine. Do any of you have an explanation for this? I am including my script here:
fs = 44100; % Sampling frequency
Paco = 10^-12; % Reference sound power
Po = 2*10^-5; % Reference sound pressure of '20µPa' (at 1000 Hz.)
r = 1; % Distance to the sound source from the listener
Q = 4; % Directivity factor for a point source
filename_audiowrite = sprintf('SSD_audiowrite_%d.wav',ii);
t_ramp = 20; %[secs]
t = 0:1/fs:t_ramp-1/fs;
RPM_max = max(cell2mat(RPM));
Frq = cell2mat(frq);
Wav_sum = 0;
for tv = 1:ordn
t_v{tv} = RPM(tv)/RPM_max*t_ramp; %Creation of individual Time Vectors
TLw_intrp{tv} = interp1(cell2mat(t_v(tv)),ord(tv).total_lw,t,'linear','extrap'); % Interpolating the values of sound power at different times for linear ramp
f_intrp{tv} = interp1(cell2mat(t_v(tv)),ord(tv).freq,t,'linear','extrap');
SPrL{tv} = cell2mat(TLw_intrp(tv))+10*log10(Q/(4*pi*r*r)); % Conversion of Sound power(TLw dB) to Sound Pressure Level(SprLdB)
Spr{tv} = sqrt(2)*(Po*(power(10,cell2mat(SPrL(tv))/20))); % Conversion of Sound Pressure Level(SprLdB)to Sound Pressure(Spr Pa)
Wav{tv} = cell2mat(Spr(tv)).*sin(pi*cell2mat(f_intrp(tv)).*t); % Data for the Wave file
Wav_sum = Wav_sum + cell2mat(Wav((tv))); % Summation of wav data for all time orders
end
audiowrite(filename_audiowrite,Wav_sum,fs,'BitsPerSample',32)
end
end

답변 (1개)

Arnab Sen
Arnab Sen 2016년 4월 25일
Hi Karthik,
In the script linear interpolation is done which might create the issue. Try interp1 with spline option as below,
figure
vq2 = interp1(x,v,xq,'spline');
plot(x,v,'o',xq,vq2,':.');
xlim([0 2*pi]);
title('Spline Interpolation');
For more details, refer to the following link:
  댓글 수: 1
Karthik Brs
Karthik Brs 2016년 4월 25일
Thank you for your time Arnab! I have tried with 'spline' and all the other interp1 methods, none works unfortunately!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by