forked from KyleZhang1118/Voice-Separation-and-Enhancement
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PrintLoopPCw.m
89 lines (83 loc) · 2.7 KB
/
PrintLoopPCw.m
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
function [Percent] = PrintLoopPCw(tt,NumFrames,oldPercent)
%PrintLoopPCw Prints computation percentage on screen
%
% [PC] = PrintLoopPCw(LOOP,NUMLOOPS,oldPC) prints the current percentage of
% computations done in a loop. Use and initialize as in the following
% examples. Also enables the use with WHILE loops.
%
% PrintLoopPCw('\n\n Starting computations. ');
% for LOOP=1:NUMLOOPS,
% PrintLoopPCw(LOOP,NUMLOOPS);
%
% % ...
% % ... your loop code ...
% % ...
% end
%
% Nested FOR loops example:
%
% PrintLoopPCw('\n\n Starting computations. ');
% for jj=1:NUMJJ,
% for kk=1:NUMKK,
% PrintLoopPCw((jj-1)*NUMKK+kk,NUMJJ*NUMKK);
%
% % ...
% % ... your loop code ...
% % ...
% end
% end
%
% WHILE loop example:
%
% LOOP = 1;
% PC = PrintLoopPCw('\n\n Starting computations. ');
% while LOOP<=NUMLOOPS,
% PC = PrintLoopPCw(LOOP,NUMLOOPS,PC);
%
% % ...
% % ... your loop code including "LOOP = LOOP + 1;" at some stage (even conditionally) ...
% % ...
% end
% Release date: August 2008
% Author: Eric A. Lehmann, Perth, Australia (www.eric-lehmann.com)
%
% Copyright (C) 2008 Eric A. Lehmann
%
% 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/>.
Percent = 0;
if nargin==0, % initialisation
fprintf('Loop execution: done 0%% ');
elseif nargin==1, % customised initialisation
if ~ischar(tt),
error('Single input parameter must be a string');
end
fprintf([tt 'Loop execution: done 0%% ']);
elseif nargin==2, % use with FOR loop
Percent = floor(100*tt/NumFrames);
PercentOld = floor(100*(tt-1)/NumFrames);
if PercentOld~=Percent,
fprintf('\b\b\b\b%-4s',[num2str(Percent) '%']);
end
if tt==NumFrames, % safe to say that this is the last call to PrintLoopPC...
fprintf('\n');
end
else % use with WHILE loop
Percent = floor(100*tt/NumFrames);
if oldPercent~=Percent,
fprintf('\b\b\b\b%-4s',[num2str(Percent) '%']);
if tt==NumFrames, % safe to say that this is the last call to PrintLoopPC...
fprintf('\n');
end
end
end