Changeset f1eda56
- Timestamp:
- Nov 4, 2007, 4:53:41 PM (17 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- aadd27a
- Parents:
- 2d60be3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/scale.c
r2d60be3 rf1eda56 1 1 /* 2 2 Copyright (C) 2003 Paul Brossier 3 3 4 5 6 7 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 8 9 10 11 12 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 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. 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 17 18 */ 18 19 … … 22 23 23 24 struct _aubio_scale_t { 24 25 26 27 25 smpl_t ilow; 26 smpl_t ihig; 27 smpl_t olow; 28 smpl_t ohig; 28 29 29 30 31 32 33 34 35 30 smpl_t scaler; 31 smpl_t irange; 32 33 /* not implemented yet : type in/out data 34 bool inint; 35 bool outint; 36 */ 36 37 }; 37 38 38 aubio_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; 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); 43 return s; 42 44 } 43 45 44 46 void del_aubio_scale(aubio_scale_t *s) { 45 47 AUBIO_FREE(s); 46 48 } 47 49 48 void 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 } 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; 54 s->ilow = ilow; 55 s->ihig = ihig; 56 s->olow = olow; 57 s->ohig = ohig; 58 if (inputrange == 0) { 59 s->scaler = 0.0f; 60 } else { 61 s->scaler = outputrange/inputrange; 62 if (inputrange < 0) { 63 inputrange = inputrange * -1.0f; 64 } 65 } 63 66 } 64 67 65 68 void aubio_scale_do (aubio_scale_t *s, fvec_t *input) 66 69 { 67 68 69 70 71 72 73 74 70 uint_t i, j; 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; 76 } 77 } 75 78 } 76 79
Note: See TracChangeset
for help on using the changeset viewer.