More work
[klaudia.git] / patches / fst_1.8+git20091228.diff
blob979962563d9a03e2a94de474bd2f9af0369367b4
1 diff -U 3 -H -d -r -N -- fst.orig/Makefile fst-1.8+git20091228/Makefile
2 --- fst.orig/Makefile 2009-12-28 15:07:55.000000000 +0000
3 +++ fst-1.8+git20091228/Makefile 2010-06-12 15:00:50.000000000 +0100
4 @@ -6,24 +6,16 @@
5 DLLS =
6 EXES = fst
8 -LASH_EXISTS := $(shell if pkg-config --exists lash-1.0; then echo yes; else echo no; fi)
10 ### Common settings
12 PKG_CONFIG_MODULES := glib-2.0
13 PKG_CONFIG_MODULES += gtk+-2.0
14 PKG_CONFIG_MODULES += jack
15 -ifeq ($(LASH_EXISTS),yes)
16 -PKG_CONFIG_MODULES += lash-1.0
17 -endif
19 CEXTRA := $(shell pkg-config --cflags $(PKG_CONFIG_MODULES)) -fPIC -m32 -g
20 -ifneq (,$(findstring lash-1.0,$(PKG_CONFIG_MODULES)))
21 -CEXTRA += -DHAVE_LASH
22 -endif
23 CXXEXTRA = -mno-cygwin
24 RCEXTRA =
25 -INCLUDE_PATH = -I. -I/usr/include -I/usr/include -I/usr/include/wine -I/usr/include/wine/windows -I/usr/local/include/wine -I/usr/local/include/wine/windows
26 +INCLUDE_PATH = -I. -I/usr/include -I/usr/include -I/usr/include/wine -I/usr/include/wine/windows -I/usr/local/include/wine -I/usr/local/include/wine/windows -I/usr/include/glib-2.0 -I/usr/include/glib-2.0/include -I/usr/include/gtk-2.0
27 DLL_PATH =
28 LIBRARY_PATH =-L/usr/lib32
29 LIBRARIES := $(shell pkg-config --libs $(PKG_CONFIG_MODULES)) -L/usr/X11R6/lib -lpthread -lrt -lX11 -m32
30 diff -U 3 -H -d -r -N -- fst.orig/README fst-1.8+git20091228/README
31 --- fst.orig/README 2009-12-28 15:07:55.000000000 +0000
32 +++ fst-1.8+git20091228/README 2010-06-12 16:51:24.000000000 +0100
33 @@ -6,7 +6,7 @@
34 Uses jack midi input.
35 Only works for GUI plugins currently.
37 -Supports LASH.
38 +Supports Ladish.
40 Getting Started
41 ---------------
42 @@ -15,39 +15,34 @@
44 gtk-devel
45 jack-devel
46 - lash-devel (optional)
48 2) Type 'make'. If everything works correctly this should create an
49 executable file called 'fst'.
51 -3) On 64bit it may fail with a link error, when it cant find a 32bit lash
52 - but the 64bit stuff is in place.
53 - build yourself a 32bit lash, or:
54 - make LASH_EXISTS=no
55 +3) To run your vst plugins:
57 -4) To run your vst plugins:
59 - ./fst /path/to/someplugin.dll
60 + ./fst /path/to/ladish/filename /path/to/someplugin.dll
62 and set up the inputs and outputs, eg. using qjackctl's
63 'Connections' window.
65 -5) To install copy both fst and fst.exe.so into your $PATH
66 + The Ladish file name may not exist.
67 + But, if it does, it will load it's state.
69 +4) To install copy both fst and fst.exe.so into your $PATH
70 (i think they need to be in the same folder)
73 Stuff
74 -----
76 -With LASH you can save and restore the state of the plugin.
77 -in order to promote lash i pushed other methods of load/save
78 -pretty much down in my priority list.
80 There is a first version of midi learn, load/save of midimap
81 will come tomorrow. i had my beer now and its 5:15
82 i should be in a club. but i go to bed now.
83 just press midi learn, move a plugin control and your midi
84 control.
87 License
88 -------
90 diff -U 3 -H -d -r -N -- fst.orig/fst.h fst-1.8+git20091228/fst.h
91 --- fst.orig/fst.h 2009-12-28 15:07:55.000000000 +0000
92 +++ fst-1.8+git20091228/fst.h 2010-06-12 16:35:18.000000000 +0100
93 @@ -24,6 +24,9 @@
95 void fst_set_error_function (void (*func)(const char *));
97 +int ladish_save_now;
98 +char* ladish_state_filename;
100 #include <vestige/aeffectx.h>
102 typedef struct _FST FST;
103 diff -U 3 -H -d -r -N -- fst.orig/gtk.c fst-1.8+git20091228/gtk.c
104 --- fst.orig/gtk.c 2009-12-28 15:07:55.000000000 +0000
105 +++ fst-1.8+git20091228/gtk.c 2010-06-12 16:46:32.000000000 +0100
106 @@ -9,11 +9,6 @@
108 #include <glib-2.0/glib.h>
110 -#ifdef HAVE_LASH
111 -#include <lash/lash.h>
112 -extern lash_client_t *lash_client;
113 -#endif
115 gboolean g_quit = FALSE;
116 gboolean quit = FALSE;
118 @@ -266,101 +261,6 @@
119 gtk_widget_grab_focus( gtk_socket );
122 -#ifdef HAVE_LASH
123 -void
124 -save_data( JackVST *jvst )
126 - int i, bytelen;
127 - lash_config_t *config;
128 - void *chunk;
130 - for( i=0; i<jvst->fst->plugin->numParams; i++ ) {
131 - char buf[10];
132 - float param;
134 - snprintf( buf, 9, "%d", i );
136 - config = lash_config_new_with_key( buf );
138 - pthread_mutex_lock( &(jvst->fst->lock) );
139 - param = jvst->fst->plugin->getParameter( jvst->fst->plugin, i );
140 - pthread_mutex_unlock( &(jvst->fst->lock) );
142 - lash_config_set_value_double(config, param);
143 - lash_send_config(lash_client, config);
144 - //lash_config_destroy( config );
147 - for( i=0; i<128; i++ ) {
148 - char buf[16];
150 - snprintf( buf, 15, "midi_map%d", i );
151 - config = lash_config_new_with_key( buf );
152 - lash_config_set_value_int(config, jvst->midi_map[i]);
153 - lash_send_config(lash_client, config);
154 - //lash_config_destroy( config );
157 - if( jvst->fst->plugin->flags & 32 ) {
158 - // TODO: calling from this thread is wrong.
159 - // is should move it to fst gui thread.
160 - printf( "getting chunk...\n" );
162 - // XXX: alternative. call using the fst->lock
163 - //pthread_mutex_lock( &(fst->lock) );
164 - //bytelen = jvst->fst->plugin->dispatcher( jvst->fst->plugin, 23, 0, 0, &chunk, 0 );
165 - //pthread_mutex_unlock( &(fst->lock) );
167 - bytelen = fst_call_dispatcher( jvst->fst, 23, 0, 0, &chunk, 0 );
168 - printf( "got tha chunk..\n" );
169 - if( bytelen ) {
170 - if( bytelen < 0 ) {
171 - printf( "Chunke len < 0 !!! Not saving chunk.\n" );
172 - } else {
173 - config = lash_config_new_with_key( "bin_chunk" );
174 - lash_config_set_value(config, chunk, bytelen );
175 - lash_send_config(lash_client, config);
176 - //lash_config_destroy( config );
185 -void
186 -restore_data(lash_config_t * config, JackVST *jvst )
188 - const char *key;
190 - key = lash_config_get_key(config);
192 - if (strncmp(key, "midi_map", strlen( "midi_map")) == 0) {
193 - int cc = atoi( key+strlen("midi_map") );
194 - int param = lash_config_get_value_int( config );
196 - if( cc < 0 || cc>=128 || param<0 || param>=jvst->fst->plugin->numParams )
197 - return;
199 - jvst->midi_map[cc] = param;
200 - return;
203 - if( jvst->fst->plugin->flags & 32 ) {
204 - if (strcmp(key, "bin_chunk") == 0) {
205 - fst_call_dispatcher( jvst->fst, 24, 0, lash_config_get_value_size( config ), (void *) lash_config_get_value( config ), 0 );
206 - return;
207 - }
208 - } else {
209 - pthread_mutex_lock( & jvst->fst->lock );
210 - jvst->fst->plugin->setParameter( jvst->fst->plugin, atoi( key ), lash_config_get_value_double( config ) );
211 - pthread_mutex_unlock( & jvst->fst->lock );
215 -#endif
217 static gboolean
218 idle_cb(JackVST *jvst)
220 @@ -383,43 +283,6 @@
221 gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( midi_learn_toggle ), 0 );
224 -#ifdef HAVE_LASH
225 - if (lash_enabled(lash_client)) {
226 - lash_event_t *event;
227 - lash_config_t *config;
229 - while ((event = lash_get_event(lash_client))) {
230 - switch (lash_event_get_type(event)) {
231 - case LASH_Quit:
232 - quit = 1;
233 - lash_event_destroy(event);
234 - break;
235 - case LASH_Restore_Data_Set:
236 - printf( "lash_restore... \n" );
237 - lash_send_event(lash_client, event);
238 - break;
239 - case LASH_Save_Data_Set:
240 - printf( "lash_save... \n" );
241 - save_data( jvst );
242 - lash_send_event(lash_client, event);
243 - break;
244 - case LASH_Server_Lost:
245 - return 1;
246 - default:
247 - printf("%s: receieved unknown LASH event of type %d",
248 - __FUNCTION__, lash_event_get_type(event));
249 - lash_event_destroy(event);
250 - break;
254 - while ((config = lash_get_config(lash_client))) {
255 - restore_data(config, jvst);
256 - lash_config_destroy(config);
260 -#endif
261 return TRUE;
264 @@ -443,6 +306,12 @@
266 if( fst->plugin->numPrograms > 0 )
267 fst->plugin->dispatcher( fst->plugin, effSetProgram, 0, 0, NULL, 0.0 );
268 + else
270 + GtkTreeIter new_row_iter;
271 + gtk_list_store_insert( retval, &new_row_iter, 0 );
272 + gtk_list_store_set( retval, &new_row_iter, 0, "no programs", 1, 0, -1 );
275 return retval;
277 diff -U 3 -H -d -r -N -- fst.orig/jfst.c fst-1.8+git20091228/jfst.c
278 --- fst.orig/jfst.c 2009-12-28 15:07:55.000000000 +0000
279 +++ fst-1.8+git20091228/jfst.c 2010-06-12 16:44:15.000000000 +0100
280 @@ -28,9 +28,6 @@
281 #include "jackvst.h"
282 #include "jack/midiport.h"
284 -#ifdef HAVE_LASH
285 -#include <lash/lash.h>
286 -#endif
287 #include <windows.h>
289 /* audiomaster.c */
290 @@ -42,6 +39,10 @@
291 extern void gui_init (int* argc, char** argv[]);
292 extern int manage_vst_plugin (JackVST*);
294 +/* Ladish support */
295 +extern int ladish_save_now;
296 +extern char* ladish_state_filename;
298 /* Prototype for plugin "canDo" helper function*/
299 int canDo(struct AEffect* plugin, char* feature);
301 @@ -58,11 +59,6 @@
302 void queue_midi_message(JackVST* jvst, int status, int d1, int d2, jack_nframes_t delta);
305 -#ifdef HAVE_LASH
306 -lash_client_t * lash_client;
307 -#endif
310 // Until i get Jack to call me when he wants to create a thread,
311 // i need to go through this.
313 @@ -218,6 +214,7 @@
314 int process_callback( jack_nframes_t nframes, void* data)
316 int i, o;
317 + int current_program;
318 JackVST* jvst = (JackVST*) data;
319 struct AEffect* plugin = jvst->fst->plugin;
321 @@ -312,7 +309,9 @@
325 - jvst->current_program = plugin->dispatcher( plugin, effGetProgram, 0, 0, NULL, 0.0f );
326 + current_program = plugin->dispatcher( plugin, effGetProgram, 0, 0, NULL, 0.0f );
327 + if( current_program >= 0 )
328 + jvst->current_program = current_program;
330 if (plugin->flags & effFlagsCanReplacing) {
332 @@ -332,6 +331,13 @@
333 process_midi_output(jvst, nframes);
337 + if (ladish_save_now)
339 + printf("got ladish save here\n");
340 + fst_save_state (jvst->fst, ladish_state_filename);
341 + ladish_save_now = 0;
344 return 0;
346 @@ -649,6 +655,13 @@
347 return (plugin->dispatcher(plugin, effCanDo, 0, 0, (void*)feature, 0.0f) > 0);
350 +//Ladish SIGUSR1
351 +static void sig_ladish(int sig)
353 + printf("got SIGUSR1, saving state now...\n");
354 + ladish_save_now = 1;
357 int WINAPI
358 WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR cmdline, int cmdshow)
359 //int
360 @@ -672,18 +685,17 @@
361 int argc;
362 char **argv;
364 - create_argc_argv_from_cmdline( cmdline, "./fst", &argc, &argv );
366 -#ifdef HAVE_LASH
368 - lash_event_t *event;
369 - lash_args_t *lash_args;
370 + //Ladish SIGUSR1
371 + struct sigaction sa;
372 + memset(&sa, 0, sizeof(sa));
373 + sa.sa_handler = sig_ladish;
374 + sigaction(SIGUSR1, &sa, NULL);
375 + ladish_save_now = 0;
377 - lash_args = lash_extract_args(&argc, &argv);
378 -#endif
379 + create_argc_argv_from_cmdline( cmdline, "./fst", &argc, &argv );
381 - if (argc < 2) {
382 - fprintf (stderr, "usage: %s <plugin>\n", argv[0]);
383 + if (argc < 3) {
384 + fprintf (stderr, "usage: %s <ladish-state-filename> <plugin>\n", argv[0]);
385 return 1;
388 @@ -691,38 +703,16 @@
389 //setpgrp();
391 gui_init (&argc, &argv);
393 - for (i = 1; i < argc; ++i) {
394 - if (argv[i][0] == '-') {
395 - if (argv[i][1] == 'n') {
396 - with_editor = 0;
398 - if (argv[i][1] == 'r') {
399 - resume_not_rt = 0;
401 - if (argv[i][1] == 's') {
402 - load_state = 1;
403 - state_file = argv[i+1];
404 - i++;
405 - if (i + 2 >= argc) {
406 - fprintf (stderr, "usage: %s <plugin>\n", argv[0]);
407 - return 1;
410 - if (argv[i][1] == 'c') {
411 - client_name = argv[i+1];
412 - i++;
413 - if (i + 2 >= argc) {
414 - fprintf (stderr, "usage: %s <plugin>\n", argv[0]);
415 - return 1;
418 - } else {
419 - plug = argv[i];
420 - break;
423 + ladish_state_filename = argv[1];
425 + if (open(ladish_state_filename, O_RDONLY) > 0) {
426 + load_state = 1;
427 + state_file = ladish_state_filename;
430 + plug = argv[2];
432 if (fst_init (hInst)) {
433 return 1;
435 @@ -731,14 +721,11 @@
436 for (i=0; i<128; i++ )
437 jvst->midi_map[i] = -1;
439 - if (!client_name) {
440 - client_name = g_path_get_basename(strdup (plug));
441 - if ((period = strrchr (client_name, '.')) != NULL) {
442 - *period = '\0';
444 + client_name = g_path_get_basename(strdup (plug));
445 + if ((period = strrchr (client_name, '.')) != NULL) {
446 + *period = '\0';
450 if ((jvst->handle = fst_load (plug)) == NULL) {
451 fst_error ("can't load plugin %s", plug);
452 return 1;
453 @@ -769,32 +756,6 @@
454 plugin->dispatcher (plugin, effSetBlockSize, 0,
455 jack_get_buffer_size (jvst->client), NULL, 0.0f);
457 - if( resume_not_rt ) {
458 - jvst->resume_called = TRUE;
459 - plugin->dispatcher (plugin, effMainsChanged, 0, 1, NULL, 0.0f);
462 - // ok.... plugin is running... lets bind to lash...
464 -#ifdef HAVE_LASH
465 - int flags = LASH_Config_Data_Set;
467 - lash_client =
468 - lash_init(lash_args, client_name, flags, LASH_PROTOCOL(2, 0));
470 - if (!lash_client) {
471 - fprintf(stderr, "%s: could not initialise lash\n", __FUNCTION__);
472 - fprintf(stderr, "%s: running fst without lash session-support\n", __FUNCTION__);
473 - fprintf(stderr, "%s: to enable lash session-support launch the lash server prior fst\n", __FUNCTION__);
476 - if (lash_enabled(lash_client)) {
477 - event = lash_event_new_with_type(LASH_Client_Name);
478 - lash_event_set_string(event, client_name);
479 - lash_send_event(lash_client, event);
481 -#endif
484 /* set program to zero */
485 /* i comment this out because it breaks dfx Geometer
486 @@ -922,14 +883,6 @@
487 printf( "no Editor\n" );
490 -#ifdef HAVE_LASH
491 - if( lash_enabled( lash_client ) ) {
492 - event = lash_event_new_with_type(LASH_Jack_Client_Name);
493 - lash_event_set_string(event, client_name);
494 - lash_send_event(lash_client, event);
496 -#endif
498 /* load state if requested */
500 if (load_state) {