# HG changeset patch # User Mike Miller # Date 1422717832 18000 # Node ID 0165d96076240b975882ebb0dfafeedfa574671c # Parent 408361a8c72fb7d636dca4e6434b55aa8cb93450 Deprecate audio functions loadaudio, playaudio, saveaudio, and setaudio. * NEWS: Announce deprecation. * scripts/deprecated/loadaudio.m, scripts/deprecated/playaudio.m, scripts/deprecated/saveaudio.m, scripts/deprecated/setaudio.m: Move from scripts/audio. Add deprecation warnings to code and to docstrings. * audio.txi: Remove from manual. * lin2mu.m, mu2lin.m, record.m: Remove seealso links. * scripts/deprecated/module.mk: Add to build system in deprecated directory. * scripts/audio/module.mk: Remove from build system in audio directory. diff -r 408361a8c72f -r 0165d9607624 NEWS --- a/NEWS Sat Jan 31 02:42:15 2015 -0500 +++ b/NEWS Sat Jan 31 10:23:52 2015 -0500 @@ -195,14 +195,18 @@ finite | isfinite fmod | rem fnmatch | glob or regexp + loadaudio | audioread luinc | ilu or ichol nfields | numfields octave_tmp_file_name | tempname + playaudio | audioplayer + saveaudio | audiowrite syl | sylvester usage | print_usage allow_noninteger_range_as_index do_braindead_shortcircuit_evaluation + setaudio ** The following functions were deprecated in Octave 3.8 and will be removed from Octave 4.2 (or whatever version is the second major diff -r 408361a8c72f -r 0165d9607624 doc/interpreter/audio.txi --- a/doc/interpreter/audio.txi Sat Jan 31 02:42:15 2015 -0500 +++ b/doc/interpreter/audio.txi Sat Jan 31 10:23:52 2015 -0500 @@ -176,24 +176,8 @@ @DOCSTRING(mu2lin) -@DOCSTRING(loadaudio) - -@DOCSTRING(saveaudio) - -The following functions for audio I/O require special A/D hardware and -operating system support. It is assumed that audio data in linear -encoding can be played and recorded by reading from and writing to -@file{/dev/dsp}, and that similarly @file{/dev/audio} is used for mu-law -encoding. These file names are system-dependent. Improvements so that -these functions will work without modification on a wide variety of -hardware are welcome. - -@DOCSTRING(playaudio) - @DOCSTRING(record) -@DOCSTRING(setaudio) - @DOCSTRING(wavread) @DOCSTRING(wavwrite) diff -r 408361a8c72f -r 0165d9607624 scripts/audio/lin2mu.m --- a/scripts/audio/lin2mu.m Sat Jan 31 02:42:15 2015 -0500 +++ b/scripts/audio/lin2mu.m Sat Jan 31 10:23:52 2015 -0500 @@ -25,7 +25,7 @@ ## ## 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} +## @seealso{mu2lin} ## @end deftypefn diff -r 408361a8c72f -r 0165d9607624 scripts/audio/loadaudio.m --- a/scripts/audio/loadaudio.m Sat Jan 31 02:42:15 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -## Copyright (C) 1995-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave 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. -## -## Octave 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 Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} loadaudio (@var{name}, @var{ext}, @var{bps}) -## Load audio data from the file @file{@var{name}.@var{ext}} into the -## vector @var{x}. -## -## The extension @var{ext} determines how the data in the audio file is -## interpreted; the extensions @file{lin} (default) and @file{raw} -## correspond to linear, the extensions @file{au}, @file{mu}, or @file{snd} -## to mu-law encoding. -## -## The argument @var{bps} can be either 8 (default) or 16, and specifies -## the number of bits per sample used in the audio file. -## @seealso{lin2mu, mu2lin, saveaudio, playaudio, setaudio, record} -## @end deftypefn - - -## Author: AW -## Created: 10 April 1994 -## Adapted-By: jwe - -function X = loadaudio (name, ext, bps) - - if (nargin == 0 || nargin > 3) - print_usage (); - endif - - if (nargin == 1) - ext = "lin"; - endif - - if (nargin < 3) - bps = 8; - elseif (bps != 8 && bps != 16) - error ("loadaudio: BPS must be either 8 or 16"); - endif - - name = [name, ".", ext]; - num = fopen (name, "rb"); - - if (strcmp (ext, "lin") || strcmp (ext, "raw") || strcmp (ext, "pcm")) - if (bps == 8) - [Y, c] = fread (num, inf, "uchar"); - X = Y - 127; - else - [X, c] = fread (num, inf, "short"); - endif - elseif (strcmp (ext, "mu") || strcmp (ext, "au") - || strcmp (ext, "snd") || strcmp (ext, "ul")) - [Y, c] = fread (num, inf, "uchar"); - ## remove file header - m = find (Y(1:64) == 0, 1, "last"); - if (! isempty (m)) - Y(1:m) = []; - endif - X = mu2lin (Y, bps); - else - fclose (num); - error ("loadaudio: unsupported extension"); - endif - - fclose (num); - -endfunction - diff -r 408361a8c72f -r 0165d9607624 scripts/audio/module.mk --- a/scripts/audio/module.mk Sat Jan 31 02:42:15 2015 -0500 +++ b/scripts/audio/module.mk Sat Jan 31 10:23:52 2015 -0500 @@ -2,12 +2,8 @@ audio_FCN_FILES = \ audio/lin2mu.m \ - audio/loadaudio.m \ audio/mu2lin.m \ - audio/playaudio.m \ audio/record.m \ - audio/saveaudio.m \ - audio/setaudio.m \ audio/wavread.m \ audio/wavwrite.m \ audio/@audioplayer/__get_properties__.m \ diff -r 408361a8c72f -r 0165d9607624 scripts/audio/mu2lin.m --- a/scripts/audio/mu2lin.m Sat Jan 31 02:42:15 2015 -0500 +++ b/scripts/audio/mu2lin.m Sat Jan 31 10:23:52 2015 -0500 @@ -24,7 +24,7 @@ ## is 0. ## ## If @var{n} is not specified it defaults to 0. -## @seealso{lin2mu, loadaudio, saveaudio} +## @seealso{lin2mu} ## @end deftypefn ## Author: Andreas Weingessel diff -r 408361a8c72f -r 0165d9607624 scripts/audio/playaudio.m --- a/scripts/audio/playaudio.m Sat Jan 31 02:42:15 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,88 +0,0 @@ -## Copyright (C) 1995-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave 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. -## -## Octave 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 Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} playaudio (@var{name}, @var{ext}) -## @deftypefnx {Function File} {} playaudio (@var{x}) -## Play the audio file @file{@var{name}.@var{ext}} or the audio data -## stored in the vector @var{x}. -## @seealso{lin2mu, mu2lin, loadaudio, saveaudio, setaudio, record} -## @end deftypefn - -## Author: AW -## Created: 11 April 1994 -## Adapted-By: jwe - -function playaudio (name, ext) - - if (nargin < 1 || nargin > 2) - print_usage (); - endif - - if (nargin == 1 && isnumeric (name)) - ## play a vector - if (! isvector (name)) - error ("playaudio: X must be a vector"); - endif - X = name(:) + 127; - unwind_protect - file = tempname (); - fid = fopen (file, "wb"); - fwrite (fid, X, "uchar"); - fclose (fid); - [status, out] = system (sprintf ('cat "%s" > /dev/dsp', file)); - if (status != 0) - system (sprintf ("paplay --raw \"%s\"", file)); - endif - unwind_protect_cleanup - unlink (file); - end_unwind_protect - elseif (nargin >= 1 && ischar (name)) - ## play a file - if (nargin == 1) - name = [name ".lin"]; - elseif (nargin == 2) - name = [name "." ext]; - endif - if (any (strcmp (ext, {"lin", "raw"}))) - [status, out] = system (sprintf ('cat "%s" > /dev/dsp', name)); - if (status != 0) - system (sprintf ('paplay --raw "%s"', name)); - endif - elseif (any (strcmp (ext, {"mu", "au" "snd", "ul"}))) - [status, out] = system (sprintf ('cat "%s" > /dev/audio', name)); - if (status != 0) - system (sprintf ('paplay "%s"', name)); - endif - else - error ("playaudio: unsupported extension '%s'", ext); - endif - else - print_usage (); - endif - -endfunction - - -%% Test input validation -%!error playaudio () -%!error playaudio (1,2,3) -%!error playaudio (magic (3)) -%!error playaudio ("file", "abc") -%!error playaudio ({"abc"}) - diff -r 408361a8c72f -r 0165d9607624 scripts/audio/record.m --- a/scripts/audio/record.m Sat Jan 31 02:42:15 2015 -0500 +++ b/scripts/audio/record.m Sat Jan 31 10:23:52 2015 -0500 @@ -22,7 +22,7 @@ ## default value for @var{sampling_rate} is 8000 samples per second, or ## 8kHz. The program waits until the user types @key{RET} and then ## immediately starts to record. -## @seealso{lin2mu, mu2lin, loadaudio, saveaudio, playaudio, setaudio} +## @seealso{lin2mu, mu2lin} ## @end deftypefn ## Author: AW diff -r 408361a8c72f -r 0165d9607624 scripts/audio/saveaudio.m --- a/scripts/audio/saveaudio.m Sat Jan 31 02:42:15 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +0,0 @@ -## Copyright (C) 1995-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave 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. -## -## Octave 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 Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} saveaudio (@var{name}, @var{x}, @var{ext}, @var{bps}) -## Save a vector @var{x} of audio data to the file -## @file{@var{name}.@var{ext}}. The optional parameters @var{ext} and -## @var{bps} determine the encoding and the number of bits per sample used -## in the audio file (see @code{loadaudio}); defaults are @file{lin} and -## 8, respectively. -## @seealso{lin2mu, mu2lin, loadaudio, playaudio, setaudio, record} -## @end deftypefn - -## Author: AW -## Created: 5 September 1994 -## Adapted-By: jwe - -function saveaudio (name, x, ext, bps) - - if (nargin < 2 || nargin > 4) - print_usage (); - endif - - if (nargin == 2) - ext = "lin"; - endif - - if (nargin < 4) - bps = 8; - elseif (bps != 8 && bps != 16) - error ("saveaudio: BPS must be either 8 or 16"); - endif - - [nr, nc] = size (x); - if (nc != 1) - if (nr == 1) - x = x'; - nr = nc; - else - error ("saveaudio: X must be a vector"); - endif - endif - - num = fopen ([name, ".", ext], "wb"); - - if (strcmp (ext, "lin") || strcmp (ext, "raw")) - if (bps == 8) - ld = max (abs (x)); - if (ld > 127) # convert 16 to 8 bit - if (ld < 16384) - sc = 64 / ld; - else - sc = 1 / 256; - endif - x = fix (x * sc); - endif - x = x + 127; - c = fwrite (num, x, "uchar"); - else - c = fwrite (num, x, "short"); - endif - elseif (strcmp (ext, "mu") || strcmp (ext, "au") - || strcmp (ext, "snd") || strcmp (ext, "ul")) - y = lin2mu (x); - c = fwrite (num, y, "uchar"); - else - fclose (num); - error ("saveaudio: unsupported extension"); - endif - - fclose (num); - -endfunction - diff -r 408361a8c72f -r 0165d9607624 scripts/audio/setaudio.m --- a/scripts/audio/setaudio.m Sat Jan 31 02:42:15 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -## Copyright (C) 1995-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave 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. -## -## Octave 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 Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} setaudio () -## @deftypefnx {Function File} {} setaudio (@var{w_type}) -## @deftypefnx {Function File} {} setaudio (@var{w_type}, @var{value}) -## Execute the shell command @samp{mixer}, possibly with optional -## arguments @var{w_type} and @var{value}. -## @end deftypefn - -## Author: AW -## Created: 5 October 1994 -## Adapted-By: jwe - -function setaudio (w_type, value) - - if (nargin == 0) - system ("mixer"); - elseif (nargin == 1) - system (sprintf ("mixer %s", w_type)); - elseif (nargin == 2) - system (sprintf ("mixer %s %d", w_type, value)); - else - print_usage (); - endif - -endfunction - diff -r 408361a8c72f -r 0165d9607624 scripts/deprecated/loadaudio.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/loadaudio.m Sat Jan 31 10:23:52 2015 -0500 @@ -0,0 +1,93 @@ +## Copyright (C) 1995-2013 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} loadaudio (@var{name}, @var{ext}, @var{bps}) +## +## @code{loadaudio} is deprecated and will be removed in Octave version 4.4. +## Please use @code{audioread} in all new code. +## +## Load audio data from the file @file{@var{name}.@var{ext}} into the +## vector @var{x}. +## +## The extension @var{ext} determines how the data in the audio file is +## interpreted; the extensions @file{lin} (default) and @file{raw} +## correspond to linear, the extensions @file{au}, @file{mu}, or @file{snd} +## to mu-law encoding. +## +## The argument @var{bps} can be either 8 (default) or 16, and specifies +## the number of bits per sample used in the audio file. +## @seealso{lin2mu, mu2lin, saveaudio, playaudio, setaudio, record} +## @end deftypefn + + +## Author: AW +## Created: 10 April 1994 +## Adapted-By: jwe + +function X = loadaudio (name, ext, bps) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "loadaudio is obsolete and will be removed from a future version of Octave, please use audioread instead"); + endif + + if (nargin == 0 || nargin > 3) + print_usage (); + endif + + if (nargin == 1) + ext = "lin"; + endif + + if (nargin < 3) + bps = 8; + elseif (bps != 8 && bps != 16) + error ("loadaudio: BPS must be either 8 or 16"); + endif + + name = [name, ".", ext]; + num = fopen (name, "rb"); + + if (strcmp (ext, "lin") || strcmp (ext, "raw") || strcmp (ext, "pcm")) + if (bps == 8) + [Y, c] = fread (num, inf, "uchar"); + X = Y - 127; + else + [X, c] = fread (num, inf, "short"); + endif + elseif (strcmp (ext, "mu") || strcmp (ext, "au") + || strcmp (ext, "snd") || strcmp (ext, "ul")) + [Y, c] = fread (num, inf, "uchar"); + ## remove file header + m = find (Y(1:64) == 0, 1, "last"); + if (! isempty (m)) + Y(1:m) = []; + endif + X = mu2lin (Y, bps); + else + fclose (num); + error ("loadaudio: unsupported extension"); + endif + + fclose (num); + +endfunction + diff -r 408361a8c72f -r 0165d9607624 scripts/deprecated/module.mk --- a/scripts/deprecated/module.mk Sat Jan 31 02:42:15 2015 -0500 +++ b/scripts/deprecated/module.mk Sat Jan 31 10:23:52 2015 -0500 @@ -20,12 +20,16 @@ deprecated/java_unsigned_conversion.m \ deprecated/javafields.m \ deprecated/javamethods.m \ + deprecated/loadaudio.m \ deprecated/luinc.m \ deprecated/nfields.m \ deprecated/octave_tmp_file_name.m \ + deprecated/playaudio.m \ deprecated/re_read_readline_init_file.m \ deprecated/read_readline_init_file.m \ + deprecated/saveaudio.m \ deprecated/saving_history.m \ + deprecated/setaudio.m \ deprecated/strmatch.m \ deprecated/syl.m \ deprecated/usage.m diff -r 408361a8c72f -r 0165d9607624 scripts/deprecated/playaudio.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/playaudio.m Sat Jan 31 10:23:52 2015 -0500 @@ -0,0 +1,99 @@ +## Copyright (C) 1995-2013 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} playaudio (@var{name}, @var{ext}) +## @deftypefnx {Function File} {} playaudio (@var{x}) +## +## @code{playaudio} is deprecated and will be removed in Octave version 4.4. +## Please use @code{audioplayer} in all new code. +## +## Play the audio file @file{@var{name}.@var{ext}} or the audio data +## stored in the vector @var{x}. +## @seealso{lin2mu, mu2lin, loadaudio, saveaudio, setaudio, record} +## @end deftypefn + +## Author: AW +## Created: 11 April 1994 +## Adapted-By: jwe + +function playaudio (name, ext) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "playaudio is obsolete and will be removed from a future version of Octave, please use audioplayer instead"); + endif + + if (nargin < 1 || nargin > 2) + print_usage (); + endif + + if (nargin == 1 && isnumeric (name)) + ## play a vector + if (! isvector (name)) + error ("playaudio: X must be a vector"); + endif + X = name(:) + 127; + unwind_protect + file = tempname (); + fid = fopen (file, "wb"); + fwrite (fid, X, "uchar"); + fclose (fid); + [status, out] = system (sprintf ('cat "%s" > /dev/dsp', file)); + if (status != 0) + system (sprintf ("paplay --raw \"%s\"", file)); + endif + unwind_protect_cleanup + unlink (file); + end_unwind_protect + elseif (nargin >= 1 && ischar (name)) + ## play a file + if (nargin == 1) + name = [name ".lin"]; + elseif (nargin == 2) + name = [name "." ext]; + endif + if (any (strcmp (ext, {"lin", "raw"}))) + [status, out] = system (sprintf ('cat "%s" > /dev/dsp', name)); + if (status != 0) + system (sprintf ('paplay --raw "%s"', name)); + endif + elseif (any (strcmp (ext, {"mu", "au" "snd", "ul"}))) + [status, out] = system (sprintf ('cat "%s" > /dev/audio', name)); + if (status != 0) + system (sprintf ('paplay "%s"', name)); + endif + else + error ("playaudio: unsupported extension '%s'", ext); + endif + else + print_usage (); + endif + +endfunction + + +%% Test input validation +%!error playaudio () +%!error playaudio (1,2,3) +%!error playaudio (magic (3)) +%!error playaudio ("file", "abc") +%!error playaudio ({"abc"}) + diff -r 408361a8c72f -r 0165d9607624 scripts/deprecated/saveaudio.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/saveaudio.m Sat Jan 31 10:23:52 2015 -0500 @@ -0,0 +1,100 @@ +## Copyright (C) 1995-2013 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} saveaudio (@var{name}, @var{x}, @var{ext}, @var{bps}) +## +## @code{saveaudio} is deprecated and will be removed in Octave version 4.4. +## Please use @code{audiowrite} in all new code. +## +## Save a vector @var{x} of audio data to the file +## @file{@var{name}.@var{ext}}. The optional parameters @var{ext} and +## @var{bps} determine the encoding and the number of bits per sample used +## in the audio file (see @code{loadaudio}); defaults are @file{lin} and +## 8, respectively. +## @seealso{lin2mu, mu2lin, loadaudio, playaudio, setaudio, record} +## @end deftypefn + +## Author: AW +## Created: 5 September 1994 +## Adapted-By: jwe + +function saveaudio (name, x, ext, bps) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "saveaudio is obsolete and will be removed from a future version of Octave, please use audiowrite instead"); + endif + + if (nargin < 2 || nargin > 4) + print_usage (); + endif + + if (nargin == 2) + ext = "lin"; + endif + + if (nargin < 4) + bps = 8; + elseif (bps != 8 && bps != 16) + error ("saveaudio: BPS must be either 8 or 16"); + endif + + [nr, nc] = size (x); + if (nc != 1) + if (nr == 1) + x = x'; + nr = nc; + else + error ("saveaudio: X must be a vector"); + endif + endif + + num = fopen ([name, ".", ext], "wb"); + + if (strcmp (ext, "lin") || strcmp (ext, "raw")) + if (bps == 8) + ld = max (abs (x)); + if (ld > 127) # convert 16 to 8 bit + if (ld < 16384) + sc = 64 / ld; + else + sc = 1 / 256; + endif + x = fix (x * sc); + endif + x = x + 127; + c = fwrite (num, x, "uchar"); + else + c = fwrite (num, x, "short"); + endif + elseif (strcmp (ext, "mu") || strcmp (ext, "au") + || strcmp (ext, "snd") || strcmp (ext, "ul")) + y = lin2mu (x); + c = fwrite (num, y, "uchar"); + else + fclose (num); + error ("saveaudio: unsupported extension"); + endif + + fclose (num); + +endfunction + diff -r 408361a8c72f -r 0165d9607624 scripts/deprecated/setaudio.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/deprecated/setaudio.m Sat Jan 31 10:23:52 2015 -0500 @@ -0,0 +1,56 @@ +## Copyright (C) 1995-2013 John W. Eaton +## +## This file is part of Octave. +## +## Octave 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. +## +## Octave 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 Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} setaudio () +## @deftypefnx {Function File} {} setaudio (@var{w_type}) +## @deftypefnx {Function File} {} setaudio (@var{w_type}, @var{value}) +## +## @code{setaudio} is deprecated and will be removed in Octave version 4.4. +## Please scale the audio signal in all new code or use the operating system's +## native tools to adjust audio input and output levels. +## +## Execute the shell command @samp{mixer}, possibly with optional +## arguments @var{w_type} and @var{value}. +## @end deftypefn + +## Author: AW +## Created: 5 October 1994 +## Adapted-By: jwe + +function setaudio (w_type, value) + + persistent warned = false; + if (! warned) + warned = true; + warning ("Octave:deprecated-function", + "setaudio is obsolete and will be removed from a future version of Octave, please scale the audio signal instead"); + endif + + if (nargin == 0) + system ("mixer"); + elseif (nargin == 1) + system (sprintf ("mixer %s", w_type)); + elseif (nargin == 2) + system (sprintf ("mixer %s %d", w_type, value)); + else + print_usage (); + endif + +endfunction +