In an Audio Plugin process function, what does 'in' represent?
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Tony Lawrence
am 2 Aug. 2018
Kommentiert: Tony Lawrence
am 17 Dez. 2018
I have read many of the tutorials but I may have missed this detail.
By default 'in' is an array doubles of size 1024x2. I think this represents one sample, or one 'snapshot' in time of audio. Using the AudioTestBench with the code below, I am able to see that process is called every .02 seconds, which indicates a sample rate of 50 Hz, but I am expecting a sample rate of 48000 Hz. If 'in' contains more than one frame, how can I access it??
classdef testPlugin < audioPlugin
properties (Constant)
PluginInterface = audioPluginInterface()
end
methods
function out = process(plugin, in)
toc;
tic;
whos in;
out = zeros(size(in));
end
end
end
0 Kommentare
Akzeptierte Antwort
Charlie DeVane
am 13 Dez. 2018
in contains one frame (buffer) of audio to be processed.
In your example, in contained 1024 samples (rows) with 2 channels (columns).
The frame size is the number of samples per frame, in this case 1024.
process was called once every 1024/48000 = 0.0213 s to handle one frame of data, so the frame rate was 48000/1024 = 46.8750 Hz.
(This is the meaning of frame as used by MathWorks. Some people use a different definition.)
Just use ordinary indexing to access individual samples. For example, in(7,:) will access all channels of the 7th sample (assuming the frame size is at least 7).
The number of channels (columns) of in is determined by the plugin. By default it is 2 channel. You can change that using the InputChannels argument of audioPluginInterface.
The frame size (rows) is determined by the plugin host. In general a plugin must be designed to handle arbitrary frame sizes. Audio Test Bench typically uses 1024, though you can change that in the settings for whichever input you choose. DAW frame sizes can usually be set by the user, although even then the plugin is not guaranteed to always receive exactly that size.
hope this helps,
Charlie
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Simulation, Tuning, and Visualization finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!