Hi Anthony,
It is expected that filtering your input sample-by-sample will be significantly slower than filtering the entire frame in one shot. Using frame-based processing removes overhead (related to calling the object repeatadly). Moreover, with frame-based processing, the filtering can be more efficient because it takes advantage of optimized vector operations (as well as some parallelism in many cases).
That being said, if you really can't use frame-based processing, you can still potentially remove a lot of the overhead by generating an audio plugin from your audio plugin MATLAB class.
I have attached code that demonstrates this:
- myFilterSamples: An audio plugin that filters an input sample by sample
- myFilterFrames: An audio plugin that filters the entire frame in one shot
- myTiming: Timing results
To generate the audio plugin, use:
generateAudioPlugin myFilterSamples
generateAudioPlugin myFilterFrames
You can then use the generated audio plugin instead of the MATLAB class:
p = loadAudioPlugin("myFilterSamples.dll");
Moreover, you will notice that you can still filter all input channels in one shot, even if you want to filter sample per sample. That might help you.
Here is a sample timing result I got:
- Samples filter in MATLAB: 0.587555 s
- Frame filter in MATLAB: 0.003006 s
- Samples filter generated plugin: 0.016783 s
- Frame filter generated plugin: 0.019210 s