annotate nonExposed/timeDomainVisualization.m @ 51:ebf92ed7d680 tip master

Added -fd (--full-duration) argument.
author Emmanouil Theofanis Chourdakis <e.t.chourdakis@qmul.ac.uk>
date Sun, 30 Sep 2018 13:21:49 +0100
parents 39399de892ef
children
rev   line source
gregoire@16 1 function status = timeDomainVisualization(tracks,figNum,settingFigure,figuresOption,fileName)
mathieu@14 2
mathieu@14 3 % This program was written by Mathias Rossignol & Grégoire Lafay
mathieu@14 4 % is Copyright (C) 2015 IRCAM <http://www.ircam.fr>
mathieu@14 5 %
mathieu@14 6 % This program is free software: you can redistribute it and/or modify it
mathieu@14 7 % under the terms of the GNU General Public License as published by the Free
mathieu@14 8 % Software Foundation, either version 3 of the License, or (at your option)
mathieu@14 9 % any later version.
mathieu@14 10 %
mathieu@14 11 % This program is distributed in the hope that it will be useful, but
mathieu@14 12 % WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
mathieu@14 13 % or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mathieu@14 14 % for more details.
mathieu@14 15 %
mathieu@14 16 % You should have received a copy of the GNU General Public License along
mathieu@14 17 % with this program. If not, see <http://www.gnu.org/licenses/>.
mathieu@14 18
mathieu@14 19 % Producing a time domain visualization
gregoire@16 20 step=0.5; % seconds
gregoire@16 21 wStep = round(step*settingFigure.sr);
gregoire@16 22 wSize = wStep*2;
mathieu@34 23 for t=1:size(tracks,1)
gregoire@16 24 for i=0:floor((size(tracks,2)-wSize)/wStep)
mathieu@14 25 % Not really power, but more nicely additive, better suited for
mathieu@14 26 % this representation I think
gregoire@16 27 powers(i+1,t) = norm(tracks(t,i*wStep+1:min(size(tracks,2), i*wStep+wSize)));
mathieu@14 28 end
mathieu@14 29 end
mathieu@14 30
mathieu@14 31 powers(powers<max(powers(:))/500) = 0;
mathieu@34 32 powers = gaussianSmoothing(powers', 15)';
mathieu@14 33
gregoire@16 34 switch figuresOption
gregoire@16 35 case 1
gregoire@16 36 f=figure('Visible', 'off');
gregoire@16 37 case 2
gregoire@16 38 f=figure(figNum);
gregoire@16 39 end
mathieu@14 40
mathieu@14 41
mathieu@14 42 clf;
mathieu@34 43 h = area(powers,'LineWidth', 2, 'EdgeColor', [.2, .2, .2]);
mathieu@34 44 for t=1:size(tracks,1)
mathieu@34 45 h(t).FaceColor = settingFigure.cmap(t, :);
mathieu@34 46 end
mathieu@34 47
gregoire@16 48 xlim([0 size(powers,1)])
gregoire@16 49 xtick=0:round(20/step):size(powers,1); % every 20 sec
gregoire@16 50 set(gca,'YTick', [],'YTicklabel', [],'xtick',xtick,'xticklabel',xtick*step);
gregoire@16 51 xlabel('time (sec)')
mathieu@34 52 % ylabel('amplitude')
mathieu@14 53
gregoire@16 54 set(findall(f,'-property','FontSize'),'FontSize',settingFigure.FontSize)
gregoire@16 55 set(findall(f,'-property','FontName'),'FontName','Arial')
mathieu@14 56
mathieu@14 57
mathieu@34 58 box off %// remove outer border
mathieu@34 59 set(gca,'ycolor', [1 1 1]);
mathieu@34 60 ax1 = gca;
mathieu@34 61 yruler = ax1.YRuler;
mathieu@34 62 yruler.Axle.Visible = 'off';
mathieu@34 63
mathieu@34 64 if figuresOption == 1
mathieu@34 65 set(f,'PaperUnits','centimeters')
mathieu@34 66 set(f,'PaperPositionMode','manual')
mathieu@34 67 set(f,'papersize',[settingFigure.width,settingFigure.height])
mathieu@34 68 set(f,'paperposition',[0,0,settingFigure.width,settingFigure.height])
mathieu@34 69 set(gca,'ycolor', [1 1 1]);
mathieu@34 70 print(f,fileName,'-dpng')
mathieu@14 71 end
mathieu@34 72
mathieu@34 73
mathieu@34 74 function as = gaussianSmoothing(as, factor)
mathieu@34 75
mathieu@34 76 if ~exist('factor', 'var'), factor = 200; end
mathieu@34 77
mathieu@34 78 % gaussian filtering for smooth display
mathieu@34 79 g = gausswin(ceil(size(as, 2)/factor)); % shall adapt the size to the length of the file
mathieu@34 80 g = g/sum(g);
mathieu@34 81 for k=1:size(as, 1)
mathieu@34 82 as(k, :) = conv(as(k, :), g, 'same');
mathieu@34 83 end
mathieu@34 84
mathieu@34 85