This file is indexed.

/usr/share/octave/packages/audio-1.1.4/auplot.m is in octave-audio 1.1.4-5.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
## Copyright (C) 1999 Paul Kienzle
##
## 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 2 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/>.

## -*- texinfo -*-
## @deftypefn {Function File} {[@var{y},@var{t},@var{scale}] = } auplot (@var{x})
## @deftypefnx {Function File} {[@var{y},@var{t},@var{scale}] = } auplot (@var{x},@var{fs})
## @deftypefnx {Function File} {[@var{y},@var{t},@var{scale}] = } auplot (@var{x},@var{fs},@var{offset})
## @deftypefnx {Function File} {[@var{y},@var{t},@var{scale}] = } auplot (@var{...},@var{plotstr})
##
## Plot the waveform data, displaying time on the @var{x} axis.  If you are
## plotting a slice from the middle of an array, you may want to specify
## the @var{offset} into the array to retain the appropriate time index. If
## the waveform contains multiple channels, then the data are scaled to
## the range [-1,1] and shifted so that they do not overlap. If a @var{plotstr}
## is given, it is passed as the third argument to the plot command. This 
## allows you to set the linestyle easily. @var{fs} defaults to 8000 Hz, and 
## @var{offset} defaults to 0 samples.
##
## Instead of plotting directly, you can ask for the returned processed 
## vectors. If @var{y} has multiple channels, the plot should have the y-range
## [-1 2*size(y,2)-1]. scale specifies how much the matrix was scaled
## so that each signal would fit in the specified range.
##
## Since speech samples can be very long, we need a way to plot them
## rapidly. For long signals, auplot windows the data and keeps the
## minimum and maximum values in the window.  Together, these values
## define the minimal polygon which contains the signal.  The number of
## points in the polygon is set with the global variable auplot_points.
## The polygon may be either 'filled' or 'outline', as set by the global
## variable auplot_format.  For moderately long data, the window does
## not contain enough points to draw an interesting polygon. In this
## case, simply choosing an arbitrary point from the window looks best.
## The global variable auplot_window sets the size of the window
## required for creating polygons.  You can turn off the polygons
## entirely by setting auplot_format to 'sampled'.  To turn off fast
## plotting entirely, set auplot_format to 'direct', or set
## auplot_points=1. There is no reason to do this since your screen
## resolution is limited and increasing the number of points plotted
## will not add any information.  auplot_format, auplot_points and
## auplot_window may be set in .octaverc.  By default auplot_format is
## 'outline', auplot_points=1000 and auplot_window=7.
## @end deftypefn

## 2000-03 Paul Kienzle
##     accept either row or column data
##     implement fast plotting
## 2000-04 Paul Kienzle
##     return signal and time vectors if asked

