代码运行的速度显著加快,(得益于C++)
音频处理效果更为通用,VST(32bit)可以被绝大多数工作站软件接受(测试软件为AU CS6和Cubase 10.5)
通过使用这种方式可以配合更强的DAW功能进行算法的细微参数调整,并可以实时进行运算。
结合DAW功能,使得Matlab的处理算法有了实际的应用场景,并且不需要增加太多的设备和软件, 制作好的VST插件不需要安装Matlab也可运行。
测试程序
% classdef AudioToolBox_VST_Plugin < audioPlugin
% methods
% function out = process(~,in)
% out=in;
% end
% end
% end
%================================================================================================================================
% classdef AudioToolBox_VST_Plugin < audioPlugin
% properties %插件含有的可变参数
% Gain = 1.5;
% end
% properties (Constant) %恒定的参数
% %PluginInterface = audioPluginInterface( audioPluginParameter('Gain','DisplayName','Echo Gain', 'Mapping',{'lin',0,3}))
% PluginInterface = audioPluginInterface;
%
% end
% methods
% function out = process(plugin, in)%process函数是用来处理音频流,plugin为数据输入的通道,in为输入数据
% out = in*plugin.Gain;
% end
% end
% end
%================================================================================================================================
% classdef AudioToolBox_VST_Plugin < audioPlugin
% properties%插件含有的可变参数
% Gain = 1;
% end
% properties (Constant)%恒定的参数
% PluginInterface = audioPluginInterface( ...
% audioPluginParameter('Gain'), ...
% 'PluginName','Simple Gain', ...%插件名称
% 'VendorName','Cool Company', ...%插件的制作者
% 'VendorVersion','1.0.0', ...%插件的版本号
% 'UniqueId','1a1Z', ...%专门的版本ID
% 'InputChannels',2, ...%输入的通道数
% 'OutputChannels',2, ...%输出的通道数
% 'BackgroundColor','y');
% end
% methods
% function out = process(plugin,in)%process函数是用来处理音频流,plugin为数据输入的通道,in为输入数据
% out = in*plugin.Gain;
% end
% end
% end
% classdef AudioToolBox_VST_Plugin < audioPlugin
% properties
% DropoutLeft = false
% DropoutRight = false
% NoiseLeftGain = 0
% NoiseRightGain = 0
% end
% properties (Constant)
% PluginInterface = audioPluginInterface( ...
% audioPluginParameter('DropoutLeft', ...
% 'Layout',[2,1], ...
% 'DisplayNameLocation','none'), ...
% audioPluginParameter('DropoutRight', ...
% 'Layout',[2,2], ...
% 'DisplayNameLocation','none'), ...
% audioPluginParameter('NoiseLeftGain', ...
% 'Layout',[1,1], ...
% 'DisplayNameLocation','none'), ...
% audioPluginParameter('NoiseRightGain', ...
% 'Layout',[1,2], ...
% 'DisplayNameLocation','none'), ...
% ...
% audioPluginGridLayout)
% end
% methods
% function out = process(plugin,in)
% r = size(in,1);%size(A,dim)A为输入数组,dim为维数
% dropRate = 0.1;
%
% if plugin.DropoutLeft
% idx = randperm(r,round(r*dropRate));%randprem随机置换
% in(idx,1) = 0;
% end
% if plugin.DropoutRight
% idx = randperm(r,round(r*dropRate));
% in(idx,2) = 0;
% end
%
% in(:,1) = in(:,1) + plugin.NoiseLeftGain*(2*rand(r,1,'like',in)-1);
% in(:,2) = in(:,2) + plugin.NoiseRightGain*(2*rand(r,1,'like',in)-1);
%
% out = in;
% end
% end
% end
%================================================================================================================================
% classdef AudioToolBox_VST_Plugin < audioPlugin
% properties
% DropoutLeft = false;
% DropoutRight = false;
% NoiseLeftGain = 0;
% NoiseRightGain = 0;
% DropoutRate = 0.1;
% end
% properties (Constant)
% PluginInterface = audioPluginInterface(...
% audioPluginParameter('DropoutLeft', ...
% 'Layout',[4,1], ...
% 'DisplayName','Dropout (L)', ...
% 'DisplayNameLocation','above', ...
% 'Style','vrocker'), ...
% audioPluginParameter('DropoutRight', ...
% 'Layout',[4,4], ...
% 'DisplayName','Dropout (R)', ...
% 'DisplayNameLocation','above', ...
% 'Style','vrocker'), ...
% audioPluginParameter('NoiseLeftGain', ...
% 'DisplayName','Noise Gain (L)', ...
% 'Layout',[2,1;2,2], ...
% 'DisplayNameLocation','above', ...
% 'Style','rotaryknob'), ...
% audioPluginParameter('NoiseRightGain', ...
% 'Layout',[2,3;2,4], ...
% 'DisplayName','Noise Gain (R)', ...
% 'DisplayNameLocation','above', ...
% 'Style','rotaryknob'), ...
% audioPluginParameter('DropoutRate', ...
% 'Layout',[4,2;4,3], ...
% 'DisplayName','Droput Rate', ...
% 'DisplayNameLocation','below', ...
% 'Style','vslider'), ...
% ...
% audioPluginGridLayout( ...
% 'RowHeight',[15,150,15,150,15], ...
% 'ColumnWidth',[100,40,40,100], ...
% 'RowSpacing',30))
% end
% methods
% function out = process(plugin,in)
% r = size(in,1);
%
% if plugin.DropoutLeft
% idx = randperm(r,round(r*plugin.DropoutRate));
% in(idx,1) = 0;
% end
% if plugin.DropoutRight
% idx = randperm(r,round(r*plugin.DropoutRate));
% in(idx,2) = 0;
% end
%
% in(:,1) = in(:,1) + plugin.NoiseLeftGain*randn(r,1,'like',in);
% in(:,2) = in(:,2) + plugin.NoiseRightGain*randn(r,1,'like',in);
%
% out = in;
% end
% end
% end
%================================================================================================================================
classdef AudioToolBox_VST_interface < audioPlugin
properties
DropoutLeft = false;
DropoutRight = false;
NoiseLeftGain = 0;
NoiseRightGain = 0;
DropoutRate = 0.1;
end
properties (Constant)
PluginInterface = audioPluginInterface(...
audioPluginParameter('DropoutLeft', ...
'Layout',[4,1], ...
'DisplayName','Dropout (L)', ...
'DisplayNameLocation','above', ...
'Style','vrocker'), ...
audioPluginParameter('DropoutRight', ...
'Layout',[4,4], ...
'DisplayName','Dropout (R)', ...
'DisplayNameLocation','above', ...
'Style','vrocker'), ...
audioPluginParameter('NoiseLeftGain', ...
'DisplayName','Noise Gain (L)', ...
'Layout',[2,1;2,2], ...
'DisplayNameLocation','above', ...
'Style','rotaryknob'), ...
audioPluginParameter('NoiseRightGain', ...
'Layout',[2,3;2,4], ...
'DisplayName','Noise Gain (R)', ...
'DisplayNameLocation','above', ...
'Style','rotaryknob'), ...
audioPluginParameter('DropoutRate', ...
'Layout',[4,2;4,3], ...
'DisplayName','Droput Rate', ...
'DisplayNameLocation','below', ...
'Style','vslider'), ...
...
audioPluginGridLayout( ...%为插件定义UI布局
'RowHeight',[15,150,15,150,15], ...%每一行之间的间距为15 150 15 150 15
'ColumnWidth',[100,40,40,100], ...%每一列之间的间距为100 40 40 100
'ColumnSpacing',10,...%每一列之间的空间
'Padding',[10,10,10,10],...%左下右上的隔开位置
'RowSpacing',30))%每一行之间的空间
end
methods
function out = process(plugin,in)
r = size(in,1);%返回输入数据的长度
if plugin.DropoutLeft
idx = randperm(r,round(r*plugin.DropoutRate));
in(idx,1) = 0;
end
if plugin.DropoutRight
idx = randperm(r,round(r*plugin.DropoutRate));
in(idx,2) = 0;
end
in(:,1) = in(:,1) + plugin.NoiseLeftGain*randn(r,1,'like',in);
in(:,2) = in(:,2) + plugin.NoiseRightGain*randn(r,1,'like',in);
out = in;
end
end
end
%parameterTuner(AudioToolBox_VST_interface)命令用于查看UI渲染设计
%audioTestBench AudioToolBox_VST_interface命令用性能检验
Copyright © 2020 by RichardYang. All rights reserved.
仅供参考,严禁转载,感谢。
首次运行后,并不会显示结果,也没有结果。
需要在命令行运行audioTestBench AudioToolBox_VST_interface才可以打开窗口
然后需要选择生成VST2
之后选择这两个(否则读不出来插件),OK了的话会在OutPut文件夹找到一个这个名字的dll文件,就生成了VST。