-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAOExamples.m
47 lines (34 loc) · 1020 Bytes
/
AOExamples.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
%% Generate tone
% Using genTone - see genToneExamples.m for how to use parameters.
% Specify parameters
amp = 0.2;
freq = 800;
dur = 2;
riseDur = 0.02;
Fs = 44100;
phase = 0;
% Generate tone
[tone, tVec, env] = genTone(amp, freq, dur, riseDur, phase, Fs);
% plot
clf
plot(tVec, tone)
hold on
plot(tVec, amp*env)
%% Create audioplayer object
% Creates audiploayer object to handle stimulus and hardware.
% Created with tone passed to L and R channels, and sample rate used to
% generate tone.
ID = -1; % Default device (probably speakers or headphones)
nBits = 24; % Output bits
ao = audioplayer([tone;tone], Fs, nBits, ID);
disp(ao)
%% Play tone
% Calling the play method to output the tone
% This will not block later code from running.
ao.play()
disp('This text is displayed while the output is playing.')
%% Play tone
% Calling the playlBocking method to output the tone
% This will block later code from running.
ao.playblocking()
disp('This text is not displayed until after the output has finished.')