source: roaraudio/libroardsp/amp.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: 3.2 KB
Line 
1//amp.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 roar_amp_pcm(void * output, int bits, void * input, int samples, int channels, struct roar_mixer_settings * set) {
29 switch (bits) {
30  case  8: return roar_amp_pcm_8bit (output, input, samples, channels, set); break;
31  case 16: return roar_amp_pcm_16bit(output, input, samples, channels, set); break;
32  case 24: return roar_amp_pcm_24bit(output, input, samples, channels, set); break;
33  case 32: return roar_amp_pcm_32bit(output, input, samples, channels, set); break;
34  default: return -1;
35 }
36}
37
38int roar_amp_pcm_8bit  (int8_t  * output, int8_t  * input, int samples, int channels, struct roar_mixer_settings * set) {
39 int    i;
40 register int s;
41
42 if ( !(input && output) )
43  return -1;
44
45 if (set->rpg_mul == set->rpg_div) {
46  for (i = 0; i < samples; i++) {
47   s  = input[i];
48   s *= set->mixer[i % channels];
49   s /= set->scale;
50   output[i] = s;
51  }
52 } else {
53  for (i = 0; i < samples; i++) {
54   s  = input[i];
55   s *= (set->mixer[i % channels] * set->rpg_mul) / set->rpg_div;
56   s /= set->scale;
57   output[i] = s;
58  }
59 }
60
61 return 0;
62}
63
64int roar_amp_pcm_16bit (int16_t * output, int16_t * input, int samples, int channels, struct roar_mixer_settings * set) {
65 int       i;
66 register int s;
67
68 if ( !(input && output) )
69  return -1;
70
71 if (set->rpg_mul == set->rpg_div) {
72  for (i = 0; i < samples; i++) {
73   s  = input[i];
74   s *= set->mixer[i % channels];
75   s /= set->scale;
76   output[i] = s;
77  }
78 } else {
79  for (i = 0; i < samples; i++) {
80   s  = input[i];
81   s *= (set->mixer[i % channels] * set->rpg_mul) / set->rpg_div;
82   s /= set->scale;
83   output[i] = s;
84  }
85 }
86
87 return 0;
88}
89
90int roar_amp_pcm_24bit (void    * output, void    * input, int samples, int channels, struct roar_mixer_settings * set) {
91 return -1;
92}
93
94int roar_amp_pcm_32bit (int32_t * output, int32_t * input, int samples, int channels, struct roar_mixer_settings * set) {
95#ifdef ROAR_NATIVE_INT64
96 int       i;
97 ROAR_NATIVE_INT64 s;
98
99 if ( !(input && output) )
100  return -1;
101
102 if (set->rpg_mul == set->rpg_div) {
103  for (i = 0; i < samples; i++) {
104   s  = input[i];
105   s *= set->mixer[i % channels];
106   s /= set->scale;
107   output[i] = s;
108  }
109 } else {
110  for (i = 0; i < samples; i++) {
111   s  = input[i];
112   s *= (set->mixer[i % channels] * set->rpg_mul) / set->rpg_div;
113   s /= set->scale;
114   output[i] = s;
115  }
116 }
117
118 return 0;
119#else
120 return -1;
121#endif
122}
123
124//ll
Note: See TracBrowser for help on using the repository browser.