Mercurial > hg > octave-nkf
annotate scripts/signal/synthesis.m @ 19830:884e0c55d92c
Fix complex compare operation for issorted (bug #44071).
* Array-C.cc (nan_ascending_compare, nan_descending_compare): Fix typo where
comparison was made between x and x rather than between x and y.
author | Rik <rik@octave.org> |
---|---|
date | Mon, 26 Jan 2015 15:32:49 -0800 |
parents | d63878346099 |
children | 4197fc428c7d |
rev | line source |
---|---|
17744
d63878346099
maint: Update copyright notices for release.
John W. Eaton <jwe@octave.org>
parents:
17718
diff
changeset
|
1 ## Copyright (C) 1995-2013 Andreas Weingessel |
3426 | 2 ## |
3922 | 3 ## This file is part of Octave. |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7016 | 7 ## the Free Software Foundation; either version 3 of the License, or (at |
8 ## your option) any later version. | |
3426 | 9 ## |
3922 | 10 ## Octave is distributed in the hope that it will be useful, but |
3191 | 11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
3426 | 13 ## General Public License for more details. |
14 ## | |
3191 | 15 ## You should have received a copy of the GNU General Public License |
7016 | 16 ## along with Octave; see the file COPYING. If not, see |
17 ## <http://www.gnu.org/licenses/>. | |
3191 | 18 |
3449 | 19 ## -*- texinfo -*- |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
20 ## @deftypefn {Function File} {@var{x} =} synthesis (@var{y}, @var{c}) |
3449 | 21 ## Compute a signal from its short-time Fourier transform @var{y} and a |
22 ## 3-element vector @var{c} specifying window size, increment, and | |
23 ## window type. | |
3191 | 24 ## |
3449 | 25 ## The values @var{y} and @var{c} can be derived by |
3191 | 26 ## |
3449 | 27 ## @example |
28 ## [@var{y}, @var{c}] = stft (@var{x} , @dots{}) | |
29 ## @end example | |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
30 ## @seealso{stft} |
3449 | 31 ## @end deftypefn |
3426 | 32 |
3457 | 33 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> |
34 ## Description: Recover a signal from its short-term Fourier transform | |
3191 | 35 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
36 function x = synthesis (y, c) |
3426 | 37 |
3191 | 38 if (nargin != 2) |
6046 | 39 print_usage (); |
3191 | 40 endif |
3426 | 41 |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
42 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
|
43 error ("synthesis: C must contain exactly 3 elements"); |
3191 | 44 endif |
3426 | 45 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
46 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
|
47 inc = c(2); |
3191 | 48 w_type = c(3); |
3426 | 49 |
3191 | 50 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
|
51 w_coeff = hanning (w_size); |
3191 | 52 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
|
53 w_coeff = hamming (w_size); |
3191 | 54 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
|
55 w_coeff = ones (w_size, 1); |
3191 | 56 else |
3457 | 57 error ("synthesis: window_type must be 1, 2, or 3"); |
3191 | 58 endif |
3426 | 59 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
60 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
|
61 st = fix ((w_size-inc) / 2); |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
62 z = z(st+1:st+inc, :); |
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
63 w_coeff = w_coeff(st+1:st+inc); |
3191 | 64 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
65 nc = columns (z); |
3191 | 66 for i = 1:nc |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
67 z(:, i) ./= w_coeff; |
3191 | 68 endfor |
3426 | 69 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
70 x = reshape (z, inc * nc, 1); |
3426 | 71 |
3191 | 72 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
73 |