-
Notifications
You must be signed in to change notification settings - Fork 2
/
MeasScrmbStats.m
77 lines (65 loc) · 2.57 KB
/
MeasScrmbStats.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
% Compute the statistics of each sound from TeohSpMus
% addpath('~/Documents/Matlab/spectrotemporal-synthesis-v2-master/Sound_Texture_Synthesis_Toolbox');
addpath('~/Documents/Matlab/Sound_Texture_Synthesis_Toolbox');
sndpth = '/Volumes/Untitled/TeohSpMus/OrigScrambExp/';
% sndpth = '/Volumes/Untitled/TeohSpMus/test_synth/synth/';
% List of all stimulus names
% stims = {'stim174_girl_speaking.wav'};
stims = {'stim268_piano.wav',...
'stim315_saxophone_jazz_solo.wav',...
'stim461_latin_music.wav',...
'stim524_cartoon_sound_effects.wav',...
'stim72_cello.wav',...
'stim174_girl_speaking.wav',...
'stim332_angry_shouting.wav',...
'stim501_spanish.wav',...
'stim503_italian.wav',...
'stim504_german.wav',...
'stim216_knuckle_cracking.wav',...
'stim399_walking_on_hard_surface.wav',...
'stim401_walking_with_heels.wav',...
'stim81_chopping_wood.wav',...
'stim85_clipping_hair.wav'};
% Load general parameters for calculating the stimulus statistics (based on
% McDermott & Simoncelli (2011)
synthesis_parameters;
P.constraint_set.mod_C2 = 1; % to make sure the mod_C2 stats are right
sndfl = cell(length(stims),2); % to store sound filename
SNRs = cell(length(stims),1);
for n = 1:length(stims),
%%% Original sound stats
% Load the sound
sndfl{n,1} = ['norm_' stims{n}];
[y,Fs] = audioread([sndpth sndfl{n,1}]);
% Set the initial parameters
P.orig_sound_filename = sndfl{n,1};
P.orig_sound_folder = sndpth;
dur = length(y)/Fs;
P.max_orig_dur_s = dur;
P.desired_synth_dur_s = dur;
% Compute the statistics
% use raised-cosine measurement window for original
meas_win = set_measurement_window(length(y), P.measurement_windowing, P);
normS = measure_texture_stats(y,P,meas_win);
normS = edit_measured_stats(normS,P);
%%% Synth sound stats
% Load the sound
sndfl{n,2} = ['synth_' stims{n}];
[y,Fs] = audioread([sndpth sndfl{n,2}]);
% Set the initial parameters
P.orig_sound_filename = sndfl{n,2};
P.orig_sound_folder = sndpth;
dur = length(y)/Fs;
P.max_orig_dur_s = dur;
P.desired_synth_dur_s = dur;
% Compute the statistics
% use imposition window for synthesized sound
imp_win = set_measurement_window(length(y), P.imposition_windowing, P);
synthS = measure_texture_stats(y,P,imp_win);
% synthS = edit_measured_stats(synthS,P);
%%% Compute the SNRs
SNRs{n} = compute_stat_SNRs(normS,synthS,P,[],1);
disp(sndfl{n,1}); disp(sndfl{n,2});
end
% Display the average SNRs for subband, env, and mod
save('SynthStats','SNRs','sndfl');