How can I do real time audio processing with sliders in a Matlab script (*.m files)?
5 ビュー (過去 30 日間)
古いコメントを表示
Hi! I want to perform some audio processing inside a Matlab script using sliders. I want the audio to change in real time as I move the slider across the screen. I am using as an example the AudioProcessingScript.m, but the audio changes when I release the slider rather than while I am moving it. If anyone could help me with this, I would gladly appreciate it. Thanks in advance!
The AudioProcessingScript.m script goes something like this:
%% A. Create input and output objects
fileReader = dsp.AudioFileReader( ...
'speech_dft.mp3', ...
'SamplesPerFrame',64, ...
'PlayCount',3);
deviceWriter = audioDeviceWriter( ...
'SampleRate', fileReader.SampleRate);
%% B. Create an object of a handle class
x = parameterRef;
x.name = 'gain';
x.value = 0.5;
%% C. Open the UI function for your parameter
parameterTuningUI(x,0,1)
%% D. Process audio in a loop
while ~isDone(fileReader)
audioIn = fileReader();
drawnow limitrate
audioOut = x.value*audioIn;
deviceWriter(audioOut);
end
% Release input and output objects
release(fileReader)
release(deviceWriter)
0 件のコメント
回答 (1 件)
Kiran Felix Robert
2020 年 8 月 14 日
Hi Ayrton,
In general, the slider callback is executed only when the slider is released. I understand that you are trying to get the values continuously as the slider is updated and not to wait for the slider to be released. I also assume that you have a working GUI and a working Audio processing callback functions. To get the slider update as it is moved ,the ‘addlistener’ function can be used.
The following example is to print the slider value, as it is being moved, in the command window
Ck = @(empty,ol) disp(ol.AffectedObject.Value);
f = figure();
s = uicontrol(f,'Style','slider');
addlistener(s, 'Value', 'PostSet',Ck);
The callback function can be altered to call the audio processing functions. To share data between the callbacks, refer this link.
Hope this Helps.
Kiran Felix Robert
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Audio I/O and Waveform Generation についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!