Azzera filtri
Azzera filtri

Is it posible to set 2 inputs in audio plugin?

6 visualizzazioni (ultimi 30 giorni)
I am designing a spectral subtracter to evaluate losses in perceptual audio coding, which consists in a plugin that compares the audio spectrum of two signals, the original and the compressed one. The thing is that i want to develop this code as an audio plugin but i am having some troubles to set two different inputs in my plugin, as the process function only has one in, right? Is there any way of adding another extra input? Or any idea to avoid having this problem?
Thank you.

Risposta accettata

jibrahim
jibrahim il 5 Mag 2023
Modificato: jibrahim il 5 Mag 2023
Hi David,
It is possible to design plugins with more than one input. Here is a simple example:
classdef myPlugin < audioPlugin
properties (Constant)
PluginInterface = audioPluginInterface( ...
audioPluginParameter('scale','DisplayName','Scale','Label','','Mapping',{'lin',0,1}),...
'InputChannels',[2 2], ...
'PluginName','myPlugin' ...
)
end
properties
scale = .1
end
methods
function y = process(obj,x1,x2)
y = obj.scale*x1+x2;
end
end
end
Validation and generation of the plugin should work:
validateAudioPlugin myPlugin
generateAudioPlugin myPlugin
If you were to use the generated plugin in MATLAB, you would have to concatenate the two inputs. For example:
hostedPlugin = loadAudioPlugin("myPlugin.dll")
y = process(hostedPlugin,randn(1024,4));
  4 Commenti
David Montalbán Caamaño
David Montalbán Caamaño il 10 Mag 2023
Thank you for your support, I have one last question. I want the plugin to be able to load two different files, one mp3 file with the compressed signal and another wav file with the original one, as they are these two inputs I mentioned previously, as any file loader of any software that allows you to navigate through the explorer. ¿Is this posible? ¿How can I implement this in the code of my plugin?
Thank you so much.
Gabriele Bunkheila
Gabriele Bunkheila il 11 Mag 2023
Modificato: Gabriele Bunkheila il 11 Mag 2023
Hi David,
I wasn't sure what you meant with your latest question but I'll try a couple of ideas to help us identify exactly what you are after.
From your MATLAB code (e.g. an edited version of the code generated byAudio Test Bench), you could use a file-selection utility such as uigetfile with 'MultiSelect','on'. Then read both separately with two different dsp.AudioDeviceReader objects. In the loop, read the samples from both objects separately in the loop and feed the frames of samples read by each as inputs to your plugin within the streaming loop.
dir = fullfile(matlabroot,'toolbox','audio','samples');
filenames = uigetfile({'*.mp3;*.wav'}, [], dir,'MultiSelect','on');
% Create test bench input and output
fileReader1 = dsp.AudioFileReader('Filename',filenames{1}, 'PlayCount',10);
fileReader2 = dsp.AudioFileReader('Filename',filenames{2}, 'PlayCount',10);
assert(isequal(fileReader1.SampleRate,fileReader2.SampleRate))
player = audioDeviceWriter(fileReader1.SampleRate);
% Create the objects under test
sut1 = myPlugin;
setSampleRate(sut1,fileReader1.SampleRate);
% Open parameter tuners for interactive tuning during simulation
tuner1 = parameterTuner(sut1);
drawnow
% Stream processing loop
while ~isDone(fileReader1) && ~isDone(fileReader2)
% Read from input, process, and write to output
in1 = fileReader1();
in2 = fileReader2();
out1 = process(sut1,in1,in2);
player(sum(out1,2))
% Process parameterTuner callbacks
drawnow limitrate
end
% Clean up
release(fileReader1)
release(fileReader2)
Note that file reading always takes place outside the boundaries. The code outside the plugin here needs to care cared of some of the tasks normally taken care of by a DAW, e.g. ensuring the two sample rates match, and that samples are always availability from both files.
If you prefer a workflow fully based on interactive Apps, you could also turn your MATLAB plugin into a binary VST or AU plugin (from Audio Test Bench or via generateAudioPlugin), then use it from your DAW of choice, and handle file selection and signal routing directly from the DAW.
I hope this helps.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Audio Plugin Creation and Hosting in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by