フィルターのクリア

VST audio plugin and .txt output file

3 ビュー (過去 30 日間)
earmello
earmello 2024 年 3 月 13 日
編集済み: jibrahim 2024 年 3 月 15 日
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 Center および File ExchangeAudio 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