Spectral Modeling Synthesis
Additive Synthesis Implementations
Matlab starter codeSearch Spectral Audio Signal Processing
Would you like to be notified by email when Julius Orion Smith III publishes a new entry into his blog?
%% For sinusoidal modeling, additive synthesis, %% and noise reduction lab. clear all; [x,fs] = wavread('wrenpn1.wav'); x = x/max(abs(x)); sound(x,fs); nx = length(x); %% ANALYSIS PARAMETERS frameRate =200; % Hz R = floor(fs/frameRate); M = 2*R; % Exact COLA not required nFrames = floor(nx/M)*2; N = 2^(1+floor(log2(5*R+1))); % FFT length, zero-padding by 5+ maxPeaks = 1; % Up to this many sinusoidal peaks (pure birdsong) %% VECTOR VARIABLES DECLARATION amps = zeros(maxPeaks,nFrames); freqs = zeros(maxPeaks,nFrames); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% ANALYSIS %% w = hanning(M); for m=1:nFrames tt = (m-1)*R+1:(m-1)*R+M; xw = w .* x(tt); Xw = fft(xw,N); % window phase inconsequential [ampsm,freqsm] = findpeaks(Xw,maxpeaks); % Write this! amps(:,m) = ampsm; freqs(:,m) = freqsm; end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% SYNTHESIS
y = zeros(1,(nFrames+1)*R);
for m=1:nFrames
tt = (m-1)*R+1:(m-1)*R+R; % Write the following too:
[y(tt),state] =
additivesynth(amps(:,m),freqs(:,m),tt,state);
end
% Add a frame of silence to make sure amps ramp down to zero:
tt = nFrames*R+(1:R);
y(tt) = additivesynth(zeros(maxpeaks,1),freqs(:,nFrames),state);
y = y/max(abs(y)); sound(y,fs);
