Mercurial > audlegacy
annotate Plugins/Output/crossfade/volume.c @ 540:326de307e2eb trunk
[svn] add playback.c to build
author | nenolod |
---|---|
date | Sat, 28 Jan 2006 09:27:32 -0800 |
parents | 88b38e2414a1 |
children | 5b81b0f310e5 |
rev | line source |
---|---|
259
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
1 /* |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
2 * XMMS Crossfade Plugin |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
3 * Copyright (C) 2000-2004 Peter Eisenlohr <peter@eisenlohr.org> |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
4 * |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
5 * based on the original OSS Output Plugin |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
6 * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
7 * |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
11 * (at your option) any later version. |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
12 * |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
17 * |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
21 * USA. |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
22 */ |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
23 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
24 /* |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
25 * Volume to standard (16bit-le stereo) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
26 */ |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
27 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
28 #ifdef HAVE_CONFIG_H |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
29 # include "config.h" |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
30 #endif |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
31 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
32 #include "volume.h" |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
33 #include <string.h> |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
34 #include <math.h> /* for rintf */ |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
35 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
36 #undef VERBOSE |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
37 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
38 static void set_factor(volume_context_t *vc, gfloat factor) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
39 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
40 vc->factor = factor; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
41 #if 0 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
42 if(vc->factor < 0.01f) vc->factor = 0.01f; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
43 if(vc->factor > 4.0f) vc->factor = 4.0f; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
44 #endif |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
45 #ifdef VERBOSE |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
46 DEBUG(("[crossfade] volume_set_factor: new factor=%.3f\n", vc->factor)); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
47 #endif |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
48 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
49 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
50 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
51 void volume_init(volume_context_t *vc) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
52 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
53 memset(vc, 0, sizeof(*vc)); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
54 vc->active = FALSE; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
55 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
56 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
57 void volume_set_active(volume_context_t *vc, gboolean active) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
58 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
59 vc->active = active; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
60 #ifdef VERBOSE |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
61 DEBUG(("[crossfade] volume_set_active: active=%d\n", vc->active)); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
62 #endif |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
63 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
64 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
65 void volume_set_target_rms(volume_context_t *vc, gint target_rms) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
66 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
67 vc->target_rms = target_rms; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
68 if(vc->active && (vc->song_rms == 0)) { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
69 DEBUG(("[crossfade] volume_set_target_rms: WARNING: song_rms=0!\n")); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
70 vc->factor = 1; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
71 return; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
72 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
73 set_factor(vc, (gfloat)vc->target_rms / (gfloat)vc->song_rms); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
74 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
75 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
76 void volume_set_song_rms(volume_context_t *vc, gint song_rms) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
77 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
78 vc->song_rms = song_rms; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
79 set_factor(vc, (gfloat)vc->target_rms / (gfloat)vc->song_rms); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
80 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
81 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
82 gfloat volume_compute_factor(gint percent, gint dB_range) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
83 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
84 if(percent>=100) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
85 return 1; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
86 if(percent<=0) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
87 return 0; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
88 gfloat dB = (percent-100)/100.0*dB_range; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
89 return pow(10, dB/20); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
90 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
91 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
92 void volume_flow(volume_context_t *vc, gpointer *buffer, gint length) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
93 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
94 gint16 *in = *buffer; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
95 struct timeval tv; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
96 glong dt; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
97 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
98 if(!vc->active) return; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
99 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
100 length /= 2; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
101 while(length--) { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
102 gint out = (gint) rintf((gfloat)*in * vc->factor); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
103 if(out > 32767) { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
104 *in++ = 32767; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
105 vc->clips++; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
106 } else if(out < -32768) { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
107 *in++ = -32768; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
108 vc->clips++; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
109 } else |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
110 *in++ = out; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
111 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
112 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
113 gettimeofday(&tv, NULL); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
114 dt = (tv.tv_sec - vc->tv_last.tv_sec) * 1000 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
115 + (tv.tv_usec - vc->tv_last.tv_usec) / 1000; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
116 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
117 if(((dt < 0) || (dt > 1000)) && (vc->clips > 0)) { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
118 DEBUG(("[crossfade] volume_flow: %d samples clipped!\n", vc->clips)); |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
119 vc->clips = 0; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
120 vc->tv_last = tv; |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
121 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
122 } |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
123 |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
124 void volume_free(volume_context_t *vc) |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
125 { |
88b38e2414a1
[svn] First attempt at porting the crossfade plugin; patches from bug #363 applied, GThreadified, includes fixed. Will most probably not compile as of yet.
chainsaw
parents:
diff
changeset
|
126 } |