Mercurial > audlegacy
annotate src/audtool/handlers_equalizer.c @ 4872:9501ad351ac0
When deleting last playlist, set title to "Untitled Playlist", as for a new one.
author | John Lindgren <john.lindgren@tds.net> |
---|---|
date | Sun, 26 Apr 2009 04:34:53 -0400 |
parents | 8a7752f1c662 |
children |
rev | line source |
---|---|
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 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
67 audtool_whine_args(argv[0], "<band>"); |
4074 | 68 exit(1); |
69 } | |
70 | |
71 band = atoi(argv[1]); | |
72 | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
73 /* FIXME, XXX, TODO: we should have a function for requesting |
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
74 * the actual number of bands, if we support dynamic amount some day ... |
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
75 * -- ccr |
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
76 */ |
4074 | 77 if (band < 0 || band > 9) |
78 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
79 audtool_whine("band number out of range\n"); |
4074 | 80 exit(1); |
81 } | |
82 | |
83 audtool_report("band %d = %.2f", band, audacious_remote_get_eq_band(dbus_proxy, band)); | |
84 | |
85 } | |
86 | |
87 void equalizer_set_eq(gint argc, gchar **argv) | |
88 { | |
89 gdouble preamp; | |
90 GArray *bands = g_array_sized_new(FALSE, FALSE, sizeof(gdouble), 10); | |
91 int i; | |
92 | |
93 if (argc < 12) | |
94 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
95 audtool_whine_args(argv[0], "<preamp> <band0> <band1> <band2> <band3> <band4> <band5> <band6> <band7> <band8> <band9>"); |
4074 | 96 exit(1); |
97 } | |
98 | |
99 preamp = atof(argv[1]); | |
100 | |
101 for(i=0; i<10; i++){ | |
102 gdouble val = atof(argv[i+2]); | |
103 g_array_append_val(bands, val); | |
104 } | |
105 | |
106 audacious_remote_set_eq(dbus_proxy, preamp, bands); | |
107 } | |
108 | |
109 void equalizer_set_eq_preamp(gint argc, gchar **argv) | |
110 { | |
111 gdouble preamp; | |
112 | |
113 if (argc < 2) | |
114 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
115 audtool_whine_args(argv[0], "<preamp>"); |
4074 | 116 exit(1); |
117 } | |
118 | |
119 preamp = atof(argv[1]); | |
120 | |
121 audacious_remote_set_eq_preamp(dbus_proxy, preamp); | |
122 } | |
123 | |
124 void equalizer_set_eq_band(gint argc, gchar **argv) | |
125 { | |
126 int band; | |
127 gdouble preamp; | |
128 | |
129 if (argc < 3) | |
130 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
131 audtool_whine_args(argv[0], "<band> <value>"); |
4074 | 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 { | |
4611
895297e46ee3
Cure some 'repetitive code syndromes' from audtool.
Matti Hamalainen <ccr@tnsp.org>
parents:
4074
diff
changeset
|
145 audtool_whine_args(argv[0], "<on/off>"); |
4074 | 146 exit(1); |
147 } | |
148 | |
149 if (!g_ascii_strcasecmp(argv[1], "on")) { | |
150 audacious_remote_eq_activate(dbus_proxy, TRUE); | |
151 } | |
152 else if (!g_ascii_strcasecmp(argv[1], "off")) { | |
153 audacious_remote_eq_activate(dbus_proxy, FALSE); | |
154 } | |
155 } |