source: roaraudio/libroardsp/filter_quantify.c @ 4708:c9d40761088a

Last change on this file since 4708:c9d40761088a was 4708:c9d40761088a, checked in by phi, 13 years ago

updated copyright statements

File size: 2.3 KB
Line 
1//filter_quantify.c:
2
3/*
4 *      Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2008-2011
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, 51 Franklin Street, Fifth Floor,
22 *  Boston, MA 02110-1301, USA.
23 *
24 */
25
26#include "libroardsp.h"
27
28int roardsp_quantify_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
29
30 roardsp_filter_reset(filter, ROARDSP_RESET_FULL);
31
32 return 0;
33}
34
35int 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;
43  s       *= (ROAR_INSTINT)filter->inst;
44  s        = (int16_t)s;
45//  ROAR_WARN("roardsp_quantify_calc16(*): s=%f", s);
46  s       /= (ROAR_INSTINT)filter->inst;
47  s       *= 32768;
48  samp[i]  = s;
49 };
50
51 ROAR_DBG("roardsp_quantify_calc16(*) = 0");
52 return 0;
53}
54
55int roardsp_quantify_ctl   (struct roardsp_filter * filter, int cmd, void * data) {
56 int32_t old;
57
58 if ( cmd == ROARDSP_FCTL_N ) {
59  old = (ROAR_INSTINT)filter->inst;
60  filter->inst = (void*)(ROAR_INSTINT)*(int32_t*)data;
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
72int 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
94//ll
Note: See TracBrowser for help on using the repository browser.