Question about "triggerlevel"
Show older comments
Hi all, I have a question about "triggerlevel" when using psychportaudio in psychtoolbox. I am trying to record audio data when a voice input is above a certain threshold. I believe that "triggerlevel" in the code below is doing that work. I would like to know what that trigger level of 0.1 stands for. Does it represent the input audio's amplitude or frequency? what is the unit used here?
- This code below is from function SimpleVoiceTriggerDemo(triggerlevel) https://github.com/Psychtoolbox-3/Psychtoolbox-3/blob/master/Psychtoolbox/PsychDemos/SimpleVoiceTriggerDemo.m
% Sound is captured from the default recording device, waiting
% until the amplitude exceeds some 'triggerlevel'.
%
% If the triggerlevel is exceeded, sound capture stops, returning the
% estimated time of "voice onset" in system time.
if nargin < 1
triggerlevel = 0.1;
fprintf('No "triggerlevel" argument in range 0.0 to 1.0 provided: Will use default of 0.1...\n\n');
end
while level < triggerlevel
% Fetch current audiodata:
[audiodata offset overflow tCaptureStart]= PsychPortAudio('GetAudioData', pahandle);
% Compute maximum signal amplitude in this chunk of data:
if ~isempty(audiodata)
level = max(abs(audiodata(1,:)));
else
level = 0;
end
% Below trigger-threshold?
if level < triggerlevel
% Wait for five milliseconds before next scan:
WaitSecs(0.005);
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Audio Plugin Creation and Hosting in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!