[979] | 1 | //quantify.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - December 2008 |
---|
| 5 | * |
---|
| 6 | * This file is part of libroardsp a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroardsp is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
[3517] | 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
[979] | 23 | * |
---|
| 24 | */ |
---|
| 25 | |
---|
| 26 | #include "libroardsp.h" |
---|
| 27 | |
---|
| 28 | int roardsp_quantify_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { |
---|
| 29 | |
---|
[1141] | 30 | roardsp_filter_reset(filter, ROARDSP_RESET_FULL); |
---|
[979] | 31 | |
---|
| 32 | return 0; |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | int roardsp_quantify_calc16 (struct roardsp_filter * filter, void * data, size_t samples) { |
---|
| 36 | int16_t * samp = (int16_t *) data; |
---|
| 37 | register float s; |
---|
| 38 | size_t i; |
---|
| 39 | |
---|
| 40 | for (i = 0; i < samples; i++) { |
---|
| 41 | s = samp[i]; |
---|
| 42 | s /= 32768; |
---|
[987] | 43 | s *= (ROAR_INSTINT)filter->inst; |
---|
[979] | 44 | s = (int16_t)s; |
---|
| 45 | // ROAR_WARN("roardsp_quantify_calc16(*): s=%f", s); |
---|
[987] | 46 | s /= (ROAR_INSTINT)filter->inst; |
---|
[979] | 47 | s *= 32768; |
---|
| 48 | samp[i] = s; |
---|
| 49 | }; |
---|
| 50 | |
---|
| 51 | ROAR_DBG("roardsp_quantify_calc16(*) = 0"); |
---|
| 52 | return 0; |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | int roardsp_quantify_ctl (struct roardsp_filter * filter, int cmd, void * data) { |
---|
| 56 | int32_t old; |
---|
| 57 | |
---|
| 58 | if ( cmd == ROARDSP_FCTL_N ) { |
---|
[987] | 59 | old = (ROAR_INSTINT)filter->inst; |
---|
| 60 | filter->inst = (void*)(ROAR_INSTINT)*(int32_t*)data; |
---|
[979] | 61 | *(int32_t*)data = old; |
---|
| 62 | } else { |
---|
| 63 | ROAR_DBG("roardsp_quantify_ctl(*) = -1"); |
---|
| 64 | return -1; |
---|
| 65 | } |
---|
| 66 | |
---|
| 67 | |
---|
| 68 | ROAR_DBG("roardsp_quantify_ctl(*) = 0"); |
---|
| 69 | return 0; |
---|
| 70 | } |
---|
| 71 | |
---|
[1141] | 72 | int roardsp_quantify_reset (struct roardsp_filter * filter, int what) { |
---|
| 73 | int n = 64; |
---|
| 74 | |
---|
| 75 | if ( filter == NULL ) |
---|
| 76 | return -1; |
---|
| 77 | |
---|
| 78 | switch (what) { |
---|
| 79 | case ROARDSP_RESET_NONE: |
---|
| 80 | case ROARDSP_RESET_STATE: |
---|
| 81 | return 0; |
---|
| 82 | break; |
---|
| 83 | case ROARDSP_RESET_FULL: |
---|
| 84 | roardsp_quantify_ctl(filter, ROARDSP_FCTL_N, &n); |
---|
| 85 | return 0; |
---|
| 86 | break; |
---|
| 87 | default: |
---|
| 88 | return -1; |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | return -1; |
---|
| 92 | } |
---|
| 93 | |
---|
[979] | 94 | //ll |
---|