Info
此问题已关闭。 请重新打开它进行编辑或回答。
Why 'simout' from simulink generates 0 arrays for this simple audio-processing example?
1 次查看(过去 30 天)
显示 更早的评论
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
(...)
0 个评论
回答(1 个)
Ryan G
2012-5-19
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.
0 个评论
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!