annotate scripts/audio/@audioplayer/set.m @ 30561:1c6e04afe50d

doc: improvements to documentation for classes in scripts/ dir. * +containers/Map.m (remove): Document calling form which returns a Map object. * @ftp/cd.m: Document calling forms which return CWD. * @ftp/dir.m: Document calling form which returns struct array. * @ftp/mput.m: Document calling form which returns cellstr. * @ftp/rename.m: Use @code{} macro around "ftp" for conformity with other functions. * @audioplayer/__get_properties__.m: Match documentation variable names to function prototype names. * @audioplayer/set.m: Match function prototype names to documentation. * @audiorecorder/__get_properties__.m: Match documentation variable names to function prototype names. * @audiorecorder/set.m: Match function prototype names to documentation.
author Rik <rik@octave.org>
date Tue, 28 Dec 2021 08:11:59 -0800
parents 0a5b15007766
children 83f9f8bda883
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ########################################################################
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 ##
29358
0a5b15007766 update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 27923
diff changeset
3 ## Copyright (C) 2013-2021 The Octave Project Developers
27918
b442ec6dda5c use centralized file for copyright info for individual contributors
John W. Eaton <jwe@octave.org>
parents: 26376
diff changeset
4 ##
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 ## See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 ## distribution or <https://octave.org/copyright/>.
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
7 ##
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
8 ## This file is part of Octave.
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
9 ##
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
10 ## Octave is free software: you can redistribute it and/or modify it
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
11 ## under the terms of the GNU General Public License as published by
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
12 ## the Free Software Foundation, either version 3 of the License, or
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
13 ## (at your option) any later version.
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
14 ##
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
15 ## Octave is distributed in the hope that it will be useful, but
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
16 ## WITHOUT ANY WARRANTY; without even the implied warranty of
22755
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
17 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a2b891d0b33 maint: Standardize Copyright formatting.
Rik <rik@octave.org>
parents: 22323
diff changeset
18 ## GNU General Public License for more details.
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
19 ##
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
20 ## You should have received a copy of the GNU General Public License
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
21 ## along with Octave; see the file COPYING. If not, see
24534
194eb4bd202b maint: Update punctuation for GPL v3 license text.
Rik <rik@octave.org>
parents: 23220
diff changeset
22 ## <https://www.gnu.org/licenses/>.
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 ##
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ########################################################################
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
25
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
26 ## -*- texinfo -*-
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
27 ## @deftypefn {} {} set (@var{player}, @var{name}, @var{value})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
28 ## @deftypefnx {} {} set (@var{player}, @var{properties})
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
29 ## @deftypefnx {} {@var{properties} =} set (@var{player})
19505
ce02743b6f2a Fix texinfo docstring syntax for all audio functions
Mike Miller <mtmiller@ieee.org>
parents: 19503
diff changeset
30 ## Set the value of property specified by @var{name} to a given @var{value}.
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
31 ##
19506
fdb8a62ef17a fix docstring style in .m files
John W. Eaton <jwe@octave.org>
parents: 19505
diff changeset
32 ## If @var{name} and @var{value} are cell arrays, set each property to the
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
33 ## corresponding value. Given a structure of @var{properties} with fields
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
34 ## corresponding to property names, set the value of those properties to the
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
35 ## field values. Given only the audioplayer object, return a structure of
30561
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
36 ## configurable properties (i.e., writeable properties).
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
37 ## @end deftypefn
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
38
30561
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
39 function properties = set (varargin)
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
40
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
41 if (nargin < 1 || nargin > 3)
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
42 print_usage ();
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
43 endif
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
44
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
45 player = struct (varargin{1}).player;
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
46
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
47 if (nargin == 1)
30561
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
48 properties.SampleRate = {};
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
49 properties.Tag = {};
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
50 properties.UserData = {};
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
51 elseif (nargin == 2)
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
52 for [value, property] = varargin{2}
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
53 setproperty (player, property, value);
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
54 endfor
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
55 elseif (nargin == 3)
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
56 if (iscell (varargin{2}))
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
57 index = 1;
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
58 for property = varargin{2}
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
59 setproperty (player, char (property), varargin{3}{index});
20231
83792dd9bcc1 Use in-place operators in m-files where possible.
Rik <rik@octave.org>
parents: 20158
diff changeset
60 index += 1;
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
61 endfor
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
62 else
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
63 setproperty (player, varargin{2}, varargin{3});
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
64 endif
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
65 else
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
66 error ("@audioplayer/set: wrong number of arguments to the set method");
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
67 endif
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
68
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
69 endfunction
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
70
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
71 function setproperty (player, property, value)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
72
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
73 switch (property)
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
74 case "SampleRate"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
75 __player_set_fs__ (player, value);
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
76 case "Tag"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
77 __player_set_tag__ (player, value);
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
78 case "UserData"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
79 __player_set_userdata__ (player, value);
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
80 otherwise
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
81 error ("audioplayer: no such property or the property specified is read-only");
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
82 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
83
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
84 endfunction