High CPU usage when running "soundsc" or "play"
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Stephen23
am 9 Mai 2018
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
Akzeptierte Antwort
Jan
am 9 Mai 2018
Bearbeitet: Jan
am 9 Mai 2018
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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!