Mercurial > hg > emotion-detection-top-level
comparison Code/Descriptors/Matlab/MPEG7/FromWeb/VoiceSauce/func_pickpeaks.m @ 4:92ca03a8fa99 tip
Update to ICASSP 2013 benchmark
author | Dawn Black |
---|---|
date | Wed, 13 Feb 2013 11:02:39 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3:e1cfa7765647 | 4:92ca03a8fa99 |
---|---|
1 function [ymax,inx] = func_pickpeaks(y, winlen) | |
2 % [ymax,inx] = func_pickpeaks(y, winlen) | |
3 % Input: y - from wavread | |
4 % winlen - size of window to use | |
5 % Output: ymax - peak values | |
6 % inx - peak positions | |
7 % Notes: | |
8 % | |
9 % Author: Yen-Liang Shue and Markus Iseli, Speech Processing and Auditory Perception Laboratory, UCLA | |
10 % Copyright UCLA SPAPL 2009 | |
11 | |
12 % first, get all maxima | |
13 ymin = min(y); | |
14 y = y - ymin; | |
15 dy = [y(1); transpose(diff(y))]; % diff() gives a shift by 1: insert one sample | |
16 inx1 = diff(dy < 0); % is +1 for maxima, -1 for minima | |
17 inx1(1) = 0; % do not accept maxima at begining | |
18 inx1(end) = 0; % do not accept maxima at end | |
19 inx = inx1 > 0; % choose maxima only | |
20 ymax= y(inx); | |
21 inx = find(inx); | |
22 %plot(y); | |
23 %hold on; | |
24 %plot(inx,ymax,'or'); | |
25 %hold off; | |
26 | |
27 nofmax = length(ymax); | |
28 if nofmax==1 | |
29 return; | |
30 end | |
31 % now filter maxima with window of length winlen | |
32 for cnt = 1 : nofmax | |
33 arr = inx(1:cnt); | |
34 cmp = inx(cnt)-winlen; | |
35 arr2 = arr>cmp; | |
36 %ymax(arr2) | |
37 [m, mi] = max(ymax(arr2)); | |
38 ymax(arr2)=-60000; | |
39 ymax(mi+length(arr2)-sum(arr2))=m; | |
40 %ymax(arr2) | |
41 end | |
42 temp = find(ymax>0); | |
43 inx = inx(temp); | |
44 ymax = ymax(temp); | |
45 %plot(y); | |
46 %hold on; | |
47 %plot(inx,ymax,'or'); | |
48 %hold off; | |
49 ymax = ymax + ymin; |