changeset 12150:605ed5bbb643

mu2lin: make default for N compatible with Matlab
author John W. Eaton <jwe@octave.org>
date Mon, 24 Jan 2011 00:35:42 -0500
parents ed129a03f93c
children 8e1ab522c902
files ChangeLog NEWS scripts/ChangeLog scripts/audio/lin2mu.m scripts/audio/mu2lin.m
diffstat 5 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-01-24  John W. Eaton  <jwe@octave.org>
+
+	* NEWS: Note change in audio/mu2lin.
+
 2010-01-22  Tatsuro MATSUOKA  <tmacchant@yahoo.co.jp>
 
 	* README.MinGW: Small corrections to documentation.
--- a/NEWS
+++ b/NEWS
@@ -413,6 +413,9 @@
       autocov  dispatch  is_global  values
       betai    fstat     krylovb
 
+  * For compatibility with Matlab, mu2lin (x) is now equivalent to
+    mu2lin (x, 0).
+
 Summary of important user-visible changes for version 3.2:
 ---------------------------------------------------------
 
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,10 @@
+2011-01-24  John W. Eaton  <jwe@octave.org>
+
+	* audio/lin2mu: Doc fix.
+
+	* audio/mu2lin.m: Doc fix.
+	For compatibility with Matlab, change default for N to be 8.
+
 2011-01-22  Rik  <octave@nomad.inbox5.com>
 
 	* miscellaneous/info.m: Use reference to bug tracker rather than
--- a/scripts/audio/lin2mu.m
+++ b/scripts/audio/lin2mu.m
@@ -17,12 +17,12 @@
 ## <http://www.gnu.org/licenses/>.
 
 ## -*- texinfo -*-
-## @deftypefn  {Function File} {} lin2mu (@var{x})
-## @deftypefnx {Function File} {} lin2mu (@var{x}, @var{n})
+## @deftypefn {Function File} {} lin2mu (@var{x}, @var{n})
 ## Convert audio data from linear to mu-law.  Mu-law values use 8-bit
 ## unsigned integers.  Linear values use @var{n}-bit signed integers or
 ## floating point values in the range -1 @leq{} @var{x} @leq{} 1 if
 ## @var{n} is 0.
+##
 ## If @var{n} is not specified it defaults to 0, 8, or 16 depending on
 ## the range of values in @var{x}.
 ## @seealso{mu2lin, loadaudio, saveaudio}
--- a/scripts/audio/mu2lin.m
+++ b/scripts/audio/mu2lin.m
@@ -20,8 +20,10 @@
 ## @deftypefn {Function File} {} mu2lin (@var{x}, @var{n})
 ## Convert audio data from mu-law to linear.  Mu-law values are 8-bit
 ## unsigned integers.  Linear values use @var{n}-bit signed integers
-## or floating point values in the range -1@leq{}y@leq{}1 if @var{n} is 0.  If
-## @var{n} is not specified it defaults to 8.
+## or floating point values in the range -1@leq{}y@leq{}1 if @var{n}
+## is 0.
+##
+## If @var{n} is not specified it defaults to 0.
 ## @seealso{lin2mu, loadaudio, saveaudio}
 ## @end deftypefn
 
@@ -29,16 +31,13 @@
 ## Created: 18 October 1994
 ## Adapted-By: jwe
 
-function y = mu2lin (x, n)
+function y = mu2lin (x, n = 0)
 
-  if (nargin == 1)
-    ## COMPATIBILITY -- n defaults to 8 for Octave, 0 for Matlab
-    n = 8;
-  elseif (nargin == 2)
+  if (nargin == 2)
     if (n != 0 && n != 8 && n != 16)
       error ("mu2lin: N must be either 0, 8, or 16");
     endif
-  else
+  elseif (nargin != 1)
     print_usage ();
   endif