annotate scripts/audio/@audioplayer/set.m @ 30568:82b685157e2b

doc: Update documentation in audio/ directory. * __get_properties__.m, audioplayer.m, disp.m, get.m, isplaying.m, pause.m, play.m, playblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, __get_properties__.m, audiorecorder.m, disp.m, get.m, getaudiodata.m, getplayer.m, isrecording.m, pause.m, play.m, record.m, recordblocking.m, resume.m, set.m, stop.m, subsasgn.m, subsref.m, record.m, sound.m, soundsc.m: Re-write lots of documentation for clarity. Add @seealso links in @audioplayer and @audiorecorder classes.
author Rik <rik@octave.org>
date Wed, 29 Dec 2021 18:17:53 -0800
parents 83f9f8bda883
children 6d96538052b9
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 ##
30564
796f54d4ddbf update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents: 29358
diff changeset
3 ## Copyright (C) 2013-2022 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})
30568
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
28 ## @deftypefnx {} {} set (@var{player}, @var{name_cell}, @var{value_cell})
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
29 ## @deftypefnx {} {} set (@var{player}, @var{properties_struct})
20852
516bb87ea72e 2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents: 20231
diff changeset
30 ## @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
31 ## 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
32 ##
19506
fdb8a62ef17a fix docstring style in .m files
John W. Eaton <jwe@octave.org>
parents: 19505
diff changeset
33 ## If @var{name} and @var{value} are cell arrays, set each property to the
30568
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
34 ## corresponding value. Given a structure of properties with fields
20158
7503499a252b doc: Update docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents: 19697
diff changeset
35 ## corresponding to property names, set the value of those properties to the
30568
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
36 ## corresponding field values. Given only an audioplayer object, return a
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
37 ## structure of configurable properties (i.e., writeable properties).
82b685157e2b doc: Update documentation in audio/ directory.
Rik <rik@octave.org>
parents: 30565
diff changeset
38 ## @seealso{@audioplayer/get, @audioplayer/audioplayer}
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
39 ## @end deftypefn
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
40
30561
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
41 function properties = set (varargin)
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
42
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
43 if (nargin < 1 || nargin > 3)
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
44 print_usage ();
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
45 endif
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
46
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
47 player = struct (varargin{1}).player;
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
48
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
49 if (nargin == 1)
30561
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
50 properties.SampleRate = {};
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
51 properties.Tag = {};
1c6e04afe50d doc: improvements to documentation for classes in scripts/ dir.
Rik <rik@octave.org>
parents: 29358
diff changeset
52 properties.UserData = {};
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
53 elseif (nargin == 2)
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
54 for [value, property] = varargin{2}
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
55 setproperty (player, property, value);
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
56 endfor
19507
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
57 elseif (nargin == 3)
dac3191a5301 style fixes for audioplayer and audiorecorder .m files
John W. Eaton <jwe@octave.org>
parents: 19506
diff changeset
58 if (iscell (varargin{2}))
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
59 index = 1;
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
60 for property = varargin{2}
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
61 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
62 index += 1;
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
63 endfor
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
64 else
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
65 setproperty (player, varargin{2}, varargin{3});
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
66 endif
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
67 else
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
68 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
69 endif
19523
5802ea7037d4 style fixes for audioplayer and audiorecorder classes
John W. Eaton <jwe@octave.org>
parents: 19507
diff changeset
70
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
71 endfunction
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
72
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
73 function setproperty (player, property, value)
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
74
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
75 switch (property)
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
76 case "SampleRate"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
77 __player_set_fs__ (player, value);
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
78 case "Tag"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
79 __player_set_tag__ (player, value);
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
80 case "UserData"
19476
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
81 __player_set_userdata__ (player, value);
e1f98e402a7e New files - @audiorecorder and @audioplayer classes
Vytautas Jančauskas <unaudio@gmail.com>
parents:
diff changeset
82 otherwise
19503
36a26a131209 Apply Octave coding style to audio project additions
Mike Miller <mtmiller@ieee.org>
parents: 19500
diff changeset
83 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
84 endswitch
21758
ffad2baa90f7 maint: Use newlines to make code more readable.
Rik <rik@octave.org>
parents: 20852
diff changeset
85
19500
8bb399569393 Add Octave copyright header block to audio project files
Mike Miller <mtmiller@ieee.org>
parents: 19496
diff changeset
86 endfunction