-
Notifications
You must be signed in to change notification settings - Fork 0
/
ExamplesTest.m
80 lines (73 loc) · 3.34 KB
/
ExamplesTest.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
classdef ExamplesTest < matlab.unittest.TestCase
% ExamplesTest tests the examples in the examples folder
properties
result_folder = fullfile(pwd, 'results')
audio_files = {fullfile(pwd, '..', ...
'examples/data/audio/guitar_duple.flac'), fullfile(pwd, '..', ...
'examples/data/audio/guitar_triple.flac')}
example_path = fullfile(pwd, '..', 'examples')
end
methods (Test)
function testEx1(testCase)
addpath(testCase.example_path)
fprintf('\ntestEx1: \n');
% Beat tracking with a pre-trained HMM
Results = ex1_beat_tracking_with_pretrained_hmm(...
testCase.audio_files{1}, testCase.result_folder);
% add all beats and compare to expected solution
exp_sum_beats = 777.48;
act_sum_beats = sum(Results{1}(:, 1));
testCase.verifyLessThan(abs(act_sum_beats-exp_sum_beats), 1e-3);
end
function testEx2(testCase)
addpath(testCase.example_path)
fprintf('\ntestEx2: \n');
% Beat tracking with a pre-trained PF
% Initialize the random number generator using a seed of 1
% to make the results in this example repeatable
rng('default'); rng(1);
Results = ex2_beat_tracking_with_pretrained_pf(...
testCase.audio_files{1}, testCase.result_folder);
% add all beats and compare to expected solution
exp_sum_beats = 777.6201;
act_sum_beats = sum(Results{1}(:, 1));
testCase.verifyLessThan(abs(act_sum_beats-exp_sum_beats), 1e-3);
end
function testEx3(testCase)
addpath(testCase.example_path)
fprintf('\ntestEx3: \n');
rng('default'); rng(1);
% Train a HMM and test it
Results = ex3_train_and_test_hmm(testCase.audio_files{1}, ...
testCase.audio_files, testCase.result_folder);
% add all beats and compare to expected solution
exp_sum_beats = 776.72;
act_sum_beats = sum(Results{1}(:, 1));
testCase.verifyLessThan(abs(act_sum_beats-exp_sum_beats), 1e-3);
end
function testEx4(testCase)
addpath(testCase.example_path)
fprintf('\ntestEx4: \n');
rng('default'); rng(1);
% Train a HMM and test it
Results = ex4_train_and_test_hmm(testCase.audio_files{1}, ...
testCase.audio_files, testCase.result_folder);
% add all beats and compare to expected solution
exp_sum_beats = 776.72;
act_sum_beats = sum(Results{1}(:, 1));
testCase.verifyLessThan(abs(act_sum_beats-exp_sum_beats), 1e-3);
end
function testEx5(testCase)
addpath(testCase.example_path)
fprintf('\ntestEx5: \n');
rng('default'); rng(1);
% Train a HMM and test it
Results = ex5_train_and_test_pf(testCase.audio_files{1}, ...
testCase.audio_files, testCase.result_folder);
% add all beats and compare to expected solution
exp_sum_beats = 777.02;
act_sum_beats = sum(Results{1}(:, 1));
testCase.verifyLessThan(abs(act_sum_beats-exp_sum_beats), 1e-3);
end
end
end