-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayVCV.m
84 lines (57 loc) · 1.38 KB
/
playVCV.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function playVCV()
pf='Stimuli';
session=1;
if session==0
SessionType='practice';
else
SessionType='test';
end
pf=[pf,filesep,SessionType];
fns = dir([pf,filesep,'*wav']);
N=length(fns);
P=randperm(N);
fns=fns(P);
for k=1:N
fn=fns(k).name;
fprintf('[%3d/%3d] %12s\n',k,N,fn)
%
clear I i1 i2 i3 i4
I=strfind(fn,'_') ;
i1=I(1)+1;
if (I(2)-I(1))==4
i2=i1+2;
token=fn(i1:i2);
vowel=token(1);
consonant=token(2);
i3=I(2)+1;
token_number=fn(i3);
i4=I(3)+1;
if length(fn)==18
snr=fn(i4);
elseif length(fn)==19
snr=fn(i4:i4+1);
end
elseif (I(2)-I(1))==5 % consonant is /sh/
i2=i1+3;
token=fn(i1:i2);
vowel=token(1);
consonant=token(2:3);
i3=I(2)+1;
token_number=fn(i3);
i4=I(3)+1;
if length(fn)==19
snr=fn(i4);
elseif length(fn)==20
snr=fn(i4:i4+1);
end
end
token_number=str2double(token_number);
snr=str2double(snr);
[x,fs]=audioread([pf,filesep,fn]);
% playback
p=audioplayer(x,fs);
play(p);
playblocking(p);
end
%
return