-
Notifications
You must be signed in to change notification settings - Fork 1
/
analysis_2.asv
58 lines (52 loc) · 2.15 KB
/
analysis_2.asv
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
% Where we are reading our audio from.
read_path = './results/snippet_smaller.flac';
% Where we are writing our encoded audio to.
write_path = 'N/A';
% Number of overlapping that happens between each window.
window_overlap_count = 2;
% How soft something has to be, relative to the loudest nearby frequency,
% to be removed from the audio.
softer_factor_threshold = 1;
% Range of octaves to analyse for a given frequency.
octave_analysis_range = 1;
% The further apart an amplitude spike is from other frequencies, the less
% likely it is to drown out said frequency. This variable specifies how
% much 'softer' said frequency's amplitude has to be to be considered
% masked by the other frequency by this equation:
% Drowned out = softness * (1/(octave_distance_weighting * octave_difference + 1)) >
% softer_factor_threshold.
octave_distance_weighting = 4;
% How much of the audio we are analysing, in milliseconds, at any given
% amount of time.
window_time_width = 4;
% Read the audio.
[o_y, o_fs] = audioread(read_path);
audio_sample_len = size(o_y, 1);
audio_info = audioinfo(read_path);
disp(audio_info);
max_softer_factor_threshold = 30;
x_axis = zeros(max_softer_factor_threshold);
y_axis_total_components_removed = zeros(max_softer_factor_threshold);
y_axis_sum_squared_error = zeros(max_softer_factor_threshold);
i = 1;
while softer_factor_threshold <= max_softer_factor_threshold
[n_y, total_components, total_windows, total_components_removed] = ...
psychoacoustic_encoding(...
o_y, o_fs, window_overlap_count, window_time_width, ...
octave_analysis_range, softer_factor_threshold, ...
octave_distance_weighting, read_path, write_path, 1 ...
);
x_axis(i) = softer_factor_threshold;
y_axis_total_components_removed(i) = total_components_removed;
y_axis_sum_squared_error(i) = sum(sum_squared_error(o_y, n_y));
i = i + 1;
softer_factor_threshold = softer_factor_threshold + 1;
end
figure;
plot(x_axis, y_axis_total_components_removed);
xlabel('Frequency (Hz)');
ylabel('softer_factor_threshold');
figure;
plot(x_axis, y_axis_sum_squared_error);
xlabel('Frequency (Hz)');
ylabel('softer_factor_threshold');