[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 |
---|
| 21 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
| 22 | * |
---|
| 23 | */ |
---|
| 24 | |
---|
| 25 | #include "libroardsp.h" |
---|
| 26 | |
---|
| 27 | int roardsp_quantify_init (struct roardsp_filter * filter, struct roar_stream * stream, int id) { |
---|
| 28 | |
---|
[1141] | 29 | roardsp_filter_reset(filter, ROARDSP_RESET_FULL); |
---|
[979] | 30 | |
---|
| 31 | return 0; |
---|
| 32 | } |
---|
| 33 | |
---|
| 34 | int roardsp_quantify_calc16 (struct roardsp_filter * filter, void * data, size_t samples) { |
---|
| 35 | int16_t * samp = (int16_t *) data; |
---|
| 36 | register float s; |
---|
| 37 | size_t i; |
---|
| 38 | |
---|
| 39 | for (i = 0; i < samples; i++) { |
---|
| 40 | s = samp[i]; |
---|
| 41 | s /= 32768; |
---|
[987] | 42 | s *= (ROAR_INSTINT)filter->inst; |
---|
[979] | 43 | s = (int16_t)s; |
---|
| 44 | // ROAR_WARN("roardsp_quantify_calc16(*): s=%f", s); |
---|
[987] | 45 | s /= (ROAR_INSTINT)filter->inst; |
---|
[979] | 46 | s *= 32768; |
---|
| 47 | samp[i] = s; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | ROAR_DBG("roardsp_quantify_calc16(*) = 0"); |
---|
| 51 | return 0; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | int roardsp_quantify_ctl (struct roardsp_filter * filter, int cmd, void * data) { |
---|
| 55 | int32_t old; |
---|
| 56 | |
---|
| 57 | if ( cmd == ROARDSP_FCTL_N ) { |
---|
[987] | 58 | old = (ROAR_INSTINT)filter->inst; |
---|
| 59 | filter->inst = (void*)(ROAR_INSTINT)*(int32_t*)data; |
---|
[979] | 60 | *(int32_t*)data = old; |
---|
| 61 | } else { |
---|
| 62 | ROAR_DBG("roardsp_quantify_ctl(*) = -1"); |
---|
| 63 | return -1; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | |
---|
| 67 | ROAR_DBG("roardsp_quantify_ctl(*) = 0"); |
---|
| 68 | return 0; |
---|
| 69 | } |
---|
| 70 | |
---|
[1141] | 71 | int roardsp_quantify_reset (struct roardsp_filter * filter, int what) { |
---|
| 72 | int n = 64; |
---|
| 73 | |
---|
| 74 | if ( filter == NULL ) |
---|
| 75 | return -1; |
---|
| 76 | |
---|
| 77 | switch (what) { |
---|
| 78 | case ROARDSP_RESET_NONE: |
---|
| 79 | case ROARDSP_RESET_STATE: |
---|
| 80 | return 0; |
---|
| 81 | break; |
---|
| 82 | case ROARDSP_RESET_FULL: |
---|
| 83 | roardsp_quantify_ctl(filter, ROARDSP_FCTL_N, &n); |
---|
| 84 | return 0; |
---|
| 85 | break; |
---|
| 86 | default: |
---|
| 87 | return -1; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | return -1; |
---|
| 91 | } |
---|
| 92 | |
---|
[979] | 93 | //ll |
---|