Inefficient Use of Bandpass IIR Filter Object (DSP System Toolbox)
Afficher commentaires plus anciens
Hey all, I'm trying to do something hopefully quite simple, but I'm having a little trouble understanding a proper implementation.
I'm processing audio signals using the Audio Toolbox audioPlugin class and want to implement a simple bandpass filter in my processing loop.
Im using the below function from the DSP System toolbox to create a system object for filtering.
designBandpassIIR
I want to implement the filtering such that it operates in a per-sample manner instead of a frame-based one as this gives me the flexibility I need for the feedback in my system.
The main hotspot when I've profiled it is
feedbackSample = plugin.feedbackBpf{ch}(feedbackSample); % problematic line
This is to the extent that it means my algorithm can't run properly in real-time any more.
The relevant snippet of code is below. Any help would be massively appreciated!
function plugin = gDel
% constructor
...
plugin.feedbackBpf = {designBandpassIIR(FilterOrder=2,HalfPowerFrequency1=0.1,HalfPowerFrequency2=0.9,DesignMethod="butter", SystemObject=true), ...
designBandpassIIR(FilterOrder=2,HalfPowerFrequency1=0.1,HalfPowerFrequency2=0.9,DesignMethod="butter", SystemObject=true)};
end
function out = process(plugin, in)
nChannels = size(in, 2);
frameSize = size(in, 1);
...
for ch = 1:nChannels
for n = 1:frameSize
inputSample = in(n, ch);
feedbackSample = plugin.feedbackBuffer{ch}.read(); % custom buffer I've written
feedbackSample = plugin.feedbackBpf{ch}(feedbackSample); % problematic line
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Code Generation and Deployment dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!