Can zp2sos be used in an audio plugin?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Nathan Lively
le 7 Mai 2021
Réponse apportée : Nathan Lively
le 11 Mai 2021
I'm getting this error:
Unable to perform assignment because dot indexing is not supported for
variables of this type.
Error in filterPlugin/reset (line 21)
p.sos = zp2sos(z,p,k);
Here's my plugin code. I'm trying to keep it super simple for testing.
classdef filterPlugin < audioPlugin
% Basic IIR Butterworth lowpass for testing
properties % Public interface
end
properties (Constant) % Define the plugin interface
PluginInterface = audioPluginInterface();
end
properties (Access = private) % Internal State
sos = zeros(1,6);
end
methods
function out = process(p, in)
[out] = sosfilt(p.sos,in);
end
function reset(p) % Initialize internal state
Fs = getSampleRate(p);
Fc = 1000; FcNormalized = Fc/(Fs/2);
[z,p,k] = butter(2,FcNormalized);
p.sos = zp2sos(z,p,k);
end
end
end
2 commentaires
Réponse acceptée
Plus de réponses (1)
Asvin Kumar
le 10 Mai 2021
The reason this error occurs is because you're using p as the "this" input argument and then overwriting it by the output of the butter function which is a column vector of complex numbers. Hence why the assignment fails. Use a modified version of the reset function to workaround this error.
function reset(this) % Initialize internal state
Fs = getSampleRate(this);
Fc = 1000;
FcNormalized = Fc/(Fs/2);
[z,p,k] = butter(2,FcNormalized);
this.sos = zp2sos(z,p,k);
end
4 commentaires
Asvin Kumar
le 11 Mai 2021
You can find details about functions that support code generation from the Signal Processing Toolbox here: Code Generation and GPU Support - MATLAB & Simulink (mathworks.com)
Voir également
Catégories
En savoir plus sur Audio Plugin Creation and Hosting 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!