2 Copyright (C) 2003 Paul Brossier
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.
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.
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.
20 #include "aubio_priv.h"
22 #include "utils/scale.h"
24 struct _aubio_scale_t {
33 /* not implemented yet : type in/out data
39 aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig,
40 smpl_t olow, smpl_t ohig) {
41 aubio_scale_t * s = AUBIO_NEW(aubio_scale_t);
42 aubio_scale_set (s, ilow, ihig, olow, ohig);
46 void del_aubio_scale(aubio_scale_t *s) {
50 void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig,
51 smpl_t olow, smpl_t ohig) {
52 smpl_t inputrange = ihig - ilow;
53 smpl_t outputrange= ohig - olow;
58 if (inputrange == 0) {
61 s->scaler = outputrange/inputrange;
63 inputrange = inputrange * -1.0f;
68 void aubio_scale_do (aubio_scale_t *s, fvec_t *input)
71 for (i=0; i < input->channels; i++){
72 for (j=0; j < input->length; j++){
73 input->data[i][j] -= s->ilow;
74 input->data[i][j] *= s->scaler;
75 input->data[i][j] += s->olow;