필터 지우기
필터 지우기

frequency variable sine generator - odd blips when interpolating frequencies

조회 수: 1 (최근 30일)
Roman
Roman 2013년 5월 6일
I made a small sine generator:
When I adjust the frequency (I use a MIDI controller, but implemented here with a slider gain for compatibility), I get very odd blips and squeals on the sine output. As if I was generating way too high frequencies for a short while. When I'm done fiddling with the slider (or MIDI controller) the new frequency is set and stable.
Inside the smoothGain Block I have this code to avoid parameter "jumps" (and thus crackling on the output). I's an interpolation between two gain values from start to end of a frame:
function output = smoothGain(input, gain)
% create variables needed
persistent lastGain;
if isempty(lastGain)
lastGain = 0;
end
% check whether gain has changed
if gain ~= lastGain
% gain has changed and will be interpolated
output = input .* repmat(linspace(lastGain, gain, size(input,1))', 1, size(input,2));
lastGain = gain;
else
% gain is the same as before
output = input .*gain;
end
I have verified that the code works as I expect it in Matlab. But I get the artifacts mentioned before.
Am I missing anything?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Author Block Masks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by