Azzera filtri
Azzera filtri

frequency variable sine generator - odd blips when interpolating frequencies

1 visualizzazione (ultimi 30 giorni)
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?

Risposte (0)

Categorie

Scopri di più su Author Block Masks in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by