Mercurial > hg > simscene-py
comparison nonExposed/timeDomainVisualization.m @ 14:b1901e8d8f5f
initial commit
author | Mathieu Lagrange <mathieu.lagrange@cnrs.fr> |
---|---|
date | Tue, 17 Mar 2015 09:34:13 +0100 |
parents | |
children | 92f73423eb37 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 14:b1901e8d8f5f |
---|---|
1 function status = timeDomainVisualization (tracks, cmap, figNum, maxWidth, lineThickness, fileName) | |
2 | |
3 % This program was written by Mathias Rossignol & Grégoire Lafay | |
4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr> | |
5 % | |
6 % This program is free software: you can redistribute it and/or modify it | |
7 % under the terms of the GNU General Public License as published by the Free | |
8 % Software Foundation, either version 3 of the License, or (at your option) | |
9 % any later version. | |
10 % | |
11 % This program is distributed in the hope that it will be useful, but | |
12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | |
13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
14 % for more details. | |
15 % | |
16 % You should have received a copy of the GNU General Public License along | |
17 % with this program. If not, see <http://www.gnu.org/licenses/>. | |
18 | |
19 nbTracks = size(tracks,1); | |
20 trackLength = length(tracks(1,:)); | |
21 | |
22 % Producing a time domain visualization | |
23 wSize = 8192; | |
24 wStep = 512; | |
25 for t=1:nbTracks | |
26 for i=0:ceil((trackLength-wSize)/wStep) | |
27 % Not really power, but more nicely additive, better suited for | |
28 % this representation I think | |
29 powers(i+1,t) = norm(tracks(t,i*wStep+1:min(trackLength, i*wStep+wSize))); | |
30 end | |
31 end | |
32 | |
33 powers(powers<max(powers(:))/500) = 0; | |
34 | |
35 | |
36 % Screen res is ~90dpi, print res is 150dpi, hence the " /1.6 " | |
37 imgWidth = min(maxWidth, 2*size(powers,1)) / 1.6; | |
38 | |
39 % Displayed version | |
40 f=figure(figNum); | |
41 clf; | |
42 h=area(powers,'LineWidth', lineThickness/1.6, 'EdgeColor', [.3, .3, .3]); | |
43 set(gca,'YTick', []); | |
44 set(f, 'Position', [0, 0, imgWidth, 400],'Visible', 'off'); | |
45 colormap(cmap); | |
46 | |
47 % Version saved to graphic file | |
48 f = figure(1000); | |
49 clf; | |
50 h = area(powers,'LineWidth', lineThickness/1.6, 'EdgeColor', [.3, .3, .3]); | |
51 set(gca,'YTick', []); | |
52 colormap(cmap); | |
53 set(f, 'Visible', 'off'); | |
54 set(f, 'Position', [0, 0, imgWidth, 400]); | |
55 set(f, 'PaperPositionMode', 'auto'); | |
56 print ('-dpng', '-r150', fileName); | |
57 | |
58 status = 1; | |
59 | |
60 end |