annotate scripts/audio/mu2lin.m @ 14552:86854d032a37

maint: miscellaneous style fixes for .m files * audio/mu2lin.m, deprecated/cut.m, general/cplxpair.m, general/genvarname.m, geometry/rectint.m, help/gen_doc_cache.m, image/hsv2rgb.m, image/rainbow.m, io/textscan.m, miscellaneous/bzip2.m, miscellaneous/compare_versions.m, miscellaneous/fact.m, miscellaneous/menu.m, optimization/fminbnd.m, optimization/fminunc.m, optimization/fzero.m, optimization/sqp.m, plot/__gnuplot_drawnow__.m, plot/axis.m, plot/findobj.m, plot/legend.m, plot/peaks.m, plot/private/__errplot__.m, plot/private/__fltk_print__.m, plot/private/__go_draw_axes__.m, plot/private/__patch__.m, polynomial/pchip.m, polynomial/residue.m, signal/periodogram.m, sparse/sprandsym.m, statistics/base/moment.m, statistics/distributions/expcdf.m, statistics/distributions/expinv.m, statistics/distributions/exppdf.m, statistics/tests/prop_test_2.m, statistics/tests/sign_test.m, statistics/tests/t_test.m, statistics/tests/t_test_2.m, statistics/tests/t_test_regression.m, strings/regexptranslate.m, time/datetick.m: Style fixes.
author John W. Eaton <jwe@octave.org>
date Wed, 11 Apr 2012 22:07:00 -0400
parents 72c96de7a403
children 1c89599167a6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 12150
diff changeset
1 ## Copyright (C) 1995-2012 John W. Eaton
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
2 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
3 ## This file is part of Octave.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
4 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
6 ## under the terms of the GNU General Public License as published by
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
8 ## your option) any later version.
2313
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
9 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
13 ## General Public License for more details.
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
14 ##
5ca126254d15 [project @ 1996-07-11 21:25:22 by jwe]
jwe
parents: 2312
diff changeset
15 ## You should have received a copy of the GNU General Public License
7016
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
93c65f2a5668 [project @ 2007-10-12 06:40:56 by jwe]
jwe
parents: 6046
diff changeset
17 ## <http://www.gnu.org/licenses/>.
2303
5cffc4b8de57 [project @ 1996-06-24 09:15:24 by jwe]
jwe
parents: 1636
diff changeset
18
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 2847
diff changeset
19 ## -*- texinfo -*-
11469
c776f063fefe Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents: 10793
diff changeset
20 ## @deftypefn {Function File} {} mu2lin (@var{x}, @var{n})
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
21 ## Convert audio data from mu-law to linear. Mu-law values are 8-bit
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
22 ## unsigned integers. Linear values use @var{n}-bit signed integers
12150
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
23 ## or floating point values in the range -1@leq{}y@leq{}1 if @var{n}
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
24 ## is 0.
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
25 ##
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
26 ## If @var{n} is not specified it defaults to 0.
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
27 ## @seealso{lin2mu, loadaudio, saveaudio}
3332
7c03933635c6 [project @ 1999-11-02 06:57:12 by jwe]
jwe
parents: 2847
diff changeset
28 ## @end deftypefn
2311
2b5788792cad [project @ 1996-07-11 20:18:38 by jwe]
jwe
parents: 2303
diff changeset
29
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
30 ## Author: Andreas Weingessel <Andreas.Weingessel@ci.tuwien.ac.at>
2312
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
31 ## Created: 18 October 1994
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
32 ## Adapted-By: jwe
204cc7db6f4a [project @ 1996-07-11 21:20:36 by jwe]
jwe
parents: 2311
diff changeset
33
12150
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
34 function y = mu2lin (x, n = 0)
2325
b5568c31ee2c [project @ 1996-07-15 22:20:21 by jwe]
jwe
parents: 2313
diff changeset
35
12150
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
36 if (nargin == 2)
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
37 if (n != 0 && n != 8 && n != 16)
11472
1740012184f9 Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents: 11469
diff changeset
38 error ("mu2lin: N must be either 0, 8, or 16");
1636
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
39 endif
12150
605ed5bbb643 mu2lin: make default for N compatible with Matlab
John W. Eaton <jwe@octave.org>
parents: 11523
diff changeset
40 elseif (nargin != 1)
6046
34f96dd5441b [project @ 2006-10-10 16:10:25 by jwe]
jwe
parents: 5775
diff changeset
41 print_usage ();
1636
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
42 endif
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
43
14552
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
44 ulaw = [32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
45 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
46 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
47 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
48 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
49 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
50 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
51 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
52 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
53 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
54 876, 844, 812, 780, 748, 716, 684, 652, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
55 620, 588, 556, 524, 492, 460, 428, 396, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
56 372, 356, 340, 324, 308, 292, 276, 260, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
57 244, 228, 212, 196, 180, 164, 148, 132, ...
86854d032a37 maint: miscellaneous style fixes for .m files
John W. Eaton <jwe@octave.org>
parents: 14138
diff changeset
58 120, 112, 104, 96, 88, 80, 72, 64, ...
10549
95c3e38098bf Untabify .m scripts
Rik <code@nomad.inbox5.com>
parents: 7017
diff changeset
59 56, 48, 40, 32, 24, 16, 8, 0 ];
1636
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
60
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
61 ulaw = [ -ulaw, ulaw ];
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
62
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
63 ## Set the shape of y to that of x overwrites the contents of y with
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
64 ## ulaw of x.
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
65 y = x;
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
66 y(:) = ulaw (x + 1);
1636
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
67
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
68 ## Convert to real or 8-bit.
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
69 if (n == 0)
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
70 ## [ -32768, 32767 ] -> [ -1, 1)
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
71 y = y/32768;
10793
be55736a0783 Grammarcheck the documentation from m-files.
Rik <octave@nomad.inbox5.com>
parents: 10549
diff changeset
72 elseif (n == 8)
3911
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
73 ld = max (abs (y (:)));
8389e78e67d4 [project @ 2002-04-28 02:15:38 by jwe]
jwe
parents: 3456
diff changeset
74 if (ld < 16384 && ld > 0)
1636
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
75 sc = 64 / ld;
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
76 else
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
77 sc = 1 / 256;
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
78 endif
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
79 y = fix (y * sc);
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
80 endif
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
81
21fe2afb3692 [project @ 1995-11-16 19:16:11 by jwe]
jwe
parents:
diff changeset
82 endfunction