Filter löschen
Filter löschen

Using EOF flag to change multimedia block parameters

1 Ansicht (letzte 30 Tage)
random09983492
random09983492 am 29 Apr. 2011
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.

Antworten (1)

Jarrod Rivituso
Jarrod Rivituso am 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 Kommentare
random09983492
random09983492 am 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 am 2 Mai 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.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Prepare Model Inputs and Outputs finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by