source: roaraudio/libroardsp/filter_add.c @ 1140:443d39e4ba48

Last change on this file since 1140:443d39e4ba48 was 979:2d5a48c15b5f, checked in by phi, 15 years ago

added new filter: Add, Quantifier, Clip

File size: 1.6 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 = malloc(sizeof(struct roardsp_amp));
29 int32_t fac;
30
31 if ( self == NULL )
32  return -1;
33
34 memset(self, 0, sizeof(struct roardsp_amp));
35
36 filter->inst = (void*) self;
37
38 fac = 0;
39 roardsp_amp_ctl(filter, ROARDSP_FCTL_MUL, &fac);
40 fac = 1;
41 roardsp_amp_ctl(filter, ROARDSP_FCTL_DIV, &fac);
42
43 return 0;
44}
45
46int roardsp_add_calc16  (struct roardsp_filter * filter, void * data, size_t samples) {
47 struct roardsp_amp * self = (struct roardsp_amp *) filter->inst;
48 int16_t * samp = (int16_t *) data;
49 size_t i;
50
51 for (i = 0; i < samples; i++) {
52  samp[i] += self->mul / self->div;
53 };
54
55 return 0;
56}
57
58//ll
Note: See TracBrowser for help on using the repository browser.