Borrar filtros
Borrar filtros

How to read audio on app designer from simulink

4 visualizaciones (últimos 30 días)
Roberto Lemaitre
Roberto Lemaitre el 24 de Mayo de 2021
Respondida: Pavan Guntha el 1 de Sept. de 2021
I want to be able to read the audio output from my simulink simulation on app designer, here's my simulation:
The output is the result of the filtering of an audio file and then everything is summed at the end. I've tried different things but can't manage to get the audio output on my app designer app to later play it, pause it, etc...
If possible, i would like to read the audio with audioplayer to be able to more easily pause and play it. This is the code i have at the moment for writing and reading for example an audio file from my pc.
Any tip or recommendation will be greatly appreciated!

Respuestas (1)

Pavan Guntha
Pavan Guntha el 1 de Sept. de 2021
One of the possible solutions is to use 'sim' command to simulate the Simulink model from the MATLAB App (as you have used in 'subirButtonPushed' callback function). In order to play/ pause/ stop the audio from the MATLAB App, you could use respective playback functions on the 'audioplayer' object as illustrated in the example below.
1) The Simulink model stores the output to a '.wav' file as shown in the figure.
2) The 'startupFcn' function of the MATLAB App simulates the Simulink model and the creates an audioplayer object.
3) The four buttons in the MATLAB App (Play, Pause, Resume & Stop) are attached to their respective callback functions to perform appropriate playback function.
% Callbacks that handle component events
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
[, app.Fs] = audioread('simuLinkMusic.wav');
app.player = audioplayer(, app.Fs);
% Button pushed function: PlayButton
function PlayButtonPushed(app, event)
% Button pushed function: PauseButton
function PauseButtonPushed(app, event)
% Button pushed function: StopButton
function StopButtonPushed(app, event)
% Button pushed function: ResumeButton
function ResumeButtonPushed(app, event)
For more information on playback functions, you could have a look at the documentation page: Play or Record Audio
Hope this helps!


Más información sobre Audio Processing Algorithm Design 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!

Translated by