Skip to content

Commit

Permalink
Update to pds.sound.stop to deactivate all sounds if called with no i…
Browse files Browse the repository at this point in the history
…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
lpl1977 authored Mar 1, 2022
1 parent 942f9db commit b20f2da
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 11 deletions.
11 changes: 7 additions & 4 deletions +pds/+eyelink/calibrate.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
% Added .trialSetup of reward structures to prevent error (via pds.behavior.reward.trialSetup)
%


if ~isfield(p.trial.eyelink, 'fixdotW')
p.trial.eyelink.fixdotW = ceil(0.2 * p.trial.display.ppd);
end
Expand All @@ -24,10 +23,14 @@
pds.behavior.reward.trialSetup(p);
end


commandwindow;
if p.trial.sound.use
Beeper
end


%if p.trial.sound.use
% Beeper
%end

disp('*************************************')
disp('Beginning Eyelink Toolbox Calibration')
disp('*************************************')
Expand Down
30 changes: 23 additions & 7 deletions +pds/+sound/stop.m
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

0 comments on commit b20f2da

Please sign in to comment.