[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 | int n = 64; |
---|
| 29 | |
---|
| 30 | roardsp_amp_ctl(filter, ROARDSP_FCTL_N, &n); |
---|
| 31 | |
---|
| 32 | ROAR_DBG("roardsp_quantify_init(*) = 0"); |
---|
| 33 | return 0; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | int roardsp_quantify_calc16 (struct roardsp_filter * filter, void * data, size_t samples) { |
---|
| 37 | int16_t * samp = (int16_t *) data; |
---|
| 38 | register float s; |
---|
| 39 | size_t i; |
---|
| 40 | |
---|
| 41 | for (i = 0; i < samples; i++) { |
---|
| 42 | s = samp[i]; |
---|
| 43 | s /= 32768; |
---|
| 44 | s *= (int32_t)filter->inst; |
---|
| 45 | s = (int16_t)s; |
---|
| 46 | // ROAR_WARN("roardsp_quantify_calc16(*): s=%f", s); |
---|
| 47 | s /= (int32_t)filter->inst; |
---|
| 48 | s *= 32768; |
---|
| 49 | samp[i] = s; |
---|
| 50 | }; |
---|
| 51 | |
---|
| 52 | ROAR_DBG("roardsp_quantify_calc16(*) = 0"); |
---|
| 53 | return 0; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | int roardsp_quantify_ctl (struct roardsp_filter * filter, int cmd, void * data) { |
---|
| 57 | int32_t old; |
---|
| 58 | |
---|
| 59 | if ( cmd == ROARDSP_FCTL_N ) { |
---|
| 60 | old = (int32_t)filter->inst; |
---|
| 61 | filter->inst = (void*)*(int32_t*)data; |
---|
| 62 | *(int32_t*)data = old; |
---|
| 63 | } else { |
---|
| 64 | ROAR_DBG("roardsp_quantify_ctl(*) = -1"); |
---|
| 65 | return -1; |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | |
---|
| 69 | ROAR_DBG("roardsp_quantify_ctl(*) = 0"); |
---|
| 70 | return 0; |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | //ll |
---|