-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay_chimera.m
67 lines (58 loc) · 1.84 KB
/
play_chimera.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
% %% Display the current working directory
% currentDir = pwd;
% disp(['Current working directory: ' currentDir]);
% files = dir;
% for i=1:length(files)
% fprintf('%s\n',files(i).name);
% end
play_chimera("101.wav", "102.wav")
function play_chimera(name1, name2, Nbands, shuffle)
% Chimera demo - Play auditory chimera from sound files
% Usage: play_chimera(name1, name2, Nbands, shuffle)
% name1, name2 file names of original sounds
% Nbands number(s) of frequency bands (scalar or vector)
% shuffle Set flag to randomize order of stimuli
%
% Copyright Bertrand Delgutte, 1999-2000
%
if nargin < 2, error('Specify original sounds'); end
if nargin < 3, Nbands = [1 8 32]; end
if nargin < 4, shuffle = 0; end
[orig1,Fs] = audioread(name1);
if ~strcmp(name2, 'noise'),
orig2 = audioread(name2);
else
orig2 = psd_matched_noise(orig1);
orig2 = orig2/max(abs(orig2(:)));
end
if shuffle, Nbands = Nbands(randperm(length(Nbands))); end
ndel = round(.2*Fs); % add 200-ms delay between signals
nchan = size(orig1,2);
tmp = [orig1; zeros(ndel, nchan); orig2];
disp('Original sounds')
repeat = 1;
while repeat,
if strcmp(computer,'SUN4'), sunsound(tmp, Fs);
else soundsc(tmp, Fs); end
pause(ceil(length(tmp)/Fs))
r=input('Repeat ("r") or next? ', 's');
if isempty(r) | r ~= 'r', repeat = 0; end
end
for n = Nbands,
file1 = sprintf('%s_env+%s_fts-nb%d', name1, name2, n);
file2 = sprintf('%s_env+%s_fts-nb%d', name2, name1, n);
disp
env1_fts2 = audioread(file1);
env2_fts1 = audioread(file2);
disp(sprintf('%d-band chimera', n))
tmp = [env1_fts2; zeros(ndel, nchan); env2_fts1];
repeat = 1;
while repeat,
if strcmp(computer,'SUN4'), sunsound(tmp, Fs);
else soundsc(tmp, Fs); end
pause(ceil(length(tmp)/Fs))
r=input('Repeat ("r") or next? ', 's');
if isempty(r) | r ~= 'r', repeat = 0; end
end
end
end