audiorec.m

by

 

Recording of short transients based on input level triggering.

test_audiorec.m
%==========================================================================
% test_audiorec - Test script for evaluating the 'auiorec.m' function.
%
% For more information see 'help audiorec'
%
%==========================================================================
% Version 1.0
%--------------------------------------------------------------------------
% Created: November 14, 2008, by Johan E. Carlson
% Last modified: November 15, 2008, by Johan E. Carlson
%==========================================================================

%--------------------------------------------------------------------------
% Define options for the audio capturing function
%--------------------------------------------------------------------------
audio_opts.duration = 0.15;     % Total duration of sound clip
audio_opts.pretrig = 0.05;      % Pre-trigger (in seconds)
audio_opts.channels = 1;        % Audio input channels to use
audio_opts.trig = 1;            % Trigger source
audio_opts.device = 'winsound'; % Input device to use

%--------------------------------------------------------------------------
% Do the actual recordning. Execution is blocked until a sound event
% occurs.
%--------------------------------------------------------------------------
out = audiorec(44100,0.1,audio_opts);

%--------------------------------------------------------------------------
% Plot the result
%--------------------------------------------------------------------------
figure(1);
plot(out.t,out.X);
xlabel('Time, t (s)');
ylabel('Audio wave form, x(t)');
axis([out.t(1), out.t(end), -1, 1]);
grid on;

Contact us