Using EOF flag to change multimedia block parameters

3 views (last 30 days)
Hi, I am wondering if it is possible to use the EOF flag on Simulink's 'From Multimedia File' block to trigger block parameter changes. What I am trying to do is this: When the multimedia file is done playing, the model will stop, change file (based on previous user input in the GUI), and restart the model. Basically an audio playlist that will automatically cycle through tracks.
I'm not quite sure how to do this though, since it needs to happen automatically at EOF, and isn't a callback.
Here's what I've done so far:
1. User specifies file to be added to queue.
2. File name and path are stored in separate arrays.
3. Added a series of checks to determine whether or not the model was stopped because of EOF or because of user choice.
4. Wrote code to perform various checks/change audio track/start model.
At this point, my model runs, I can add files to the queue, but at the end of the current file, the model just stops and doesn't change file. My code for changing tracks should work, I'm just not sure where to put it in the GUI code such that the file will change and interact with EOF.

Answers (1)

Jarrod Rivituso
Jarrod Rivituso on 30 Apr 2011
Could you put the logic to switch files and restart the simulation in MATLAB instead?
You could redefine the file using set_param. Something like
set_param('myModel/From Multimedia File','inputFilename','speech_dft.avi')
And then you could restart the simulation
sim('myModel')
I'm not sure about setting parameter values from the file based on EOF. However, if you really wanted to go that route, I would look into the Assertion block in the Simulink -> Model Verification library. It provides a callback mechanism based on an input signal. You could potentially reset a file from there.
  2 Comments
random09983492
random09983492 on 30 Apr 2011
I think your suggestion is what I am doing. The problem is figuring out how to trigger those commands when the simulation stops via EOF, since I do not change the file name/path at the time it is selected, rather I want them to be set once EOF triggers the simulation off.
Kaustubha Govind
Kaustubha Govind on 2 May 2011
The model callback StopFcn is executed at the end of simulation, so you could potentially leverage that. However, that would be a very convoluted way of doing things, and potentially error prone.
How are you running the simulation exactly? Do you use the "sim" command in your GUI code? The "sim" command only returns after the model stops running, so you should then be able to check for new tracks and rerun simulation.

Sign in to comment.

Categories

Find more on Audio Processing Algorithm Design in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!