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