* -> gives the feeling of a real room with a simple headphone
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: headphone.c,v 1.5 2003/05/15 22:27:37 massiot Exp $
+ * $Id: headphone.c,v 1.6 2003/12/20 22:57:36 babal Exp $
*
* Authors: Boris Dorès <babal@via.ecp.fr>
*
/*****************************************************************************
* Module descriptor
*****************************************************************************/
+#define MODULE_DESCRIPTION N_ ( \
+ "This effect gives you the feeling that you are standing in a room " \
+ "with a complete 5.1 speaker set when using only a headphone, " \
+ "providing a more realistic sound experience. It should also be " \
+ "more comfortable and less tiring when listening to music for " \
+ "long periods of time.\nIt works with any source format from mono " \
+ "to 5.1.")
+
#define HEADPHONE_DIM_TEXT N_("Characteristic dimension")
#define HEADPHONE_DIM_LONGTEXT N_( \
"Headphone virtual spatialization effect parameter: "\
"distance between front left speaker and listener in meters.")
vlc_module_begin();
- add_category_hint( N_("headphone"), NULL, VLC_FALSE );
- add_integer( "headphone-dim", 5, NULL, HEADPHONE_DIM_TEXT,
- HEADPHONE_DIM_LONGTEXT, VLC_TRUE );
- set_description( _("headphone channel mixer with virtual spatialization effect") );
+ add_category_hint( N_("headphone"), MODULE_DESCRIPTION, VLC_FALSE );
+ add_integer( "headphone-dim", 10, NULL, HEADPHONE_DIM_TEXT,
+ HEADPHONE_DIM_LONGTEXT, VLC_FALSE );
+ set_description( N_("headphone channel mixer with virtual spatialization effect") );
+
set_capability( "audio filter", 0 );
set_callbacks( Create, Destroy );
add_shortcut( "headphone" );
* input.c : internal management of input streams for the audio output
*****************************************************************************
* Copyright (C) 2002 VideoLAN
- * $Id: input.c,v 1.41 2003/12/17 23:21:15 hartman Exp $
+ * $Id: input.c,v 1.42 2003/12/20 22:57:36 babal Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
static int VisualizationCallback( vlc_object_t *, char const *,
vlc_value_t, vlc_value_t, void * );
+static aout_filter_t * allocateUserChannelMixer( aout_instance_t *,
+ audio_sample_format_t *,
+ audio_sample_format_t * );
/*****************************************************************************
* aout_InputNew : allocate a new input and rework the filter pipeline
*****************************************************************************/
int aout_InputNew( aout_instance_t * p_aout, aout_input_t * p_input )
{
- audio_sample_format_t intermediate_format;
+ audio_sample_format_t user_filter_format;
+ audio_sample_format_t intermediate_format;/* input of resampler */
vlc_value_t val, text;
char * psz_filters;
+ aout_filter_t * p_user_channel_mixer;
aout_FormatPrint( p_aout, "input", &p_input->input );
sizeof(audio_sample_format_t) );
intermediate_format.i_rate = p_input->input.i_rate;
+ /* Try to use the channel mixer chosen by the user */
+ memcpy ( &user_filter_format, &intermediate_format,
+ sizeof(audio_sample_format_t) );
+ user_filter_format.i_physical_channels = p_input->input.i_physical_channels;
+ user_filter_format.i_original_channels = p_input->input.i_original_channels;
+ user_filter_format.i_bytes_per_frame = user_filter_format.i_bytes_per_frame
+ * aout_FormatNbChannels( &user_filter_format )
+ / aout_FormatNbChannels( &intermediate_format );
+ p_user_channel_mixer = allocateUserChannelMixer( p_aout, &user_filter_format,
+ &intermediate_format );
+ /* If it failed, let the main pipeline do channel mixing */
+ if ( ! p_user_channel_mixer )
+ {
+ memcpy ( &user_filter_format, &intermediate_format,
+ sizeof(audio_sample_format_t) );
+ }
+
/* Create filters. */
if ( aout_FiltersCreatePipeline( p_aout, p_input->pp_filters,
&p_input->i_nb_filters,
&p_input->input,
- &intermediate_format
+ &user_filter_format
) < 0 )
{
msg_Err( p_aout, "couldn't set an input pipeline" );
{
char *psz_parser = psz_filters;
char *psz_next;
- audio_sample_format_t format_in, format_out;
-
- memcpy( &format_in, &p_aout->mixer.mixer,
- sizeof( audio_sample_format_t ) );
- memcpy( &format_out,&p_aout->mixer.mixer,
- sizeof( audio_sample_format_t ) );
-
- format_in.i_rate = p_input->input.i_rate;
- format_out.i_rate = p_input->input.i_rate;
while( psz_parser && *psz_parser )
{
}
vlc_object_attach( p_filter , p_aout );
- memcpy( &p_filter->input, &format_in,
+ memcpy( &p_filter->input, &user_filter_format,
sizeof(audio_sample_format_t) );
- memcpy( &p_filter->output, &format_out,
+ memcpy( &p_filter->output, &user_filter_format,
sizeof(audio_sample_format_t) );
p_filter->p_module =
}
if( psz_filters ) free( psz_filters );
+ /* Attach the user channel mixer */
+ if ( p_user_channel_mixer )
+ {
+ p_input->pp_filters[p_input->i_nb_filters++] = p_user_channel_mixer;
+ }
+
/* Prepare hints for the buffer allocator. */
p_input->input_alloc.i_alloc_type = AOUT_ALLOC_HEAP;
p_input->input_alloc.i_bytes_per_sec = -1;
return VLC_SUCCESS;
}
+
+static aout_filter_t * allocateUserChannelMixer( aout_instance_t * p_aout,
+ audio_sample_format_t * p_input_format,
+ audio_sample_format_t * p_output_format )
+{
+ aout_filter_t * p_channel_mixer;
+
+ /* Retreive user preferred channel mixer */
+ char * psz_name = config_GetPsz( p_aout, "audio-channel-mixer" );
+
+ /* Not specified => let the main pipeline do the mixing */
+ if ( ! psz_name ) return NULL;
+
+ /* Debug information */
+ aout_FormatsPrint( p_aout, "channel mixer", p_input_format,
+ p_output_format );
+
+ /* Create a VLC object */
+ p_channel_mixer = vlc_object_create( p_aout, sizeof(aout_filter_t) );
+ if( p_channel_mixer == NULL )
+ {
+ msg_Err( p_aout, "cannot add user channel mixer %s", psz_name );
+ return NULL;
+ }
+ vlc_object_attach( p_channel_mixer , p_aout );
+
+ /* Attach the suitable module */
+ memcpy( &p_channel_mixer->input, p_input_format,
+ sizeof(audio_sample_format_t) );
+ memcpy( &p_channel_mixer->output, p_output_format,
+ sizeof(audio_sample_format_t) );
+ p_channel_mixer->p_module =
+ module_Need( p_channel_mixer,"audio filter", psz_name );
+ if( p_channel_mixer->p_module== NULL )
+ {
+ msg_Err( p_aout, "cannot add user channel mixer %s", psz_name );
+ vlc_object_detach( p_channel_mixer );
+ vlc_object_destroy( p_channel_mixer );
+ return NULL;
+ }
+ p_channel_mixer->b_continuity = VLC_FALSE;
+
+ /* Ok */
+ return p_channel_mixer;
+}
* libvlc.h: main libvlc header
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: libvlc.h,v 1.124 2003/12/15 14:05:19 hartman Exp $
+ * $Id: libvlc.h,v 1.125 2003/12/20 22:57:36 babal Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
"This allows you to add audio postprocessing filters, to modify " \
"the sound.")
-#define HEADPHONE_TEXT N_("Headphone virtual spatialization effect")
-#define HEADPHONE_LONGTEXT N_( \
- "This effect gives you the feeling that you are standing in a room " \
- "with a complete 5.1 speaker set when using only a headphone, " \
- "providing a more realistic sound experience. It should also be " \
- "more comfortable and less tiring when listening to music for " \
- "long periods of time.\nIt works with any source format from mono " \
- "to 5.1.")
+#define AUDIO_CHANNEL_MIXER N_("Channel mixer")
+#define AUDIO_CHANNEL_MIXER_LONGTEXT N_( \
+ "This allows you to choose a specific audio channel mixer. For instance " \
+ "the headphone channel mixer will downmix any audio source to a stereo " \
+ "output and give the feeling that you are standing in a room with a " \
+ "complete 5.1 speaker set when using only a headphone.")
#define VOUT_CAT_LONGTEXT N_( \
"These options allow you to modify options related to " \
add_bool( "hq-resampling", 1, NULL, AOUT_RESAMP_TEXT, AOUT_RESAMP_LONGTEXT, VLC_TRUE );
#endif
add_bool( "spdif", 0, NULL, SPDIF_TEXT, SPDIF_LONGTEXT, VLC_FALSE );
-#if 0
- add_bool( "headphone-opt", 0, NULL, HEADPHONE_TEXT,
- HEADPHONE_LONGTEXT, VLC_FALSE );
-#endif
add_integer( "audio-desync", 0, NULL, DESYNC_TEXT, DESYNC_LONGTEXT, VLC_TRUE );
add_string("audio-filter",0,NULL,AUDIO_FILTER_TEXT,
AUDIO_FILTER_LONGTEXT,VLC_FALSE);
+ add_module( "audio-channel-mixer", "audio filter", NULL, NULL,
+ AUDIO_CHANNEL_MIXER, AUDIO_CHANNEL_MIXER_LONGTEXT,
+ VLC_FALSE );
/* Video options */
add_category_hint( N_("Video"), VOUT_CAT_LONGTEXT , VLC_FALSE );