summaryrefslogtreecommitdiffstats
path: root/libao2
diff options
context:
space:
mode:
authorpl <pl@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-03 14:17:53 +0000
committerpl <pl@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-03-03 14:17:53 +0000
commitfd28ff2c130b9555be4e8e87aed3b29c313647d1 (patch)
tree10cec7c8ecd755d6c24b127591d2cd1d905f0c91 /libao2
parent9301c0157c28116d17f0a1cf58c7be5b04bea4b7 (diff)
downloadmpv-fd28ff2c130b9555be4e8e87aed3b29c313647d1.tar.bz2
mpv-fd28ff2c130b9555be4e8e87aed3b29c313647d1.tar.xz
Extrastereo plugin: increases linearly the difference between left and right
channels (as the XMMS extrastereo plugin) which has some of "live" effect (use it to hear what I mean) ex: mplayer media.avi -aop list=extrastereo[:mul=3.4] The default coefficient (mul) is a float number that defaults to 2.5. If you set it to 0.0, you will have a mono sound (average of both channels), if you set it to 1.0, you will have unchanged sound. A patch for DOCS/sound.html is about to be sent to Gabucino. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@4928 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libao2')
-rw-r--r--libao2/Makefile2
-rw-r--r--libao2/audio_plugin.h8
-rw-r--r--libao2/pl_extrastereo.c121
3 files changed, 128 insertions, 3 deletions
diff --git a/libao2/Makefile b/libao2/Makefile
index 96d730db63..1701e6dd73 100644
--- a/libao2/Makefile
+++ b/libao2/Makefile
@@ -4,7 +4,7 @@ include config.mak
LIBNAME = libao2.a
# TODO: moveout ao_sdl.c so it's only used when SDL is detected
-SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c $(OPTIONAL_SRCS)
+SRCS=afmt.c audio_out.c ao_mpegpes.c ao_null.c ao_pcm.c ao_plugin.c pl_delay.c pl_format.c pl_surround.c remez.c pl_resample.c pl_volume.c pl_extrastereo.c $(OPTIONAL_SRCS)
OBJS=$(SRCS:.c=.o)
diff --git a/libao2/audio_plugin.h b/libao2/audio_plugin.h
index 145b4e3e14..4ee8f1c145 100644
--- a/libao2/audio_plugin.h
+++ b/libao2/audio_plugin.h
@@ -36,6 +36,7 @@ typedef struct ao_plugin_cfg_s
int pl_delay_len; // Number of samples to delay sound output
int pl_resample_fout; // Output frequency from resampling
int pl_volume_volume; // Initial volume setting
+ float pl_extrastereo_mul; // Stereo enhancer multiplier
} ao_plugin_cfg_t;
extern ao_plugin_cfg_t ao_plugin_cfg;
@@ -46,19 +47,21 @@ extern ao_plugin_cfg_t ao_plugin_cfg;
AFMT_S16_LE, \
0, \
48000, \
- 255 \
+ 255, \
+ 2.5 \
};
// This block should not be available in the pl_xxxx files
// due to compilation issues
#ifndef PLUGIN
-#define NPL 5+1 // Number of PLugins ( +1 list ends with NULL )
+#define NPL 6+1 // Number of PLugins ( +1 list ends with NULL )
// List of plugins
extern ao_plugin_functions_t audio_plugin_delay;
extern ao_plugin_functions_t audio_plugin_format;
extern ao_plugin_functions_t audio_plugin_surround;
extern ao_plugin_functions_t audio_plugin_resample;
extern ao_plugin_functions_t audio_plugin_volume;
+extern ao_plugin_functions_t audio_plugin_extrastereo;
#define AO_PLUGINS { \
@@ -67,6 +70,7 @@ extern ao_plugin_functions_t audio_plugin_volume;
&audio_plugin_surround, \
&audio_plugin_resample, \
&audio_plugin_volume, \
+ &audio_plugin_extrastereo, \
NULL \
}
#endif /* PLUGIN */
diff --git a/libao2/pl_extrastereo.c b/libao2/pl_extrastereo.c
new file mode 100644
index 0000000000..da15e0ff41
--- /dev/null
+++ b/libao2/pl_extrastereo.c
@@ -0,0 +1,121 @@
+/* Extrastereo effect plugin
+ * (linearly increases difference between L&R channels)
+ *
+ * Current limitations:
+ * - only AFMT_S16_LE is supported currently
+ *
+ * License: GPLv2 (as a mix of pl_volume.c and
+ * xmms:stereo_plugin/stereo.c)
+ *
+ * Author: pl <p_l@gmx.fr> (c) 2002 and beyond...
+ * */
+
+#define PLUGIN
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <inttypes.h>
+
+#include "audio_out.h"
+#include "audio_plugin.h"
+#include "audio_plugin_internal.h"
+#include "afmt.h"
+
+static ao_info_t info = {
+ "Extra stereo plugin",
+ "extrastereo",
+ "pl <p_l@gmx.fr>",
+ ""
+};
+
+LIBAO_PLUGIN_EXTERN(extrastereo)
+
+// local data
+static struct {
+ float mul; // intensity
+ int inuse; // This plugin is in use TRUE, FALSE
+ int format; // sample format
+} pl_extrastereo = {2.5, 0, 0};
+
+
+// to set/get/query special features/parameters
+static int control(int cmd,int arg){
+ switch(cmd){
+ case AOCONTROL_PLUGIN_SET_LEN:
+ return CONTROL_OK;
+ }
+ return CONTROL_UNKNOWN;
+}
+
+// open & setup audio device
+// return: 1=success 0=fail
+static int init(){
+ switch(ao_plugin_data.format){
+ case(AFMT_S16_LE):
+ break;
+ default:
+ fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n");
+ return 0;
+ }
+
+ pl_extrastereo.mul=ao_plugin_cfg.pl_extrastereo_mul;
+ pl_extrastereo.format=ao_plugin_data.format;
+ pl_extrastereo.inuse=1;
+
+ printf("[pl_extrastereo] Extra stereo plugin in use (multiplier=%2.2f).\n",
+ pl_extrastereo.mul);
+ return 1;
+}
+
+// close plugin
+static void uninit(){
+ pl_extrastereo.inuse=0;
+}
+
+// empty buffers
+static void reset(){
+}
+
+// processes 'ao_plugin_data.len' bytes of 'data'
+// called for every block of data
+static int play(){
+
+ switch(pl_extrastereo.format){
+ case(AFMT_S16_LE): {
+
+ int16_t* data=(int16_t*)ao_plugin_data.data;
+ int len=ao_plugin_data.len / 2; // 16 bits samples
+
+ float mul = pl_extrastereo.mul;
+ int32_t i, avg, ltmp, rtmp;
+
+ for (i=0; i < len ; i += 2) {
+
+ avg = (data[i] + data[i + 1]) / 2;
+
+ ltmp = avg + (int) (mul * (data[i] - avg));
+ rtmp = avg + (int) (mul * (data[i + 1] - avg));
+
+ if (ltmp < -32768) {
+ ltmp = -32768;
+ } else if (ltmp > 32767) {
+ ltmp = 32767;
+ }
+
+ if (rtmp < -32768) {
+ rtmp = -32768;
+ } else if (rtmp > 32767) {
+ rtmp = 32767;
+ }
+
+ data[i] = ltmp;
+ data[i + 1] = rtmp;
+ }
+ break;
+ }
+ default:
+ return 0;
+ }
+ return 1;
+}
+