-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathExample.m
More file actions
37 lines (21 loc) · 793 Bytes
/
Example.m
File metadata and controls
37 lines (21 loc) · 793 Bytes
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
%This takes a collection of trumpet notes, estimates the frequency, and classifies each note
close all
clear all
load trumpet_iowa_cell
load class_names_trumpet
load class_frequencies_trumpet
count = zeros(1,35);
for note = 1:35;
x = collection{note};
x = x(10000:10799); %Sample portion of the note
x = (x-mean(x))/max(x); %Normalize
[W1,W2,H1,H2] = CNMFS(x,5,.05,.05,11025); %Compute correntropy decomposition
ind_list(note) = index;
[value,loc] = max(H1);
freq(loc); %Find frequency
note_ind = knnsearch(log2(class_frequencies),log2(freq(loc))); %Classify sample
if note_ind == note
count(note) = 1;
end
end
sum(count)/length(count) %Display percentage of correct notes