Mercurial > hg > octave-nkf
annotate scripts/signal/synthesis.m @ 20830:b65888ec820e draft default tip gccjit
dmalcom gcc jit import
author | Stefan Mahr <dac922@gmx.de> |
---|---|
date | Fri, 27 Feb 2015 16:59:36 +0100 |
parents | f1d0f506ee78 |
children |
rev | line source |
---|---|
19898
4197fc428c7d
maint: Update copyright notices for 2015.
John W. Eaton <jwe@octave.org>
parents:
17744
diff
changeset
|
1 ## Copyright (C) 1995-2015 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 |
20375
f1d0f506ee78
doc: Update more docstrings to have one sentence summary as first line.
Rik <rik@octave.org>
parents:
19898
diff
changeset
|
22 ## 3-element vector @var{c} specifying window size, increment, and window type. |
3191 | 23 ## |
3449 | 24 ## The values @var{y} and @var{c} can be derived by |
3191 | 25 ## |
3449 | 26 ## @example |
27 ## [@var{y}, @var{c}] = stft (@var{x} , @dots{}) | |
28 ## @end example | |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
29 ## @seealso{stft} |
3449 | 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 |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
41 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
|
42 error ("synthesis: C must contain exactly 3 elements"); |
3191 | 43 endif |
3426 | 44 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
45 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
|
46 inc = c(2); |
3191 | 47 w_type = c(3); |
3426 | 48 |
3191 | 49 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
|
50 w_coeff = hanning (w_size); |
3191 | 51 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
|
52 w_coeff = hamming (w_size); |
3191 | 53 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
|
54 w_coeff = ones (w_size, 1); |
3191 | 55 else |
3457 | 56 error ("synthesis: window_type must be 1, 2, or 3"); |
3191 | 57 endif |
3426 | 58 |
11469
c776f063fefe
Overhaul m-script files to use common variable name between code and documentation.
Rik <octave@nomad.inbox5.com>
parents:
7017
diff
changeset
|
59 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
|
60 st = fix ((w_size-inc) / 2); |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
61 z = z(st+1:st+inc, :); |
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
62 w_coeff = w_coeff(st+1:st+inc); |
3191 | 63 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
64 nc = columns (z); |
3191 | 65 for i = 1:nc |
17718
6ed0a8532bcf
Overhaul stft and synthesis functions
Rik <rik@octave.org>
parents:
17338
diff
changeset
|
66 z(:, i) ./= w_coeff; |
3191 | 67 endfor |
3426 | 68 |
14868
5d3a684236b0
maint: Use Octave coding conventions for cuddling parentheses in scripts directory
Rik <octave@nomad.inbox5.com>
parents:
14138
diff
changeset
|
69 x = reshape (z, inc * nc, 1); |
3426 | 70 |
3191 | 71 endfunction |
17338
1c89599167a6
maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents:
14868
diff
changeset
|
72 |