Filter löschen
Filter löschen

frequency variable sine generator - odd blips when interpolating frequencies

1 Ansicht (letzte 30 Tage)
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?

Antworten (0)

Kategorien

Mehr zu Author Block Masks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by