VST audio plugin and .txt output file
조회 수: 2 (최근 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
댓글 수: 0
답변 (1개)
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
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 Exchange에서 Audio Plugin Creation and Hosting에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!