Info

This question is closed. Reopen it to edit or answer.

Why 'simout' from simulink generates 0 arrays for this simple audio-processing example?

1 view (last 30 days)
Hello all !
I am currently doing real-time speech processing with 'Queue(FIFO buffer)' using simulink. I want to process every 0.1s of speech from the Queue.
Firstly, I finished testing basic simulink record-play test by using my microphone and speaker. (like this : http://www.flickr.com/photos/52197146@N07/7225551482/in/photostream) (i.e. microphone and speaker works in simulink)
Next, I built block system for my project. (like this : http://www.flickr.com/photos/52197146@N07/7225598988/in/photostream)
This simulink is executed from matlab mfile. (some of codes shown in the Appendix) After I execute the mfile, 'simout' variable in the workspace is always have 0 value of 2205x1 size. (I just want to know the reason of this.)
And these are the settings for each blocks.
(1) From Audio Device block
[Parameters]
#1 Sample rate : 22050
#2 Queue duration (seconds) : 5
[Outputs]
- Frame size : 2205
(2) Pulse Generator (for 'Push' Queue)
- Amplitude : 1
- Period : 0.1
- Pulse Width (% of period) : 50
- Phase delay : 0
(3) Pulse Generator (for 'Pop' Queue)
- Amplitude : AmpVar (this can be varied in MATLAB command window)
(when I need pop, set 'AmpVar =1', when I don't need pop set 'Ampvar = 0')
(4) Queue
- Register size : 22050
- Triggering type : Rising Edge
Is there anyone who can give me some advice? I really appreciate all of your comments.
Appendix.
[Code for .mfile]
(...)
set_param('record_test','simulationcommand','start');
(...)
for k=1:1000
set_param('record_test','simulationcommand','pause');
while isempty(empty_signal)
set_param('record_test','simulationcommand','pause');
pause(0.0001); % during the pause matlab workspace will get simout from
% simulink workspace
set_param('record_test','simulationcommand','continue');
end
(...)

Answers (1)

Ryan G
Ryan G on 19 May 2012
First, you can add a scope block to the simulation and see what Simulink is doing.
Second, I'm not so sure your simulation method is doing what you think it's doing. Between the simulation pause/continue the simulation is going to run as fast as it can. The MATLAB file and Simulink will not synchronize in any meaningful way.
If you have the aerospace blockset there is a pacer block to force the simulation to run at a slower rate.
Another option would be to run the simulation with a time of inf and utilize an enabled or triggered subsystem to record the data. You could enable/trigger this subsystem when out is non-zero.

Tags

Products

Community Treasure Hunt

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

Start Hunting!