source: roaraudio/libroardsp/filter_add.c @ 3003:9d0935291fca

Last change on this file since 3003:9d0935291fca was 3001:98395340e261, checked in by phi, 15 years ago

do not use malloc()/free() but roar_mm_*()

File size: 2.0 KB
Line 
1//add.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
27int roardsp_add_init  (struct roardsp_filter * filter, struct roar_stream * stream, int id) {
28 struct roardsp_amp * self = roar_mm_malloc(sizeof(struct roardsp_amp));
29
30 if ( self == NULL )
31  return -1;
32
33 memset(self, 0, sizeof(struct roardsp_amp));
34
35 filter->inst = (void*) self;
36
37 roardsp_filter_reset(filter, ROARDSP_RESET_FULL);
38
39 return 0;
40}
41
42int roardsp_add_calc16  (struct roardsp_filter * filter, void * data, size_t samples) {
43 struct roardsp_amp * self = (struct roardsp_amp *) filter->inst;
44 int16_t * samp = (int16_t *) data;
45 size_t i;
46
47 for (i = 0; i < samples; i++) {
48  samp[i] += self->mul / self->div;
49 };
50
51 return 0;
52}
53
54int roardsp_add_reset (struct roardsp_filter * filter, int what) {
55 struct roardsp_amp * self;
56
57 if ( filter == NULL )
58  return -1;
59
60 if ( filter->inst == NULL )
61  return -1;
62
63 self = filter->inst;
64
65 switch (what) {
66  case ROARDSP_RESET_NONE:
67  case ROARDSP_RESET_STATE:
68    return  0;
69   break;
70  case ROARDSP_RESET_FULL:
71    self->mul = 0;
72    self->div = 1;
73    return  0;
74   break;
75  default:
76    return -1;
77 }
78
79 return -1;
80}
81
82//ll
Note: See TracBrowser for help on using the repository browser.