Mercurial > forge
changeset 17:2824c708cecb octave-forge
Restore octave default behaviour even though it differs from matlab.
author | pkienzle |
---|---|
date | Mon, 29 Oct 2001 15:39:11 +0000 |
parents | cbd867d31022 |
children | 17e1a5a6b6da |
files | FIXES/lin2mu.m FIXES/mu2lin.m |
diffstat | 2 files changed, 19 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/FIXES/lin2mu.m Mon Oct 29 15:37:47 2001 +0000 +++ b/FIXES/lin2mu.m Mon Oct 29 15:39:11 2001 +0000 @@ -30,13 +30,24 @@ ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> ## Created: 17 October 1994 ## Adapted-By: jwe + ## Paul Kienzle <pkienzle@kienzle.powernet.co.uk> ## handle [-1,1] input range +## 2001-10-22 Paul Kienzle +## * restore Octave's guessing behaviour for precision, but issue warning function y = lin2mu (x, bit) if (nargin == 1) - bit = 0; + range = max(abs(x(:))); + if (range <= 1) + bit = 0; + elseif (range <= 128) + bit = 8; + warning ("lin2mu: no precision specified, so using %d", bit); + else + bit = 16; + endif elseif (nargin == 2) if (bit != 0 && bit != 8 && bit != 16) error ("lin2mu: bit must be either 0, 8 or 16");
--- a/FIXES/mu2lin.m Mon Oct 29 15:37:47 2001 +0000 +++ b/FIXES/mu2lin.m Mon Oct 29 15:39:11 2001 +0000 @@ -22,21 +22,25 @@ ## If the matrix @var{x} represents audio data in mu-law encoding, ## @code{mu2lin} converts it to linear encoding. The optional argument ## @var{bps} specifies whether the output data uses 8 bit samples (range -## -128 to 127), 16 bit samples (range -32768 to 32767) or default 0 for -## real values (range -1 to 1). +## -128 to 128), 16 bit samples (range -32768 to 32768) or 0 for +## real values (range -1 to 1). The default is 8. ## @end deftypefn ## @seealso{lin2mu, loadaudio, saveaudio, playaudio, setaudio, and record} ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> ## Created: 18 October 1994 ## Adapted-By: jwe + ## Paul Kienzle <pkienzle@kienzle.powernet.co.uk> ## handle [-1,1] input range +## 2001-10-23 Paul Kienzle <pkienzle@users.sf.net> +## * default to 8-bit as in octave function y = mu2lin (x, bit) if (nargin == 1) - bit = 0; + ## XXX COMPATIBILITY XXX: bps defaults to 8 for octave, 0 for Matlab + bit = 8; elseif (nargin == 2) if (bit != 0 && bit != 8 && bit != 16) error ("mu2lin: bit must be either 0, 8 or 16");