当前位置: 首页 > 程序语言 >matlab处理声音

matlab处理声音

作者 沉默18
来源: 小木虫 750 15 举报帖子
+关注

利用matlab已经读出声音波形图,并用fft得到频谱图,请问我该怎么做才能得到声音的dB?谢谢各位

 返回小木虫查看更多

今日热帖
  • 精华评论
  • somomo91

    正常是

    CODE:
    Pref=20; % 20microPascal
    Y = fft(y)
    db = 20*log10((abs(Y)/Pref))

    但有很多解释,比较啰嗦

    或者你可以用最新的 MATLAB 2018A,语音处理工具箱 新添加了一个 splMeter ,专门量 spl 的,这个比较标准,最好用这个

  • somomo91

    引用回帖:
    3楼: Originally posted by 沉默18 at 2018-05-23 08:34:24
    非常感谢您!Y=fft(y),Y不是是声压才可以用您下面那个分贝计算公式?您知道怎么才能得到声压吗?
    ...

    计算声压有很多方法,用FFT 也可以,或者用其他的 filter
    通常,更好的是用  A-weighting
    CODE:
    AWeighting = weightingFilter('A-weighting', 48000)

    我现在没法用MATLAB测试,你可以先试试这个例子,用 butter filter,
    CODE:
    [wav,fs_Hz]=audioread( "audiofile.wav"  %load the WAV file
    my_cal_factor = 1.0;  %the value for your system to convert the WAV into Pascals
    wav_Pa = wav * my_cal_factor;

    %extract the envelope
    smooth_sec = 0.125;  %"FAST" SPL is 1/8th of second.  "SLOW" is 1 second;
    smooth_Hz = 1/smooth_sec;
    [b,a]=butter(1,smooth_Hz/(fs_Hz/2),'low');  %design a Low-pass filter
    wav_env_Pa = sqrt(filter(b,a,wav_Pa.^2));  %rectify, by squaring, and low-pass filter

    %compute SPL
    Pa_ref = 20e-6;  %reference pressure for SPL in Air
    SPL_dB = 10.0*log10( (wav_env_Pa ./ Pa_ref).^2 ); % 10*log10 because signal is squared

    %plot results
    figure;
    subplot(2,1,1);
    t_sec = ([1:size(wav_Pa)]-1)/fs_Hz;
    plot(t_sec,wav_Pa);
    xlabel('Time (sec)');
    ylabel('Pressure (Pa)');

    subplot(2,1,2)
    plot(t_sec,SPL_dB);
    xlabel('Time (sec)');
    ylabel('SPL (dB)');
    yl=ylim;ylim(yl(2)+[-80 0]);


  • qqinly

    引用回帖:
    6楼: Originally posted by 沉默18 at 2018-05-24 17:44:43
    请问,怎么能得到横轴为频率,纵轴为db呢?
    ...

    dB 是个相对值,要看你以什么参考功率为基准,而绝对值是 dBm 和 dBW,参考功率分别为 mW 和 W ,举个例子:

    matlab处理声音

    效果如下:

    matlab处理声音-1

猜你喜欢
下载小木虫APP
与700万科研达人随时交流
  • 二维码
  • IOS
  • 安卓