Effacer les filtres
Effacer les filtres

frequency variable sine generator - odd blips when interpolating frequencies

1 vue (au cours des 30 derniers jours)
Roman
Roman le 6 Mai 2013
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?

Réponses (0)

Catégories

En savoir plus sur Author Block Masks dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by