changeset 30571:faf96757915a

record.m, soundsc.m: Small code tweaks for Octave conventions. * record.m: Rename output parameter to match documentation. * soundsc.m: Use default value for function input parameter to simplify code.
author Rik <rik@octave.org>
date Thu, 30 Dec 2021 11:42:19 -0800
parents d3b1d0e770e2
children 6d96538052b9
files scripts/audio/record.m scripts/audio/soundsc.m
diffstat 2 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/audio/record.m	Thu Dec 30 11:28:56 2021 -0800
+++ b/scripts/audio/record.m	Thu Dec 30 11:42:19 2021 -0800
@@ -36,7 +36,7 @@
 ## @seealso{@audiorecorder/audiorecorder, sound, soundsc}
 ## @end deftypefn
 
-function x = record (sec, fs = 8000)
+function data = record (sec, fs = 8000)
 
   if (nargin < 1)
     print_usage ();
@@ -50,16 +50,14 @@
     error ("record: sample rate FS must be a positive number");
   endif
 
-  x = [];
+  data = [];
 
   if (sec > 0)
-
     rec = audiorecorder (fs, 16, 1);
 
     recordblocking (rec, sec);
 
-    x = getaudiodata (rec);
-
+    data = getaudiodata (rec);
   endif
 
 endfunction
--- a/scripts/audio/soundsc.m	Thu Dec 30 11:28:56 2021 -0800
+++ b/scripts/audio/soundsc.m	Thu Dec 30 11:42:19 2021 -0800
@@ -49,16 +49,12 @@
 ## @seealso{sound, @audioplayer/audioplayer, record}
 ## @end deftypefn
 
-function soundsc (y, fs, nbits, yrange)
+function soundsc (y, fs, nbits, yrange = [])
 
   if (nargin < 1)
     print_usage ();
   endif
 
-  if (nargin < 4)
-    yrange = [];
-  endif
-
   if (nargin < 2 || isempty (fs))
     fs = 8000;
   elseif (nargin == 2 && numel (fs) > 1)