]> git.sesse.net Git - vlc/blobdiff - modules/audio_filter/channel_mixer/headphone.c
Allow on the fly change of equalizer config. Only restart aout when enabling/disablin...
[vlc] / modules / audio_filter / channel_mixer / headphone.c
index ee7c3a40721ba4ff531803f5b2fe5b895e3114e4..911be1aa7f746824d8f069b7770523fe15e700d4 100644 (file)
@@ -3,7 +3,7 @@
  *               -> gives the feeling of a real room with a simple headphone
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: headphone.c,v 1.1 2002/12/09 00:52:42 babal Exp $
+ * $Id$
  *
  * Authors: Boris Dorès <babal@via.ecp.fr>
  *
@@ -45,8 +45,25 @@ static void DoWork    ( aout_instance_t *, aout_filter_t *, aout_buffer_t *,
 /*****************************************************************************
  * 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();
-    set_description( _("headphone channel mixer with virtual spatialization effect") );
+    set_description( N_("headphone channel mixer with virtual spatialization effect") );
+
+    add_integer( "headphone-dim", 10, NULL, HEADPHONE_DIM_TEXT,
+                 HEADPHONE_DIM_LONGTEXT, VLC_FALSE );
+
     set_capability( "audio filter", 0 );
     set_callbacks( Create, Destroy );
     add_shortcut( "headphone" );
@@ -209,6 +226,14 @@ static int Init ( aout_filter_t * p_filter , struct aout_filter_sys_t * p_data
         i_next_atomic_operation += 2;
         i_source_channel_offset++;
     }
+    if ( i_physical_channels & AOUT_CHAN_REARCENTER )
+    {
+        ComputeChannelOperations ( p_data , i_rate
+                , i_next_atomic_operation , i_source_channel_offset
+                , 0 , -d_z , 1.5 / i_nb_channels );
+        i_next_atomic_operation += 2;
+        i_source_channel_offset++;
+    }
     if ( i_physical_channels & AOUT_CHAN_CENTER )
     {
         ComputeChannelOperations ( p_data , i_rate
@@ -225,6 +250,22 @@ static int Init ( aout_filter_t * p_filter , struct aout_filter_sys_t * p_data
         i_next_atomic_operation += 2;
         i_source_channel_offset++;
     }
+    if ( i_physical_channels & AOUT_CHAN_MIDDLELEFT )
+    {
+        ComputeChannelOperations ( p_data , i_rate
+                , i_next_atomic_operation , i_source_channel_offset
+                , -d_x , 0 , 1.5 / i_nb_channels );
+        i_next_atomic_operation += 2;
+        i_source_channel_offset++;
+    }
+    if ( i_physical_channels & AOUT_CHAN_MIDDLERIGHT )
+    {
+        ComputeChannelOperations ( p_data , i_rate
+                , i_next_atomic_operation , i_source_channel_offset
+                , d_x , 0 , 1.5 / i_nb_channels );
+        i_next_atomic_operation += 2;
+        i_source_channel_offset++;
+    }
 
     /* Initialize the overflow buffer
      * we need it because the process induce a delay in the samples */
@@ -265,6 +306,7 @@ static int Create( vlc_object_t *p_this )
           || (p_filter->input.i_format != VLC_FOURCC('f','l','3','2')
                && p_filter->input.i_format != VLC_FOURCC('f','i','3','2')) )
     {
+        msg_Dbg( p_filter, "Filter discarded (invalid format)" );
         return -1;
     }