Mercurial > mplayer.hg
annotate libao2/pl_extrastereo.c @ 7484:32c7ca9359b1
help*.h files moved to help/ subdir
author | arpi |
---|---|
date | Sun, 22 Sep 2002 16:31:21 +0000 |
parents | 776b686069af |
children | 66f3204117d6 |
rev | line source |
---|---|
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
1 /* Extrastereo effect plugin |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
2 * (linearly increases difference between L&R channels) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
3 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
4 * Current limitations: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
5 * - only AFMT_S16_LE is supported currently |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
6 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
7 * License: GPLv2 (as a mix of pl_volume.c and |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
8 * xmms:stereo_plugin/stereo.c) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
9 * |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
10 * Author: pl <p_l@gmx.fr> (c) 2002 and beyond... |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
11 * */ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
12 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
13 #define PLUGIN |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
14 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
15 #include <stdio.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
16 #include <stdlib.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
17 #include <inttypes.h> |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
18 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
19 #include "audio_out.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
20 #include "audio_plugin.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
21 #include "audio_plugin_internal.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
22 #include "afmt.h" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
23 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
24 static ao_info_t info = { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
25 "Extra stereo plugin", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
26 "extrastereo", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
27 "pl <p_l@gmx.fr>", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
28 "" |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
29 }; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
30 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
31 LIBAO_PLUGIN_EXTERN(extrastereo) |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
32 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
33 // local data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
34 static struct { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
35 float mul; // intensity |
6795 | 36 int inuse; // This plugin is in use TRUE, FALSE |
37 int format; // sample format | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
38 } pl_extrastereo = {2.5, 0, 0}; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
39 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
40 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
41 // to set/get/query special features/parameters |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
42 static int control(int cmd,int arg){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
43 switch(cmd){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
44 case AOCONTROL_PLUGIN_SET_LEN: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
45 return CONTROL_OK; |
6795 | 46 case AOCONTROL_PLUGIN_ES_SET: |
47 pl_extrastereo.mul=*((float*)arg); | |
48 return CONTROL_OK; | |
49 case AOCONTROL_PLUGIN_ES_GET: | |
50 *((float*)arg)=pl_extrastereo.mul; | |
51 return CONTROL_OK; | |
4927
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
52 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
53 return CONTROL_UNKNOWN; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
54 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
55 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
56 // open & setup audio device |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
57 // return: 1=success 0=fail |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
58 static int init(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
59 switch(ao_plugin_data.format){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
60 case(AFMT_S16_LE): |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
61 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
62 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
63 fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n"); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
64 return 0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
65 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
66 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
67 pl_extrastereo.mul=ao_plugin_cfg.pl_extrastereo_mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
68 pl_extrastereo.format=ao_plugin_data.format; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
69 pl_extrastereo.inuse=1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
70 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
71 printf("[pl_extrastereo] Extra stereo plugin in use (multiplier=%2.2f).\n", |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
72 pl_extrastereo.mul); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
73 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
74 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
75 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
76 // close plugin |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
77 static void uninit(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
78 pl_extrastereo.inuse=0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
79 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
80 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
81 // empty buffers |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
82 static void reset(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
83 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
84 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
85 // processes 'ao_plugin_data.len' bytes of 'data' |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
86 // called for every block of data |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
87 static int play(){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
88 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
89 switch(pl_extrastereo.format){ |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
90 case(AFMT_S16_LE): { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
91 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
92 int16_t* data=(int16_t*)ao_plugin_data.data; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
93 int len=ao_plugin_data.len / 2; // 16 bits samples |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
94 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
95 float mul = pl_extrastereo.mul; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
96 int32_t i, avg, ltmp, rtmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
97 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
98 for (i=0; i < len ; i += 2) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
99 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
100 avg = (data[i] + data[i + 1]) / 2; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
101 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
102 ltmp = avg + (int) (mul * (data[i] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
103 rtmp = avg + (int) (mul * (data[i + 1] - avg)); |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
104 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
105 if (ltmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
106 ltmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
107 } else if (ltmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
108 ltmp = 32767; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
109 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
110 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
111 if (rtmp < -32768) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
112 rtmp = -32768; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
113 } else if (rtmp > 32767) { |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
114 rtmp = 32767; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
115 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
116 |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
117 data[i] = ltmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
118 data[i + 1] = rtmp; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
119 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
120 break; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
121 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
122 default: |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
123 return 0; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
124 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
125 return 1; |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
126 } |
3022570ad7d4
Extrastereo plugin: increases linearly the difference between left and right
pl
parents:
diff
changeset
|
127 |