1 /*****************************************************************************
2 * float32.c : precise float32 audio volume implementation
3 *****************************************************************************
4 * Copyright (C) 2002 VLC authors and VideoLAN
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program 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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
33 #include <vlc_common.h>
34 #include <vlc_plugin.h>
36 #include <vlc_aout_volume.h>
38 /*****************************************************************************
40 *****************************************************************************/
41 static int Create( vlc_object_t
* );
43 /*****************************************************************************
45 *****************************************************************************/
47 set_category( CAT_AUDIO
)
48 set_subcategory( SUBCAT_AUDIO_MISC
)
49 set_description( N_("Single precision audio volume") )
50 set_capability( "audio volume", 10 )
51 set_callbacks( Create
, NULL
)
55 * Mixes a new output buffer
57 static void FilterFL32( audio_volume_t
*p_volume
, block_t
*p_buffer
,
60 if( f_multiplier
== 1.f
)
61 return; /* nothing to do */
63 float *p
= (float *)p_buffer
->p_buffer
;
64 for( size_t i
= p_buffer
->i_buffer
/ sizeof(*p
); i
> 0; i
-- )
65 *(p
++) *= f_multiplier
;
70 static void FilterFL64( audio_volume_t
*p_volume
, block_t
*p_buffer
,
73 double *p
= (double *)p_buffer
->p_buffer
;
74 double mult
= f_multiplier
;
76 return; /* nothing to do */
78 for( size_t i
= p_buffer
->i_buffer
/ sizeof(*p
); i
> 0; i
-- )
85 * Initializes the mixer
87 static int Create( vlc_object_t
*p_this
)
89 audio_volume_t
*p_volume
= (audio_volume_t
*)p_this
;
91 switch (p_volume
->format
)
94 p_volume
->amplify
= FilterFL32
;
97 p_volume
->amplify
= FilterFL64
;