High CPU usage when running "soundsc" or "play"
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi,
I am trying to play simple beep sounds of various lengths and whenever I run "soundsc" or "play" the CPU usage goes high up. Does anybody known why is this the case and if there is anything that can be done to keep the CPU usage low?
Kind regards, Marius
댓글 수: 4
Stephen23
2018년 5월 9일
Hi,
Thanks for your replies.
I am running Windows 7 Professional with Service Pack 1 on a i5-3210M CPU @2.5Ghz (laptop) and Matlab 2018a. I open up Matlab, paste this code in the command window, hit enter and then monitor the CPU usage.
[y,Fs] = audioread('sounds\beep-1378.125Hz-30s.wav');
player = audioplayer(y, Fs);
play(player);
The sound I am playing is a triangle shape stored as a .wav file and is 30 seconds long. The CPU usage is quite high for the whole duration of the sound playing. Once the sound stops the CPU usage goes down.

Kind regards, Marius
채택된 답변
Jan
2018년 5월 9일
편집: Jan
2018년 5월 9일
My former comment vanished, when your message was moved from the section for answers to the comments. I wrote:
And what do you expect? One of the two cores works for creating the sound. On my i7 with 4 cores/8 threads, playing the sound uses 16% of the processor - to my surprise it is not 12.5%, but at least near to it.
But you are right: Windows can play sounds without blocking a core. See e.g. FEX: jAudio. This allows a buffered output also. Unfortunately it blocks the Matlab session until the sound has been played. I do not understand the methods of this submission, so maybe it is not possible to play the sound non-blocking. But at least jAudio demonstrates, that playing a sound requires just some percent of CPU load.
There are some other submissions in the FileExchange, but their handling is not trivial.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!