Mercurial > octave
annotate scripts/signal/synthesis.m @ 31706:597f3ee61a48 stable
update Octave Project Developers copyright for the new year
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Fri, 06 Jan 2023 13:11:27 -0500 |
parents | 796f54d4ddbf |
children | 2e484f9f1f18 |
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 ## |
31706
597f3ee61a48
update Octave Project Developers copyright for the new year
John W. Eaton <jwe@octave.org>
parents:
30564
diff
changeset
|
3 ## Copyright (C) 1995-2023 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/>. |
3426 | 7 ## |
3922 | 8 ## This file is part of Octave. |
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 |
3922 | 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. |
3426 | 14 ## |
3922 | 15 ## Octave is distributed in the hope that it will be useful, but |
3191 | 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. |
3426 | 19 ## |
3191 | 20 ## You should have received a copy of the GNU General Public License |
7016 | 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 ######################################################################## |
3191 | 25 |
3449 | 26 ## -*- texinfo -*- |
20852
516bb87ea72e
2015 Code Sprint: remove class of function from docstring for all m-files.
Rik <rik@octave.org>
parents:
20165
diff
changeset
|
27 ## @deftypefn {} {@var{x} =} synthesis (@var{y}, @var{c}) |
3449 | 28 ## Compute a signal from its short-time Fourier transform @var{y} and a |
20165
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19697
diff
changeset
|
29 ## 3-element vector @var{c} specifying window size, increment, and window type. |
3191 | 30 ## |
3449 | 31 ## The values @var{y} and @var{c} can be derived by |
3191 | 32 ## |
3449 | 33 ## @example |
34 ## [@var{y}, @var{c}] = stft (@var{x} , @dots{}) | |
35 ## @end example | |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
36 ## @seealso{stft} |
3449 | 37 ## @end deftypefn |
3426 | 38 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
39 function x = synthesis (y, c) |
3426 | 40 |
3191 | 41 if (nargin != 2) |
6046 | 42 print_usage (); |
3191 | 43 endif |
3426 | 44 |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
45 if (numel (c) != 3) |
11472
1740012184f9
Use uppercase for variable names in error() strings to match Info documentation. Only m-files done.
Rik <octave@nomad.inbox5.com>
parents:
11469
diff
changeset
|
46 error ("synthesis: C must contain exactly 3 elements"); |
3191 | 47 endif |
3426 | 48 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
49 w_size = c(1); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
50 inc = c(2); |
3191 | 51 w_type = c(3); |
3426 | 52 |
3191 | 53 if (w_type == 1) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
54 w_coeff = hanning (w_size); |
3191 | 55 elseif (w_type == 2) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
56 w_coeff = hamming (w_size); |
3191 | 57 elseif (w_type == 3) |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
58 w_coeff = ones (w_size, 1); |
3191 | 59 else |
3457 | 60 error ("synthesis: window_type must be 1, 2, or 3"); |
3191 | 61 endif |
3426 | 62 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
63 z = real (ifft (y)); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
64 st = fix ((w_size-inc) / 2); |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
65 z = z(st+1:st+inc, :); |
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
66 w_coeff = w_coeff(st+1:st+inc); |
3191 | 67 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
68 nc = columns (z); |
3191 | 69 for i = 1:nc |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
70 z(:, i) ./= w_coeff; |
3191 | 71 endfor |
3426 | 72 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
73 x = reshape (z, inc * nc, 1); |
3426 | 74 |
3191 | 75 endfunction |