Filter löschen
Filter löschen

VST audio plugin and .txt output file

3 Ansichten (letzte 30 Tage)
earmello
earmello am 13 Mär. 2024
Bearbeitet: jibrahim am 15 Mär. 2024
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

Antworten (1)

jibrahim
jibrahim am 14 Mär. 2024
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 Kommentare
earmello
earmello am 15 Mär. 2024
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 am 15 Mär. 2024
Bearbeitet: jibrahim am 15 Mär. 2024
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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Audio Plugin Creation and Hosting finden Sie in Help Center und File Exchange

Produkte


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by