1 /*****************************************************************************
2 * float32.c : precise float32 audio volume implementation
3 *****************************************************************************
4 * Copyright (C) 2002 VLC authors and VideoLAN
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
23 /*****************************************************************************
25 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
35 #include <vlc_aout_volume.h>
37 /*****************************************************************************
39 *****************************************************************************/
40 static int Create( vlc_object_t * );
42 /*****************************************************************************
44 *****************************************************************************/
46 set_category( CAT_AUDIO )
47 set_subcategory( SUBCAT_AUDIO_AFILTER )
48 set_description( N_("Single precision audio volume") )
49 set_capability( "audio volume", 10 )
50 set_callback( Create )
54 * Mixes a new output buffer
56 static void FilterFL32( audio_volume_t *p_volume, block_t *p_buffer,
59 if( f_multiplier == 1.f )
60 return; /* nothing to do */
62 float *p = (float *)p_buffer->p_buffer;
63 for( size_t i = p_buffer->i_buffer / sizeof(*p); i > 0; i-- )
64 *(p++) *= f_multiplier;
69 static void FilterFL64( audio_volume_t *p_volume, block_t *p_buffer,
72 double *p = (double *)p_buffer->p_buffer;
73 double mult = f_multiplier;
75 return; /* nothing to do */
77 for( size_t i = p_buffer->i_buffer / sizeof(*p); i > 0; i-- )
84 * Initializes the mixer
86 static int Create( vlc_object_t *p_this )
88 audio_volume_t *p_volume = (audio_volume_t *)p_this;
90 switch (p_volume->format)
93 p_volume->amplify = FilterFL32;
96 p_volume->amplify = FilterFL64;