Mercurial > hg > simscene-py
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nonExposed/timeDomainVisualization.m Tue Mar 17 09:34:13 2015 +0100 @@ -0,0 +1,60 @@ +function status = timeDomainVisualization (tracks, cmap, figNum, maxWidth, lineThickness, fileName) + +% This program was written by Mathias Rossignol & Grégoire Lafay +% is Copyright (C) 2015 IRCAM <http://www.ircam.fr> +% +% This program is free software: you can redistribute it and/or modify it +% under the terms of the GNU General Public License as published by the Free +% Software Foundation, either version 3 of the License, or (at your option) +% any later version. +% +% This program is distributed in the hope that it will be useful, but +% WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +% or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +% for more details. +% +% You should have received a copy of the GNU General Public License along +% with this program. If not, see <http://www.gnu.org/licenses/>. + +nbTracks = size(tracks,1); +trackLength = length(tracks(1,:)); + +% Producing a time domain visualization +wSize = 8192; +wStep = 512; +for t=1:nbTracks + for i=0:ceil((trackLength-wSize)/wStep) + % Not really power, but more nicely additive, better suited for + % this representation I think + powers(i+1,t) = norm(tracks(t,i*wStep+1:min(trackLength, i*wStep+wSize))); + end +end + +powers(powers<max(powers(:))/500) = 0; + + +% Screen res is ~90dpi, print res is 150dpi, hence the " /1.6 " +imgWidth = min(maxWidth, 2*size(powers,1)) / 1.6; + +% Displayed version +f=figure(figNum); +clf; +h=area(powers,'LineWidth', lineThickness/1.6, 'EdgeColor', [.3, .3, .3]); +set(gca,'YTick', []); +set(f, 'Position', [0, 0, imgWidth, 400],'Visible', 'off'); +colormap(cmap); + +% Version saved to graphic file +f = figure(1000); +clf; +h = area(powers,'LineWidth', lineThickness/1.6, 'EdgeColor', [.3, .3, .3]); +set(gca,'YTick', []); +colormap(cmap); +set(f, 'Visible', 'off'); +set(f, 'Position', [0, 0, imgWidth, 400]); +set(f, 'PaperPositionMode', 'auto'); +print ('-dpng', '-r150', fileName); + +status = 1; + +end