source: src/scale.c @ dde06ad

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since dde06ad was e8359d7, checked in by Paul Brossier <piem@altern.org>, 18 years ago

update scale deletion function
update scale deletion function

  • Property mode set to 100644
File size: 1.8 KB
Line 
1/*
2         Copyright (C) 2003 Paul Brossier
3
4         This program is free software; you can redistribute it and/or modify
5         it under the terms of the GNU General Public License as published by
6         the Free Software Foundation; either version 2 of the License, or
7         (at your option) any later version.
8
9         This program is distributed in the hope that it will be useful,
10         but WITHOUT ANY WARRANTY; without even the implied warranty of
11         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12         GNU General Public License for more details.
13
14         You should have received a copy of the GNU General Public License
15         along with this program; if not, write to the Free Software
16         Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17*/
18
19#include "aubio_priv.h"
20#include "sample.h"
21#include "scale.h"
22
23struct _aubio_scale_t {
24        smpl_t ilow;
25        smpl_t ihig;
26        smpl_t olow;
27        smpl_t ohig;
28
29        smpl_t scaler;
30        smpl_t irange;
31       
32        /* not implemented yet : type in/out data
33        bool inint;
34        bool outint;
35        */
36};
37
38aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig     ){
39        aubio_scale_t * s = AUBIO_NEW(aubio_scale_t);
40        aubio_scale_set (s, ilow, ihig, olow, ohig);
41        return s;       
42}
43
44void del_aubio_scale(aubio_scale_t *s) {
45        AUBIO_FREE(s);
46}
47
48void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig) 
49{
50        smpl_t inputrange = ihig - ilow;
51        smpl_t outputrange= ohig - olow;
52        s->ilow = ilow;
53        s->ihig = ihig;
54        s->olow = olow;
55        s->ohig = ohig;
56        if (inputrange == 0 )
57                s->scaler = 0.0f;
58        else {
59                s->scaler = outputrange/inputrange;
60                if (inputrange < 0 )
61                        inputrange = inputrange * -1.0f;
62        }
63}
64
65void aubio_scale_do (aubio_scale_t *s, fvec_t *input) 
66{
67        uint_t i, j;
68        for (i=0; i < input->channels; i++){
69                for (j=0;  j < input->length; j++){
70                        input->data[i][j] -= s->ilow;
71                        input->data[i][j] *= s->scaler;
72                        input->data[i][j] += s->olow;
73                }
74        }
75}
76
Note: See TracBrowser for help on using the repository browser.