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

조회 수: 3 (최근 30일)
Tony Lawrence
Tony Lawrence 2018년 8월 2일
댓글: Tony Lawrence 2018년 12월 17일
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개)

카테고리

Help CenterFile Exchange에서 Simulation, Tuning, and Visualization에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by