Convolution with audio system toolbox

15 views (last 30 days)
Peter Rowland-Jones
Peter Rowland-Jones on 19 Aug 2017
Commented: Tom111 on 17 Jul 2020
Hi all, i'm trying to use the audio system toolbox to turn one of my scripts into a VST. The plugin needs to take an impulse response in the form of an array and convolve it with the given input samples. When I implement this with conv(a,b) I get an output frame size larger than the input frame size (2). Do I need to implement a circular buffer to fix this, if so how could this be done?
  1 Comment
Peter Rowland-Jones
Peter Rowland-Jones on 19 Aug 2017
Just found the Fast Convolution example on the AudioSystemstToolbox page!! :)

Sign in to comment.

Answers (3)

Gabriele Bunkheila
Gabriele Bunkheila on 1 Nov 2017
Hello,
I thought I'd capture a quick update on this topic as R2017b has already been out there for a few weeks. With the latest release, DSP System Toolbox now includes a new dsp.FrequencyDomainFIRFilter System object, which audiopluginexample.FastConvolver is now using under the hood. If you need fast convolution using partitioned frequency-domain filtering you can now use dsp.FrequencyDomainFIRFilter directly.
The new object includes both overlap-add and overlap-save methods, it has a property to report algorithmic latency as a function of the partition length used, and it comes with a block equivalent to use with Simulink.
Give it a try if you get a chance and let us know what you think!
Thanks,
Gabriele.
  3 Comments
Gabriele Bunkheila
Gabriele Bunkheila on 20 Nov 2018
Hello ridgerider,
Indeed, dsp.FrequencyDomainFIRFilter currently only supports a single filter per object and it reserves 2D coefficients for partitioned frequency-domain filter coefficients.
However, to implement a multi-filter fast convolution all you need to do is augmenting audiopluginexample.FastConvolver by creating one instance of dsp.FrequencyDomainFIRFilter per required filter (and then running each separately within the process or stepImpl method of your new audioPlugin class).
You can do that by either adding as many private properties as needed (similarly to pFIR in the baseline version of audiopluginexample.FastConvolver) or by using a cell array with one object instance per cell.
I hope this helps.
Thanks,
Gabriele.
ridgerider
ridgerider on 20 Nov 2018
Thanks, Gabriele!
The only problem is that I have a lot of channels and a lot of IRs and would like to safe unnecessary mulitple FFTs of the same input signal block, if convolved with several filters... That's what would happen when subsequently filtering with multiple instances of dsp.FrequencyDomainFIRFilter, right?

Sign in to comment.


Gabriele Bunkheila
Gabriele Bunkheila on 21 Nov 2018
Hi ridgerider,
You are right indeed - currently I see no plug-and-play solution to share the FFT of the input signal across many instances of dsp.FrequencyDomainFIRFilter. Yours is good feedback and we'll take into account for enhancements in future releases.
For the time being, I suggest:
  • Using multiple separate instances of dsp.FrequencyDomainFIRFIilter first and quantify how big of a performance problem you really have. Beyond the built-in tools like tic, toc , timeit, or and the MATLAB Profiler, I also suggest taking a look at the approach used in the example Measure Performance of Streaming Real-Time Audio Algorithms
  • If needed, take a look inside dsp.FrequencyDomainFIRFilter to inspire yourself for an improved version. All the code should be open and visible, so hopefully it shouldn't take long if you only need one specific operating mode
Thanks,
Gabriele.
  1 Comment
Tom111
Tom111 on 17 Jul 2020
Gabriele you say it's possible to use a cell array with one object instance of dsp.FrequencyDomainFIRFilter per cell, when I try to do this the plugin compiles but doesn't run, giving the error (in audioTestBench) 'Conversion to cell from dsp.FrequencyDomainFIRFilter is not possible'. Any ideas? Where should I initialise the cell array, in the properties? (as would have been for pFIR in the Fast Convolver example)?
Many thanks

Sign in to comment.


SHIFFA MEMON
SHIFFA MEMON on 29 Jan 2020
anyone please help me . I have two audio file so how can i convolution my audio signals?
  2 Comments
Gabriele Bunkheila
Gabriele Bunkheila on 29 Jan 2020
Hi Shiffa, this conversation is about fast convolution. If you have doubts about the basics of convolution, you may find it useful to take a look at this page first.
Use audioread to open your two audio files (say one for x and one for h) then use either of conv(h,x) or filter(h,1,x). The former will generate the full convolved sequence, while the latter will return a sequence of the same length of x.
SHIFFA MEMON
SHIFFA MEMON on 30 Jan 2020
can you guide me? how can I get fft of my convolution output?

Sign in to comment.

Categories

Find more on Audio Plugin Creation and Hosting in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!