Convolution Reverb audio plugin
26 ビュー (過去 30 日間)
古いコメントを表示
Hello.
My idea is to create a simple convolution reverb audio plugin. I have chosen a nice Impulse response and I wrote a function script. It works and I would convert the function script in an audio plugin. For the moment I'm working with mono audio, but I will convert to stereo.
My only problem is that I have to specify also the Impulse Response as input in the function. I would find a way to "store" the IR (or more than one IR) inside the function in order to give only the audio and the parameters as input.
The IR is a too long vector and I can't explicitly write in the function code, I actually have it as a variable.
Have you any idea?
function y = ConvReverb(IR, Audio_Input, Input_Gain, Output_Gain, DryWet)
% Input and Output gain between 0 and 1. If you put 1 the volume is not
% affected
%
% Dry/Wet percentage between 0 and 1
%
% "length(IR)+length(Audio_Input)-1" is the conv length between x and h
x = Input_Gain*Audio_Input;
d = DryWet;
wet = d*x;
dry = (1-d)*x;
H = fft(IR, length(IR)+length(Audio_Input)-1);
DRY = fft(dry, length(IR)+length(Audio_Input)-1);
WET = fft(wet, length(IR)+length(Audio_Input)-1);
Y=H.*WET+DRY;
y_time = ifft(Y);
y = Output_Gain*y_time;
end
0 件のコメント
採用された回答
Brian Hemmat
2021 年 6 月 9 日
Hi Lorenzo,
My understanding is that you are developing a function but eventually want to convert it to an audioPlugin object. In that case:
Take a look at the pattern in audiopluginexample.FastConvolver. It defines a property to hold the impulse response. In general, the plugins in the plugin gallery cover a number of common patterns:
Best,
Brian
0 件のコメント
その他の回答 (1 件)
Lorenzo Lellini
2021 年 6 月 11 日
2 件のコメント
Brian Hemmat
2021 年 6 月 11 日
Hi Lorenzo,
Regarding why you're not hearing anything: You are creating the filter and using it in the process method. This means every time its called, the filter has no prior state. Instead, you need to create the filter during construction. Here is your code updated:
classdef ConvReverbPlugin < audioPlugin
properties
% PROPERTIES THAT CAN BE MODIFIED FROM THE USER.
DryWet = 0.5;
Output_Gain = 1;
end
properties (Access = private)
% PROPERTIES NOT VISIBLE TO THE USER.
% MONO IR (it is a column vector)
IR = audioread('ChurchImpulseResponse-16-44p1-mono-5secs.wav').'; % <<<< TRANSPOSE TO ROW VECTOR
Filter % <<<< CREATE PROPERTY TO HOLD FILTER.
end
properties (Constant)
% USER INTERFACE SECTION.
PluginInterface = audioPluginInterface(...
audioPluginParameter('DryWet', ...
'DisplayName','Dry/Wet', ...
'Mapping', {'lin',0,1}), ...
audioPluginParameter('Output_Gain', ...
'DisplayName','Output Volume','Mapping', {'lin',0,1}))
end
methods
function plugin = ConvReverbPlugin()
% CONSTRUCTOR - Create the filter once.
plugin.Filter = dsp.FrequencyDomainFIRFilter('Numerator', plugin.IR, ... %<<<
'PartitionForReducedLatency', true, 'PartitionLength', 10240); %<<<
end
function out = process(plugin, in)
% PLUGIN PROCESSING
d = plugin.DryWet;
wet = d*in;
dry = (1-d)*in;
y = plugin.Filter(wet); % <<< USE THE FILTER
out = (dry + y) * plugin.Output_Gain;
end
end
end
Regarding row vector impulse response: Just convert the impulse response to a row vector when its defined in the property. The example code above does this.
Regarding stereo convolution: Do you mean you want two separate impulse responses for the two channels? If so, create two filters and filter each channel separately. If both channels use the same impulse response, then the example code works for that. It will filter the channels independently.
Best,
Brian
参考
カテゴリ
Help Center および File Exchange で Audio Plugin Creation and Hosting についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!