Mercurial > hg > octave-lyh
annotate scripts/signal/synthesis.m @ 17535:c12c688a35ed default tip lyh
Fix warnings
author | LYH <lyh.kernel@gmail.com> |
---|---|
date | Fri, 27 Sep 2013 17:43:27 +0800 |
parents | 1c89599167a6 |
children |
rev | line source |
---|---|
14138
72c96de7a403
maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents:
11523
diff
changeset
|
1 ## Copyright (C) 1995-2012 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 -*- |
3500 | 20 ## @deftypefn {Function File} {} 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 | |
30 ## @end deftypefn | |
3426 | 31 |
3457 | 32 ## Author: AW <Andreas.Weingessel@ci.tuwien.ac.at> |
33 ## Description: Recover a signal from its short-term Fourier transform | |
3191 | 34 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
35 function x = synthesis (y, c) |
3426 | 36 |
3191 | 37 if (nargin != 2) |
6046 | 38 print_usage (); |
3191 | 39 endif |
3426 | 40 |
3238 | 41 [nr, nc] = size (c); |
3191 | 42 if (nr * nc != 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); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
62 z = z(st:st+inc-1, :); |
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
63 w_coeff = w_coeff(st:st+inc-1); |
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 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
67 z(:, i) = 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 |
17346
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
73 |