frequency variable sine generator - odd blips when interpolating frequencies
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Author Block Masks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!