In an Audio Plugin process function, what does 'in' represent?
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tony Lawrence
el 2 de Ag. de 2018
Comentada: Tony Lawrence
el 17 de Dic. de 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 comentarios
Respuesta aceptada
Charlie DeVane
el 13 de Dic. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Simulation, Tuning, and Visualization en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!