-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to pds.sound.stop to deactivate all sounds if called with no i…
…nput argument (#33) * removed call to Beeper which seemed to becausing memory leak (?) * 20220225 updated sound stop function * 20220226 update to pds.sound.stop to stop all sounds if called with no arguments
- Loading branch information
Showing
2 changed files
with
30 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,32 @@ | ||
function stop(p, sound_name) | ||
% funtion pds.sound.stop(p, sound_name) | ||
% | ||
% | ||
% Stop the sound associated with sound_name. | ||
% - No arguments out | ||
% | ||
% 2020-01-16 TBC Migrated to pds.sound (from pds.audio) to be consistent with field name | ||
% | ||
% Virtual device handle | ||
[~,name] = fileparts(p.trial.sound.wavfiles.(sound_name)); | ||
pahandle = p.trial.sound.(name); | ||
% 2022-02-25 LPL ([email protected]) added functionality to deactivate | ||
% all sounds if function called with one input argument. | ||
% | ||
|
||
% Stop the requested sound | ||
PsychPortAudio('Stop',pahandle); | ||
if(nargin==1) | ||
fields = fieldnames(p.trial.sound.wavfiles); | ||
for i=1:numel(fields) | ||
[~,name] = fileparts(p.trial.sound.wavfiles.(fields{i})); | ||
pahandle = p.trial.sound.(name); | ||
status = PsychPortAudio('getStatus',pahandle); | ||
if(status.Active~=0) | ||
PsychPortAudio('Stop',pahandle); | ||
end | ||
end | ||
else | ||
|
||
% Virtual device handle | ||
[~,name] = fileparts(p.trial.sound.wavfiles.(sound_name)); | ||
pahandle = p.trial.sound.(name); | ||
|
||
% Stop the requested sound | ||
PsychPortAudio('Stop',pahandle); | ||
end | ||
|
||
end |