## TODO: test offset and plotstr
## TODO: convert offset to time range in the form used by au
## TODO: rename to au; if nargout return data within time range
## TODO:     otherwise plot the data
function [y_r, t_r, scale_r] = auplot(x, fs, offset, plotstr)

  global auplot_points=1000;
  global auplot_format="outline";
  global auplot_window=7;

  if nargin<1 || nargin>4
    usage("[y, t, scale] = auplot(x [, fs [, offset [, plotstr]]])");
  endif
  if nargin<2, fs = 8000; offset=0; plotstr = []; endif
  if nargin<3, offset=0; plotstr = []; endif
  if nargin<4, plotstr = []; endif
  if ischar(fs), plotstr=fs; fs=8000; endif
  if ischar(offset), plotstr=offset; offset=0; endif
  if isempty(plotstr), plotstr=";;"; endif
  

  if (size(x,1)<size(x,2)), x=x'; endif

  [samples, channels] = size(x);
  r = ceil(samples/auplot_points);
  c = floor(samples/r);
  hastail = (samples>c*r);

  if r==1 || strcmp(auplot_format,"direct")
    ## full plot
    t=[0:samples-1]*1000/fs;
    y=x;
  elseif r<auplot_window || strcmp(auplot_format,"sampled")
    ## sub-sampled plot
    y=x(1:r:samples,:);
    t=[0:size(y,1)-1]*1000*r/fs;
  elseif strcmp(auplot_format,"filled")
    ## filled plot
    if hastail
      t=zeros(2*(c+1),1);
      y=zeros(2*(c+1),channels);
      t(2*c+1)=t(2*c+2)=c*1000*r/fs;
    else
      t=zeros(2*c,1);
      y=zeros(2*c,channels);
    endif
    t(1:2:2*c) = t(2:2:2*c) = [0:c-1]*1000*r/fs;
    for chan=1:channels
      head=reshape(x(1:r*c,chan),r,c);
      y(1:2:2*c,chan) = max(head)';
      y(2:2:2*c,chan) = min(head)';
      if (hastail)
      	tail=x(r*c+1:samples,chan);
      	y(2*c+1,chan)=max(tail);
      	y(2*c+2,chan)=min(tail);
      endif
    endfor
  elseif strcmp(auplot_format,"outline")
    ## outline plot
    if hastail
      y=zeros(2*(c+1)+1,channels);
      t=[0:c]; 
    else 
      y=zeros(2*c+1,channels);
      t=[0:c-1]; 
    endif
    t=[t, fliplr(t), 0]*1000*r/fs;
    for chan=1:channels
      head=reshape(x(1:r*c,chan),r,c);
      if hastail
      	tail=x(r*c+1:samples,chan);
      	y(:,chan)=[max(head), max(tail), min(tail), \
		   fliplr(min(head)),  max(head(:,1))]';
      else
      	y(:,chan)=[max(head), fliplr(min(head)), max(head(:,1))]';
      endif
    endfor
  else
    error("auplot_format must be 'outline', 'filled', 'sampled' or 'direct'");
  endif

  t=t+offset*1000/fs;
  grid;
  if channels > 1
    scale = max(abs(y(:)));
    if (scale > 0) y=y/scale; endif
    for i=1:channels
      y(:,i) = y(:,i) + 2*(i-1);
    end
  else
    scale = 1;
  end

  if nargout >= 1, y_r = y; endif
  if nargout >= 2, t_r = t; endif
  if nargout >= 3, scale_r = scale; endif
  if nargout == 0
    if channels > 1
      unwind_protect ## protect plot state
      	ylabel(sprintf('signal scaled by %f', scale));
      	axis([min(t), max(t), -1, 2*channels-1]);
      	plot(t,y,plotstr);
      unwind_protect_cleanup
      	axis(); ylabel("");
      end_unwind_protect
    else
      plot(t,y,plotstr);
    end
  endif
end

%!demo
%! [x, fs] = auload(file_in_loadpath("sample.wav"));
%! subplot(211); title("single channel"); auplot(x,fs);
%! subplot(212); title("2 channels, x and 3x"); auplot([x, 3*x], fs);
%! oneplot(); title("");

%!demo
%! [x, fs] = auload(file_in_loadpath("sample.wav"));
%! global auplot_points; pts=auplot_points; 
%! global auplot_format; fmt=auplot_format;
%! auplot_points=300;
%! subplot(221); title("filled"); auplot_format="filled"; auplot(x,fs);
%! subplot(223); title("outline"); auplot_format="outline"; auplot(x,fs);
%! auplot_points=900;
%! subplot(222); title("sampled"); auplot_format="sampled"; auplot(x,fs);
%! subplot(224); title("direct"); auplot_format="direct"; auplot(x,fs);
%! auplot_format=fmt; auplot_points=pts; title(""); oneplot();

%!demo
%! [x, fs] = auload(file_in_loadpath("sample.wav"));
%! title("subrange example"); auplot(au(x,fs,300,450),fs)
%! title("");

%!error auplot
%!error auplot(1,2,3,4,5)