In an Audio Plugin process function, what does 'in' represent?

4 次查看(过去 30 天)
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

采纳的回答

Charlie DeVane
Charlie DeVane 2018-12-13
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
  1 个评论
Tony Lawrence
Tony Lawrence 2018-12-17
Thanks. I've been able to piece this together since asking, but I'm sure someone else will want to know.

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by