Mercurial > audlegacy-plugins
annotate src/sndstretch/sndstretch_xmms.c @ 2284:d19b53359b24
cleaned up the sndfile wav plugin, currently limiting it ONLY TO WAV
PLAYBACK. if somebody is more experienced with it and wants to restore
the other formats, go ahead (maybe change the name of the plugin too?).
author | mf0102 <0102@gmx.at> |
---|---|
date | Wed, 09 Jan 2008 15:41:22 +0100 |
parents | b8da6a0b0da2 |
children | 4d6045c20cc5 |
rev | line source |
---|---|
881 | 1 // sndstretch_xmms.c |
2 // | |
3 // sndstretch_xmms - xmms-output plugin for adjusting | |
4 // pitch and speed of s16le data | |
5 // Copyright (C) 2001 Florian Berger | |
6 // Email: florian.berger@jk.uni-linz.ac.at | |
7 // | |
8 // This program is free software; you can redistribute it and/or modify | |
9 // it under the terms of the GNU General Public License Version 2 as | |
10 // published by the Free Software Foundation; | |
11 // | |
12 // This program is distributed in the hope that it will be useful, | |
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 // GNU General Public License for more details. | |
16 // | |
17 // You should have received a copy of the GNU General Public License | |
18 // along with this program; if not, write to the Free Software | |
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | |
20 // | |
21 // | |
22 | |
23 #include "sndstretch.h" | |
24 #include "sndstretch_xmms-logo.xpm" | |
25 #include "FB_logo.xpm" | |
26 | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
27 #include "config.h" |
1950
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1642
diff
changeset
|
28 #include <audacious/configdb.h> |
2ebeb7816c5e
Change from "" to <>-style includes. With thanks to ccr for the correct sed voodoo.
chainsaw@localhost
parents:
1642
diff
changeset
|
29 #include <audacious/plugin.h> |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
30 #include <audacious/i18n.h> |
881 | 31 #include <gtk/gtk.h> |
32 #include <math.h> | |
33 #include <stdlib.h> | |
34 #include <stdio.h> | |
35 #include <string.h> | |
36 | |
37 #define SNDSTRETCH_VERSION_STRING "0.7" | |
38 | |
39 #define SS sndstretch_var | |
40 | |
41 void sndstretch_init (void); | |
42 void sndstretch_about (void); | |
43 void sndstretch_config (void); | |
44 int sndstretch_mod_samples (gpointer *ptr, gint length, AFormat fmt, gint srate, gint nch); | |
45 | |
46 EffectPlugin sndstretch_ep = { | |
1642 | 47 .description = "SndStretch", |
48 .init = sndstretch_init, | |
49 .about = sndstretch_about, | |
50 .configure = sndstretch_config, | |
51 .mod_samples = sndstretch_mod_samples, | |
881 | 52 }; |
53 | |
1071 | 54 EffectPlugin *sndstretch_eplist[] = { &sndstretch_ep, NULL }; |
881 | 55 |
1395
761e17b23e0c
added Discovery plugin type
Cristi Magherusan <majeru@atheme-project.org>
parents:
1369
diff
changeset
|
56 DECLARE_PLUGIN(sndstretch, NULL, NULL, NULL, NULL, sndstretch_eplist, NULL, NULL, NULL); |
881 | 57 |
58 static struct { | |
59 int handle; // file handle | |
60 int fragsize; | |
61 int chnr; | |
62 int paused; | |
63 int time_offs; | |
64 int fmtsize; | |
65 int fmt; | |
66 int sampfreq; | |
67 int written; | |
68 int bpsec; | |
69 int vol_l,vol_r; | |
70 int going; | |
71 double pitch; | |
72 double speed; | |
73 double scale; | |
74 int short_overlap; | |
75 int volume_corr; | |
76 GtkObject * pitch_adj; | |
77 GtkObject * speed_adj; | |
78 GtkObject * scale_adj; | |
79 } sndstretch_var; | |
80 | |
81 | |
82 static const char sndstretch_title_text[] = "SndStretch xmms - " SNDSTRETCH_VERSION_STRING; | |
83 | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
84 static const gchar sndstretch_about_text[] = |
881 | 85 "Copyright (C) 2001 Florian Berger\n<harpin_floh@yahoo.de>\n" |
86 "Ported to Audacious by Michael Färber\n" | |
87 "http://www.geocities.com/harpin_floh/home.html"; | |
88 | |
89 static const gchar sndstretch_GPL_text[] = | |
90 "This program is free software; you can redistribute it and/or modify " | |
91 "it under the terms of the GNU General Public License as published by " | |
92 "the Free Software Foundation; either version 2 of the License, or " | |
93 "(at your option) any later version.\n\n" | |
94 "This program is distributed in the hope that it will be useful, " | |
95 "but WITHOUT ANY WARRANTY; without even the implied warranty of " | |
96 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " | |
97 "GNU General Public License for more details.\n\n" | |
98 "You should have received a copy of the GNU General Public License " | |
99 "along with this program; if not, write to the Free Software " | |
100 "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, " | |
101 "USA."; | |
102 | |
103 GtkWidget * sndstretch_about_dialog = NULL; | |
104 GtkWidget * sndstretch_config_dialog = NULL; | |
105 | |
106 | |
107 static gint sndstretch_about_destroy_cb(GtkWidget * w, GdkEventAny * e, gpointer data) | |
108 { | |
109 gtk_widget_destroy(sndstretch_about_dialog); | |
110 sndstretch_about_dialog = NULL; | |
111 return TRUE; | |
112 } | |
113 | |
114 static void sndstretch_about_ok_cb(GtkButton * button, gpointer data) | |
115 { | |
116 gtk_widget_destroy(GTK_WIDGET(sndstretch_about_dialog)); | |
117 sndstretch_about_dialog = NULL; | |
118 } | |
119 | |
120 void sndstretch_about(void) | |
121 { | |
122 GtkWidget * vbox, * scrolltext, * button; | |
123 GtkWidget * titlelabel, * copylabel; | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
124 GtkWidget * text; |
881 | 125 GtkTextBuffer * textbuffer; |
126 GtkTextIter iter; | |
127 | |
128 GdkPixmap * logopix; | |
129 GdkBitmap * logomask; | |
130 GtkWidget * logo; | |
131 | |
132 GdkPixmap * FBlogopix; | |
133 GdkBitmap * FBlogomask; | |
134 GtkWidget * FBlogo; | |
135 GtkWidget * copyhbox, * copy_rbox, * copy_lbox; | |
136 | |
137 | |
138 if (sndstretch_about_dialog != NULL) | |
139 return; | |
140 | |
141 sndstretch_about_dialog = gtk_dialog_new(); | |
142 gtk_widget_show(sndstretch_about_dialog); | |
143 | |
144 /* title logo */ | |
145 logopix = gdk_pixmap_create_from_xpm_d(sndstretch_about_dialog->window, &logomask, | |
146 NULL, | |
147 (gchar **) sndstretch_xmms_logo_xpm); | |
148 logo = gtk_pixmap_new(logopix,logomask); | |
149 | |
150 /* FB-logo */ | |
151 FBlogopix = gdk_pixmap_create_from_xpm_d(sndstretch_about_dialog->window, &FBlogomask, | |
152 NULL, | |
153 (gchar **) FB_logo_xpm); | |
154 FBlogo = gtk_pixmap_new(FBlogopix,FBlogomask); | |
155 | |
156 | |
157 gtk_signal_connect(GTK_OBJECT(sndstretch_about_dialog), "destroy", | |
158 GTK_SIGNAL_FUNC(sndstretch_about_destroy_cb), NULL); | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
159 gtk_window_set_title(GTK_WINDOW(sndstretch_about_dialog), _("About SndStretch")); |
881 | 160 |
161 | |
162 /* labels */ | |
163 titlelabel = gtk_label_new(sndstretch_title_text); | |
164 copylabel = gtk_label_new(sndstretch_about_text); | |
165 gtk_label_set_justify(GTK_LABEL(copylabel), GTK_JUSTIFY_LEFT); | |
166 | |
167 copy_lbox = gtk_hbox_new(FALSE,0); | |
168 copy_rbox = gtk_hbox_new(FALSE,0); | |
169 gtk_box_pack_end (GTK_BOX(copy_lbox), FBlogo, FALSE, TRUE, 0); | |
170 gtk_box_pack_start(GTK_BOX(copy_rbox), copylabel, FALSE, TRUE, 0); | |
171 copyhbox = gtk_hbox_new(FALSE,0); | |
172 gtk_box_pack_start(GTK_BOX(copyhbox), copy_lbox, TRUE, TRUE, 5); | |
173 gtk_box_pack_start(GTK_BOX(copyhbox), copy_rbox, TRUE, TRUE, 5); | |
174 | |
175 vbox = gtk_vbox_new(FALSE, 5); | |
176 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(sndstretch_about_dialog)->vbox), vbox, | |
177 TRUE, TRUE, 5); | |
178 | |
179 scrolltext = gtk_scrolled_window_new(NULL,NULL); | |
180 text = gtk_text_view_new(); | |
181 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD); | |
182 gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE); | |
183 textbuffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(text)); | |
184 gtk_text_buffer_get_iter_at_offset(textbuffer, &iter, 0); | |
185 gtk_text_buffer_insert(textbuffer, &iter, | |
186 sndstretch_GPL_text, strlen(sndstretch_GPL_text)); | |
187 | |
188 | |
189 scrolltext = gtk_scrolled_window_new(NULL, NULL); | |
190 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolltext), | |
191 GTK_POLICY_AUTOMATIC, | |
192 GTK_POLICY_AUTOMATIC); | |
193 gtk_container_add(GTK_CONTAINER(scrolltext), text); | |
194 | |
195 gtk_box_pack_start(GTK_BOX(vbox), logo, FALSE, TRUE, 5); | |
196 gtk_box_pack_start(GTK_BOX(vbox), titlelabel, FALSE, TRUE, 5); | |
197 gtk_box_pack_start(GTK_BOX(vbox), copyhbox, FALSE, TRUE, 5); | |
198 gtk_box_pack_start(GTK_BOX(vbox), scrolltext, TRUE, TRUE, 5); | |
199 gtk_container_set_border_width(GTK_CONTAINER(vbox), 8); | |
200 gtk_widget_set_usize(scrolltext, -1, 110); | |
201 | |
202 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); | |
203 gtk_box_pack_start(GTK_BOX(GTK_DIALOG(sndstretch_about_dialog)->action_area), | |
204 button, FALSE, FALSE, 0); | |
205 gtk_signal_connect(GTK_OBJECT(button), "clicked", | |
206 GTK_SIGNAL_FUNC(sndstretch_about_ok_cb), NULL); | |
207 GTK_WIDGET_SET_FLAGS(button, GTK_CAN_DEFAULT); | |
208 gtk_widget_grab_default(button); | |
209 gtk_widget_show(button); | |
210 gtk_widget_show_all(sndstretch_about_dialog); | |
211 } | |
212 | |
213 | |
214 | |
215 static void speed_change_cb(GtkAdjustment * adj, gpointer data) | |
216 { | |
217 SS.speed = pow(2.0, GTK_ADJUSTMENT(adj)->value / (GTK_ADJUSTMENT(adj)->upper-10)); | |
218 } | |
219 | |
220 static void pitch_change_cb(GtkAdjustment * adj, gpointer data) | |
221 { | |
222 SS.pitch = pow(2.0, GTK_ADJUSTMENT(adj)->value / (GTK_ADJUSTMENT(adj)->upper-10)); | |
223 gtk_adjustment_set_value(GTK_ADJUSTMENT(SS.scale_adj), | |
224 (GTK_ADJUSTMENT(SS.scale_adj)->upper-10.0)*log(SS.pitch)/log(2.0)); | |
225 } | |
226 | |
227 static void scale_change_cb(GtkAdjustment * adj, gpointer data) | |
228 { | |
229 double speed_eff; | |
230 | |
231 SS.scale = pow(2.0, GTK_ADJUSTMENT(adj)->value / (GTK_ADJUSTMENT(adj)->upper-10)); | |
232 speed_eff= SS.speed/SS.pitch; | |
233 SS.pitch = SS.scale; | |
234 SS.speed = speed_eff*SS.scale; | |
235 if (SS.speed>2.0) SS.speed=2.0; | |
236 if (SS.speed<0.5) SS.speed=0.5; | |
237 gtk_adjustment_set_value(GTK_ADJUSTMENT(SS.speed_adj), | |
238 (GTK_ADJUSTMENT(SS.speed_adj)->upper-10.0)*log(SS.speed)/log(2.0)); | |
239 gtk_adjustment_set_value(GTK_ADJUSTMENT(SS.pitch_adj), | |
240 (GTK_ADJUSTMENT(SS.pitch_adj)->upper-10.0)*log(SS.pitch)/log(2.0)); | |
241 } | |
242 | |
243 static void overlap_toggle_cb(GtkToggleButton *butt, gpointer user_data) | |
244 { | |
245 SS.short_overlap = gtk_toggle_button_get_active(butt); | |
246 } | |
247 | |
248 static void volume_toggle_cb(GtkToggleButton *butt, gpointer user_data) | |
249 { | |
250 SS.volume_corr = gtk_toggle_button_get_active(butt); | |
251 } | |
252 | |
253 static void sndstretch_config_logobutton_cb(GtkButton * button, gpointer data) | |
254 { | |
255 sndstretch_about(); | |
256 } | |
257 | |
258 static gint sndstretch_config_destroy_cb(GtkWidget * w, GdkEventAny * e, gpointer data) | |
259 { | |
2124 | 260 ConfigDb *db = aud_cfg_db_open(); |
881 | 261 |
2124 | 262 aud_cfg_db_set_double(db, "sndstretch", "pitch", SS.pitch); |
263 aud_cfg_db_set_double(db, "sndstretch", "speed", SS.speed); | |
881 | 264 |
2124 | 265 aud_cfg_db_set_bool(db, "sndstretch", "short_overlap", SS.short_overlap); |
266 aud_cfg_db_set_bool(db, "sndstretch", "volume_corr", SS.volume_corr); | |
881 | 267 |
2124 | 268 aud_cfg_db_close(db); |
881 | 269 |
270 gtk_widget_destroy(sndstretch_config_dialog); | |
271 sndstretch_config_dialog = NULL; | |
272 return TRUE; | |
273 } | |
274 | |
275 void sndstretch_config(void) | |
276 { | |
277 GtkWidget * vbox; | |
278 GtkWidget * speed_scale, * pitch_scale, * scale_scale; | |
279 GtkWidget * speed_spin, * pitch_spin, * scale_spin; | |
280 GtkWidget * speed_hbox, * pitch_hbox, * scale_hbox, * opt_hbox; | |
281 GtkWidget * speed_frame, * pitch_frame, * scale_frame, * opt_frame; | |
282 GdkPixmap * logopix; | |
283 GdkBitmap * logomask; | |
284 GtkWidget * logo; | |
285 GtkWidget * logohbox; | |
286 GtkWidget * logobutton; | |
287 GtkWidget * volume_toggle; | |
288 GtkWidget * overlap_toggle; | |
289 | |
290 if (sndstretch_config_dialog != NULL) | |
291 return; | |
292 | |
293 sndstretch_config_dialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
294 gtk_widget_show(sndstretch_config_dialog); | |
295 | |
296 logopix = gdk_pixmap_create_from_xpm_d(sndstretch_config_dialog->window, &logomask, | |
297 NULL, (gchar **)sndstretch_xmms_logo_xpm); | |
298 | |
299 logo = gtk_pixmap_new(logopix,logomask); | |
300 | |
301 logobutton = gtk_button_new(); | |
302 gtk_button_set_relief(GTK_BUTTON(logobutton), GTK_RELIEF_NONE); | |
303 gtk_container_add(GTK_CONTAINER(logobutton), logo); | |
304 gtk_signal_connect(GTK_OBJECT(logobutton), "clicked", | |
305 GTK_SIGNAL_FUNC(sndstretch_config_logobutton_cb), NULL); | |
306 GTK_WIDGET_SET_FLAGS(logobutton, GTK_CAN_DEFAULT); | |
307 gtk_widget_grab_default(logobutton); | |
308 | |
309 logohbox = gtk_hbox_new(FALSE,0); // to make it rightbound | |
310 gtk_box_pack_end(GTK_BOX(logohbox), logobutton, FALSE, TRUE, 4); | |
311 | |
312 SS.speed_adj = gtk_adjustment_new( 100.0*log(SS.speed)/log(2.0), | |
313 -100, 100+10, 2, 10, 10); | |
314 SS.pitch_adj = gtk_adjustment_new( 120.0*log(SS.pitch)/log(2.0), | |
315 -120, 120+10, 2, 10, 10); | |
316 SS.scale_adj = gtk_adjustment_new( 100.0*log(SS.scale)/log(2.0), | |
317 -100, 100+10, 2, 10, 10); | |
318 | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
319 volume_toggle = gtk_check_button_new_with_label(_("Volume corr.")); |
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
320 overlap_toggle = gtk_check_button_new_with_label(_("Short Overlap")); |
881 | 321 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(volume_toggle), SS.volume_corr ); |
322 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(overlap_toggle), SS.short_overlap ); | |
323 | |
324 | |
325 gtk_signal_connect(GTK_OBJECT(SS.speed_adj), "value-changed", | |
326 GTK_SIGNAL_FUNC(speed_change_cb), NULL); | |
327 | |
328 gtk_signal_connect(GTK_OBJECT(SS.pitch_adj), "value-changed", | |
329 GTK_SIGNAL_FUNC(pitch_change_cb), NULL); | |
330 | |
331 gtk_signal_connect(GTK_OBJECT(SS.scale_adj), "value-changed", | |
332 GTK_SIGNAL_FUNC(scale_change_cb), NULL); | |
333 | |
334 gtk_signal_connect(GTK_OBJECT(volume_toggle), "toggled", | |
335 GTK_SIGNAL_FUNC(volume_toggle_cb), NULL); | |
336 | |
337 gtk_signal_connect(GTK_OBJECT(overlap_toggle), "toggled", | |
338 GTK_SIGNAL_FUNC(overlap_toggle_cb), NULL); | |
339 | |
340 speed_scale = gtk_hscale_new(GTK_ADJUSTMENT(SS.speed_adj)); | |
341 pitch_scale = gtk_hscale_new(GTK_ADJUSTMENT(SS.pitch_adj)); | |
342 scale_scale = gtk_hscale_new(GTK_ADJUSTMENT(SS.scale_adj)); | |
343 gtk_scale_set_draw_value (GTK_SCALE(speed_scale),FALSE); | |
344 gtk_scale_set_draw_value (GTK_SCALE(pitch_scale),FALSE); | |
345 gtk_scale_set_draw_value (GTK_SCALE(scale_scale),FALSE); | |
346 | |
347 speed_spin = gtk_spin_button_new(GTK_ADJUSTMENT(SS.speed_adj),1.0,2); | |
348 pitch_spin = gtk_spin_button_new(GTK_ADJUSTMENT(SS.pitch_adj),1.0,2); | |
349 scale_spin = gtk_spin_button_new(GTK_ADJUSTMENT(SS.scale_adj),1.0,2); | |
350 gtk_widget_set_usize (speed_spin,70,20); | |
351 gtk_widget_set_usize (pitch_spin,70,20); | |
352 gtk_widget_set_usize (scale_spin,70,20); | |
353 gtk_entry_set_max_length (GTK_ENTRY(pitch_spin),7); | |
354 gtk_entry_set_max_length (GTK_ENTRY(speed_spin),7); | |
355 gtk_entry_set_max_length (GTK_ENTRY(scale_spin),7); | |
356 | |
357 speed_hbox = gtk_hbox_new(FALSE,5); | |
358 pitch_hbox = gtk_hbox_new(FALSE,5); | |
359 scale_hbox = gtk_hbox_new(FALSE,5); | |
360 opt_hbox = gtk_hbox_new(FALSE,5); | |
361 gtk_container_set_border_width(GTK_CONTAINER(speed_hbox), 3); | |
362 gtk_container_set_border_width(GTK_CONTAINER(pitch_hbox), 3); | |
363 gtk_container_set_border_width(GTK_CONTAINER(scale_hbox), 3); | |
364 gtk_container_set_border_width(GTK_CONTAINER(opt_hbox), 3); | |
365 gtk_box_pack_start(GTK_BOX(speed_hbox), speed_spin, FALSE, TRUE, 5); | |
366 gtk_box_pack_start(GTK_BOX(speed_hbox), speed_scale, TRUE, TRUE, 5); | |
367 gtk_box_pack_start(GTK_BOX(pitch_hbox), pitch_spin, FALSE, TRUE, 5); | |
368 gtk_box_pack_start(GTK_BOX(pitch_hbox), pitch_scale, TRUE, TRUE, 5); | |
369 gtk_box_pack_start(GTK_BOX(scale_hbox), scale_spin, FALSE, TRUE, 5); | |
370 gtk_box_pack_start(GTK_BOX(scale_hbox), scale_scale, TRUE, TRUE, 5); | |
371 gtk_box_pack_start(GTK_BOX(opt_hbox), volume_toggle, FALSE, TRUE, 5); | |
372 gtk_box_pack_start(GTK_BOX(opt_hbox), overlap_toggle,TRUE, TRUE, 5); | |
373 | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
374 speed_frame = gtk_frame_new(_("Speed")); |
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
375 pitch_frame = gtk_frame_new(_("Pitch")); |
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
376 scale_frame = gtk_frame_new(_("Scale")); |
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
377 opt_frame = gtk_frame_new(_("Options")); |
881 | 378 gtk_container_add(GTK_CONTAINER(speed_frame), speed_hbox); |
379 gtk_container_add(GTK_CONTAINER(pitch_frame), pitch_hbox); | |
380 gtk_container_add(GTK_CONTAINER(scale_frame), scale_hbox); | |
381 gtk_container_add(GTK_CONTAINER(opt_frame), opt_hbox); | |
382 gtk_container_set_border_width(GTK_CONTAINER(speed_frame), 5); | |
383 gtk_container_set_border_width(GTK_CONTAINER(pitch_frame), 5); | |
384 gtk_container_set_border_width(GTK_CONTAINER(scale_frame), 5); | |
385 gtk_container_set_border_width(GTK_CONTAINER(opt_frame), 5); | |
386 | |
387 vbox=gtk_vbox_new(FALSE,0); | |
388 gtk_box_pack_start(GTK_BOX(vbox), pitch_frame, FALSE, TRUE, 0); | |
389 gtk_box_pack_start(GTK_BOX(vbox), speed_frame, FALSE, TRUE, 0); | |
390 gtk_box_pack_start(GTK_BOX(vbox), scale_frame, FALSE, TRUE, 0); | |
391 gtk_box_pack_start(GTK_BOX(vbox), opt_frame, FALSE, TRUE, 0); | |
392 gtk_box_pack_start(GTK_BOX(vbox), logohbox, FALSE, TRUE, 0); | |
393 | |
394 gtk_signal_connect(GTK_OBJECT(sndstretch_config_dialog), "destroy", | |
395 GTK_SIGNAL_FUNC(sndstretch_config_destroy_cb), NULL); | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
396 gtk_window_set_title(GTK_WINDOW(sndstretch_config_dialog), _("SndStretch - Configuration")); |
881 | 397 gtk_container_add(GTK_CONTAINER(sndstretch_config_dialog), vbox); |
398 | |
1369
6d87598ff8a9
Internationalization... (The first step of the "i18n" project could be ready for Audacious 1.4 release)
Stany HENRY <StrassBoy@gmail.com>
parents:
1071
diff
changeset
|
399 gtk_widget_set_usize(sndstretch_config_dialog, -1, -1); |
881 | 400 gtk_widget_show_all(sndstretch_config_dialog); |
401 } | |
402 | |
403 | |
404 void sndstretch_init(void) | |
405 { | |
406 ConfigDb *db; | |
407 | |
2124 | 408 db = aud_cfg_db_open(); |
881 | 409 |
410 SS.fragsize=0; | |
411 SS.chnr=2; | |
412 SS.paused=0; | |
413 SS.time_offs=0; | |
414 SS.fmtsize=2; | |
415 SS.fmt=FMT_S16_NE; | |
416 SS.sampfreq=44100; | |
417 SS.written=0; | |
418 SS.bpsec=176400; | |
419 SS.vol_r=50; | |
420 SS.vol_l=50; | |
421 SS.pitch=1.0; | |
422 SS.speed=1.0; | |
423 SS.scale=1.0; | |
424 | |
425 gboolean b; | |
2124 | 426 aud_cfg_db_get_double(db, "sndstretch", "pitch", &SS.pitch); |
427 aud_cfg_db_get_double(db, "sndstretch", "speed", &SS.speed); | |
428 if (aud_cfg_db_get_bool(db, "sndstretch", "short_overlap", &b)) | |
881 | 429 SS.short_overlap = b; |
2124 | 430 if (aud_cfg_db_get_bool(db, "sndstretch", "volume_corr", &b)) |
881 | 431 SS.volume_corr = b; |
2124 | 432 aud_cfg_db_close(db); |
881 | 433 } |
434 | |
435 int sndstretch_mod_samples (gpointer *ptr, gint length, AFormat fmt, gint srate, gint nch) | |
436 { | |
437 static short int * buff_o; | |
438 static int prod_size; | |
439 static PitchSpeedJob job; | |
440 static int init_job=1; | |
441 | |
442 buff_o = realloc(buff_o, 65536); | |
443 | |
444 if (init_job) { | |
445 InitPitchSpeedJob(&job); | |
446 init_job = 0; | |
447 } | |
448 snd_pitch_speed_job(*ptr, nch, length/2, 0, SS.pitch, SS.speed, | |
449 (SS.short_overlap) ? 882 : 1764, | |
450 buff_o, &prod_size, &job, SS.volume_corr); | |
451 | |
452 *ptr = (gpointer) buff_o; | |
453 | |
454 return prod_size*2; | |
455 } |