VST audio plugin and .txt output file

3 次查看(过去 30 天)
Hello,
I have written a VST plugin that processes input signals and would like to save the results of these calculations in a .txt file, but I don't understand how to do this.
Can anyone help me?
Thank you

回答(1 个)

jibrahim
jibrahim 2024-3-14
It is not clear from the question if you want this writing capability to be part of the plugin, or if it is something you want to run outside the plugin as part of a script for example. either way, refer to dsp.BinaryFIleWriter for real-time use case for writing data to binary files:
  2 个评论
earmello
earmello 2024-3-15
What I want is for the writing capability to be part of the plugin. I also want to be able to choose from the plugin interface the destination and the name of the .txt file where the processing data is to be stored.
In the meantime, thank you for the information.
jibrahim
jibrahim 2024-3-15
编辑:jibrahim 2024-3-15
Here is the pattern to write results from within the plugin:
classdef myPlugin < audioPlugin
properties (Access = private)
fid
end
methods
function plugin = myPlugin
plugin.fid = fopen('results.bin','w');
end
function y = process(plugin,x)
y = x;
fwrite(plugin.fid,y,class(x));
end
end
end
Here is an example with the generated plugin:
generateAudioPlugin myPlugin
p = loadAudioPlugin("myPlugin.dll");
process(p,1.5*ones(1024,2));
% Read results
reader = dsp.BinaryFileReader('results.bin');
reader()
It is currently not possible to specify the desired output binary file name on the plugin interface.
Here is a workaround where you specify the desired output file name in a txt file. The plugin will use that name. to write data.
classdef myPlugin < audioPlugin
properties (Access = private)
fid
end
methods
function plugin = myPlugin
% Get the desired file name
fid0 = fopen('name.txt');
name = char(fread(fid0)).';
plugin.fid = fopen(name,'w');
end
function y = process(plugin,x)
y = x;
fwrite(plugin.fid,y,class(x));
end
end
end
For example:
First, set the string in name.txt to myresults.bin:
generateAudioPlugin myPlugin
p = loadAudioPlugin("myPlugin.dll");
p = loadAudioPlugin("myPlugin.dll");
process(p,1.5*ones(1e3,2));
reader = dsp.BinaryFileReader('myresults.bin','SamplesPerFrame',1000);
Now change the name in name.txt to myresults2.bin
p = loadAudioPlugin("myPlugin.dll");
process(p,pi*ones(1e3,2));
reader = dsp.BinaryFileReader('myresults2.bin','SamplesPerFrame',1000);
reader()
Notice that you only have to generate the plugin once, and can write to your desired location.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Audio Plugin Creation and Hosting 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by