【源码】Timbre Modeler:基于小波的时频信号分解与重构
函数调用形式
For function call
[yo,afz,t,G,tg] = waveletmodel(yi,Fs,fh,ff,fd,ffl)
Define input:
yi - 采样的音乐信号sampled musical sound, row vector
Fs - yi的采样率sample rate of yi (samples/sec)
fh - 小波形状的Hermite基系数Hermite basis coefficients for wavelet shape, row vector (if unsure set fh=1).
ff - 音乐声音的基频fundamental frequency of musical sound (cycles/sec)
fd - 频域滤波器带宽frequency domain filter bandwidth
ffl - 小波滤波器谐振频率集set of wavelet filter resonant frequencies, ff normalized row vector
Define output:
yo - 滤波后输出的声音filtered output sound, row vector
afz - 堆叠振幅轮廓模型stacked amplitude contour model
t - 时间向量time vector for yo and afz
G - 高斯小波滤波器Gaussian wavelet filter
tg - time vector for G
示例:使用30个带宽为330Hz的谐波过滤一个A3(220Hz)钢琴音符。用标准高斯小波重构平滑后的输出信号。接下来,通过先将输入信号按平滑输出分解,然后重复滤波过程来重构瞬态输出信号。这里只需使用第一Hermite小波。
Example: Filter an A3 (220Hz) piano note using 30 harmonics with bandwidths of 330Hz. Reconstruct a smoothed output signal with a standard Gaussian wavelet. Next reconstruct a transient output signal by first decomposing the input by the smoothed output then repeating a filtering process. This time, simply use the 1st Hermite wavelet.
示例代码:
%% get sampled musical audio
yi = audioread(‘a3-piano.wav’)’; Fs=44100;
%% specify hermite filter structure, fundamental frequency,
%% frequency set and bandwidth
fh=[1]; ff = 220; ffl = (1:30); fd = 1.5*ff;
%% generate model for standard gaussian wavelet
[yo1,afz1,t,G1,tg] = waveletmodel(yi,Fs,fh,ff,fd,ffl);
%% plot smooth model in first figure and play sound
figure(1)
sound(yo1,Fs)
waveletplottool(yi,yo1,afz1,t,G1,tg)
%% specify wavelet shape as the 1st hermite wavelet
fh = [0 1];
%% subtract output from input then refilter with 1st order wavelet
[yo2,afz2,,G2,] = waveletmodel(yi-yo1,Fs,fh,ff,fd,ffl);
%% plot 1st order transience model in next figure and play sound
figure(2)
sound(yo2,Fs)
waveletplottool(yi-yo1,yo2,afz2,t,G2,tg)
参考文献:
[1] Hermite Transform and wavelets - https://qr.ae/pNrYxL
[2] more on wavelets https://qr.ae/pNrJJ9
[3] wavelet filter algorithm https://qr.ae/TxQMDl
[4] modeled timbre gallery - https://qr.ae/pNrPEd
[5] Gaussian Fourier transform and bandwidth interpretations https://qr.ae/pXR35y
更多精彩文章请关注公众号: