4074
|
1 /*
|
|
2 * Audtool2
|
|
3 * Copyright (c) 2007 Audacious development team
|
|
4 *
|
|
5 * Redistribution and use in source and binary forms, with or without
|
|
6 * modification, are permitted provided that the following conditions are
|
|
7 * met:
|
|
8 *
|
|
9 * 1. Redistributions of source code must retain the above copyright notice,
|
|
10 * this list of conditions and the following disclaimer.
|
|
11 *
|
|
12 * 2. Redistributions in binary form must reproduce the above copyright
|
|
13 * notice, this list of conditions and the following disclaimer in the
|
|
14 * documentation and/or other materials provided with the distribution.
|
|
15 *
|
|
16 * 3. The name of the author may not be used to endorse or promote products
|
|
17 * derived from this software without specific prior written permission.
|
|
18 *
|
|
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
|
23 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
27 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
28 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
29 * POSSIBILITY OF SUCH DAMAGE.
|
|
30 */
|
|
31
|
|
32 #include <stdlib.h>
|
|
33 #include <string.h>
|
|
34 #include <glib.h>
|
|
35 #include <mowgli.h>
|
|
36 #include <locale.h>
|
|
37 #include "libaudclient/audctrl.h"
|
|
38 #include "audtool.h"
|
|
39
|
|
40 void equalizer_get_eq(gint argc, gchar **argv)
|
|
41 {
|
|
42 double preamp;
|
|
43 GArray *bands;
|
|
44 int i;
|
|
45
|
|
46 audacious_remote_get_eq(dbus_proxy, &preamp, &bands);
|
|
47
|
|
48 audtool_report("preamp = %.2f", preamp);
|
|
49 for(i=0; i<10; i++){
|
|
50 printf("%.2f ", g_array_index(bands, gdouble, i));
|
|
51 }
|
|
52 printf("\n");
|
|
53 g_array_free(bands, TRUE);
|
|
54 }
|
|
55
|
|
56 void equalizer_get_eq_preamp(gint argc, gchar **argv)
|
|
57 {
|
|
58 audtool_report("preamp = %.2f", audacious_remote_get_eq_preamp(dbus_proxy));
|
|
59 }
|
|
60
|
|
61 void equalizer_get_eq_band(gint argc, gchar **argv)
|
|
62 {
|
|
63 int band;
|
|
64
|
|
65 if (argc < 2)
|
|
66 {
|
|
67 audtool_whine("invalid parameters for %s.", argv[0]);
|
|
68 audtool_whine("syntax: %s <band>", argv[0]);
|
|
69 exit(1);
|
|
70 }
|
|
71
|
|
72 band = atoi(argv[1]);
|
|
73
|
|
74 if (band < 0 || band > 9)
|
|
75 {
|
|
76 audtool_whine("band number out of range");
|
|
77 exit(1);
|
|
78 }
|
|
79
|
|
80 audtool_report("band %d = %.2f", band, audacious_remote_get_eq_band(dbus_proxy, band));
|
|
81
|
|
82 }
|
|
83
|
|
84 void equalizer_set_eq(gint argc, gchar **argv)
|
|
85 {
|
|
86 gdouble preamp;
|
|
87 GArray *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10);
|
|
88 int i;
|
|
89
|
|
90 if (argc < 12)
|
|
91 {
|
|
92 audtool_whine("invalid parameters for %s.", argv[0]);
|
|
93 audtool_whine("syntax: %s <preamp> <band0> <band1> <band2> <band3> <band4> <band5> <band6> <band7> <band8> <band9>", argv[0]);
|
|
94 exit(1);
|
|
95 }
|
|
96
|
|
97 preamp = atof(argv[1]);
|
|
98
|
|
99 for(i=0; i<10; i++){
|
|
100 gdouble val = atof(argv[i+2]);
|
|
101 g_array_append_val(bands, val);
|
|
102 }
|
|
103
|
|
104 audacious_remote_set_eq(dbus_proxy, preamp, bands);
|
|
105 }
|
|
106
|
|
107 void equalizer_set_eq_preamp(gint argc, gchar **argv)
|
|
108 {
|
|
109 gdouble preamp;
|
|
110
|
|
111 if (argc < 2)
|
|
112 {
|
|
113 audtool_whine("invalid parameters for %s.", argv[0]);
|
|
114 audtool_whine("syntax: %s <preamp>", argv[0]);
|
|
115 exit(1);
|
|
116 }
|
|
117
|
|
118 preamp = atof(argv[1]);
|
|
119
|
|
120 audacious_remote_set_eq_preamp(dbus_proxy, preamp);
|
|
121 }
|
|
122
|
|
123 void equalizer_set_eq_band(gint argc, gchar **argv)
|
|
124 {
|
|
125 int band;
|
|
126 gdouble preamp;
|
|
127
|
|
128 if (argc < 3)
|
|
129 {
|
|
130 audtool_whine("invalid parameters for %s.", argv[0]);
|
|
131 audtool_whine("syntax: %s <band> <value>", argv[0]);
|
|
132 exit(1);
|
|
133 }
|
|
134
|
|
135 band = atoi(argv[1]);
|
|
136 preamp = atof(argv[2]);
|
|
137
|
|
138 audacious_remote_set_eq_band(dbus_proxy, band, preamp);
|
|
139 }
|
|
140
|
|
141 void equalizer_active(gint argc, gchar **argv)
|
|
142 {
|
|
143 if (argc < 2)
|
|
144 {
|
|
145 audtool_whine("invalid parameters for %s.", argv[0]);
|
|
146 audtool_whine("syntax: %s <on/off>", argv[0]);
|
|
147 exit(1);
|
|
148 }
|
|
149
|
|
150 if (!g_ascii_strcasecmp(argv[1], "on")) {
|
|
151 audacious_remote_eq_activate(dbus_proxy, TRUE);
|
|
152 return;
|
|
153 }
|
|
154 else if (!g_ascii_strcasecmp(argv[1], "off")) {
|
|
155 audacious_remote_eq_activate(dbus_proxy, FALSE);
|
|
156 return;
|
|
157 }
|
|
158 }
|