summaryrefslogtreecommitdiffstats
path: root/src/progs
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2008-09-30 16:50:21 +0000
committerDavid Robillard <d@drobilla.net>2008-09-30 16:50:21 +0000
commit93850c202de8b073a1ce1dd8bd246d407bce4e2f (patch)
tree6910b135bf4eff12de1af116cef73f6e9c107cd0 /src/progs
parenta8bf5272d096de73507d2eab47f282c345f4ca8a (diff)
downloadingen-93850c202de8b073a1ce1dd8bd246d407bce4e2f.tar.gz
ingen-93850c202de8b073a1ce1dd8bd246d407bce4e2f.tar.bz2
ingen-93850c202de8b073a1ce1dd8bd246d407bce4e2f.zip
Flatten ingen source directory heirarchy a bit.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@1551 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/progs')
-rw-r--r--src/progs/ingen/Makefile.am30
-rw-r--r--src/progs/ingen/cmdline.c665
-rw-r--r--src/progs/ingen/cmdline.ggo36
-rw-r--r--src/progs/ingen/cmdline.h200
-rwxr-xr-xsrc/progs/ingen/ingen.dbg5
-rw-r--r--src/progs/ingen/ingen.desktop.in9
-rwxr-xr-xsrc/progs/ingen/ingen.dev5
-rw-r--r--src/progs/ingen/ingen.grind5
-rw-r--r--src/progs/ingen/main.cpp259
-rw-r--r--src/progs/ingen/wscript11
-rw-r--r--src/progs/python/Makefile.am4
-rwxr-xr-xsrc/progs/python/OSC.py373
-rw-r--r--src/progs/python/ingen.py636
-rw-r--r--src/progs/python/ingenecho.py40
-rw-r--r--src/progs/python/scripts/Makefile.am2
-rwxr-xr-xsrc/progs/python/scripts/flatten.py232
-rw-r--r--src/progs/python/scripts/sillysinepatch.py41
-rw-r--r--src/progs/supercollider/Ingen.sc746
-rw-r--r--src/progs/supercollider/Makefile.am2
-rw-r--r--src/progs/supercollider/README11
-rw-r--r--src/progs/supercollider/example.sc27
21 files changed, 0 insertions, 3339 deletions
diff --git a/src/progs/ingen/Makefile.am b/src/progs/ingen/Makefile.am
deleted file mode 100644
index c48a47a2..00000000
--- a/src/progs/ingen/Makefile.am
+++ /dev/null
@@ -1,30 +0,0 @@
-AM_CXXFLAGS = \
- -DINGEN_MODULE_DIR=\"$(libdir)/ingen\" \
- @GTHREAD_CFLAGS@ \
- @GLIBMM_CFLAGS@ \
- @REDLANDMM_CFLAGS@ \
- @RAUL_CFLAGS@ \
- @SLV2_CFLAGS@ \
- @INGEN_CFLAGS@
-
-MAINTAINERCLEANFILES = Makefile.in
-
-desktopfilesdir = $(datadir)/applications
-dist_desktopfiles_DATA = ingen.desktop
-
-bin_PROGRAMS = ingen
-ingen_LDADD = \
- ../../libs/module/libingen_module.la \
- ../../libs/shared/libingen_shared.la \
- @SLV2_LIBS@ \
- @REDLANDMM_LIBS@ \
- @RAUL_LIBS@ \
- @GTHREAD_LIBS@ \
- @GLIBMM_LIBS@
-
-ingen_DEPENDENCIES = ../../libs/module/libingen_module.la
-
-ingen_SOURCES = \
- main.cpp \
- cmdline.h \
- cmdline.c
diff --git a/src/progs/ingen/cmdline.c b/src/progs/ingen/cmdline.c
deleted file mode 100644
index ea48135c..00000000
--- a/src/progs/ingen/cmdline.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/*
- File autogenerated by gengetopt
- generated with the following command:
- gengetopt -g
-
- The developers of gengetopt consider the fixed text that goes in all
- gengetopt output files to be in the public domain:
- we make no copyright claims on it.
-*/
-
-/* If we use autoconf. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "getopt.h"
-
-#include "cmdline.h"
-
-const char *gengetopt_args_info_purpose = "A modular realtime audio processing system";
-
-const char *gengetopt_args_info_usage = "Usage: ingen [OPTIONS]...";
-
-const char *gengetopt_args_info_description = "Ingen can be run in various configurations. The engine can\nrun as a stand-alone server controlled by OSC, or internal to\nanother process (e.g. the GUI). The GUI can communicate with the engine\nvia either method, and many GUIs (or other things) may connect to an\nengine via OSC.\n\nExamples:\n\n ingen -e - Run an engine, listen for OSC \n ingen -g - Run a GUI, connect via OSC \n ingen -eg - Run an engine and a GUI in one process\n\nThe -l (load) option can be used in all cases:\n \n ingen -el patch.ingen.ttl - Run an engine and load a patch\n ingen -gl patch.ingen.ttl - Run a GUI and load a patch\n ingen -egl patch.ingen.ttl - Run an engine and a GUI and load a patch\n\nOptions:\n";
-
-const char *gengetopt_args_info_help[] = {
- " -h, --help Print help and exit",
- " -V, --version Print version and exit",
- " -e, --engine Run (JACK) engine (default=off)",
- " -E, --engine-port=INT Engine OSC port (default=`16180')",
- " -c, --connect=STRING Connect to existing engine at OSC URI \n (default=`osc.udp://localhost:16180')",
- " -g, --gui Launch the GTK graphical interface (default=off)",
- " -C, --client-port=INT Client OSC port",
- " -l, --load=STRING Load patch",
- " -L, --path=STRING Target path for loaded patch",
- " -r, --run=STRING Run script",
- " -p, --parallelism=INT Number of concurrent process threads (default=`1')",
- 0
-};
-
-typedef enum {ARG_NO
- , ARG_FLAG
- , ARG_STRING
- , ARG_INT
-} cmdline_parser_arg_type;
-
-static
-void clear_given (struct gengetopt_args_info *args_info);
-static
-void clear_args (struct gengetopt_args_info *args_info);
-
-static int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
- struct cmdline_parser_params *params, const char *additional_error);
-
-
-static char *
-gengetopt_strdup (const char *s);
-
-static
-void clear_given (struct gengetopt_args_info *args_info)
-{
- args_info->help_given = 0 ;
- args_info->version_given = 0 ;
- args_info->engine_given = 0 ;
- args_info->engine_port_given = 0 ;
- args_info->connect_given = 0 ;
- args_info->gui_given = 0 ;
- args_info->client_port_given = 0 ;
- args_info->load_given = 0 ;
- args_info->path_given = 0 ;
- args_info->run_given = 0 ;
- args_info->parallelism_given = 0 ;
-}
-
-static
-void clear_args (struct gengetopt_args_info *args_info)
-{
- args_info->engine_flag = 0;
- args_info->engine_port_arg = 16180;
- args_info->engine_port_orig = NULL;
- args_info->connect_arg = gengetopt_strdup ("osc.udp://localhost:16180");
- args_info->connect_orig = NULL;
- args_info->gui_flag = 0;
- args_info->client_port_orig = NULL;
- args_info->load_arg = NULL;
- args_info->load_orig = NULL;
- args_info->path_arg = NULL;
- args_info->path_orig = NULL;
- args_info->run_arg = NULL;
- args_info->run_orig = NULL;
- args_info->parallelism_arg = 1;
- args_info->parallelism_orig = NULL;
-
-}
-
-static
-void init_args_info(struct gengetopt_args_info *args_info)
-{
-
-
- args_info->help_help = gengetopt_args_info_help[0] ;
- args_info->version_help = gengetopt_args_info_help[1] ;
- args_info->engine_help = gengetopt_args_info_help[2] ;
- args_info->engine_port_help = gengetopt_args_info_help[3] ;
- args_info->connect_help = gengetopt_args_info_help[4] ;
- args_info->gui_help = gengetopt_args_info_help[5] ;
- args_info->client_port_help = gengetopt_args_info_help[6] ;
- args_info->load_help = gengetopt_args_info_help[7] ;
- args_info->path_help = gengetopt_args_info_help[8] ;
- args_info->run_help = gengetopt_args_info_help[9] ;
- args_info->parallelism_help = gengetopt_args_info_help[10] ;
-
-}
-
-void
-cmdline_parser_print_version (void)
-{
- printf ("%s %s\n", CMDLINE_PARSER_PACKAGE, CMDLINE_PARSER_VERSION);
-}
-
-static void print_help_common(void) {
- cmdline_parser_print_version ();
-
- if (strlen(gengetopt_args_info_purpose) > 0)
- printf("\n%s\n", gengetopt_args_info_purpose);
-
- if (strlen(gengetopt_args_info_usage) > 0)
- printf("\n%s\n", gengetopt_args_info_usage);
-
- printf("\n");
-
- if (strlen(gengetopt_args_info_description) > 0)
- printf("%s\n\n", gengetopt_args_info_description);
-}
-
-void
-cmdline_parser_print_help (void)
-{
- int i = 0;
- print_help_common();
- while (gengetopt_args_info_help[i])
- printf("%s\n", gengetopt_args_info_help[i++]);
-}
-
-void
-cmdline_parser_init (struct gengetopt_args_info *args_info)
-{
- clear_given (args_info);
- clear_args (args_info);
- init_args_info (args_info);
-}
-
-void
-cmdline_parser_params_init(struct cmdline_parser_params *params)
-{
- if (params)
- {
- params->override = 0;
- params->initialize = 1;
- params->check_required = 1;
- params->check_ambiguity = 0;
- params->print_errors = 1;
- }
-}
-
-struct cmdline_parser_params *
-cmdline_parser_params_create(void)
-{
- struct cmdline_parser_params *params =
- (struct cmdline_parser_params *)malloc(sizeof(struct cmdline_parser_params));
- cmdline_parser_params_init(params);
- return params;
-}
-
-static void
-free_string_field (char **s)
-{
- if (*s)
- {
- free (*s);
- *s = 0;
- }
-}
-
-
-static void
-cmdline_parser_release (struct gengetopt_args_info *args_info)
-{
-
- free_string_field (&(args_info->engine_port_orig));
- free_string_field (&(args_info->connect_arg));
- free_string_field (&(args_info->connect_orig));
- free_string_field (&(args_info->client_port_orig));
- free_string_field (&(args_info->load_arg));
- free_string_field (&(args_info->load_orig));
- free_string_field (&(args_info->path_arg));
- free_string_field (&(args_info->path_orig));
- free_string_field (&(args_info->run_arg));
- free_string_field (&(args_info->run_orig));
- free_string_field (&(args_info->parallelism_orig));
-
-
-
- clear_given (args_info);
-}
-
-
-static void
-write_into_file(FILE *outfile, const char *opt, const char *arg, char *values[])
-{
- if (arg) {
- fprintf(outfile, "%s=\"%s\"\n", opt, arg);
- } else {
- fprintf(outfile, "%s\n", opt);
- }
-}
-
-
-int
-cmdline_parser_dump(FILE *outfile, struct gengetopt_args_info *args_info)
-{
- int i = 0;
-
- if (!outfile)
- {
- fprintf (stderr, "%s: cannot dump options to stream\n", CMDLINE_PARSER_PACKAGE);
- return EXIT_FAILURE;
- }
-
- if (args_info->help_given)
- write_into_file(outfile, "help", 0, 0 );
- if (args_info->version_given)
- write_into_file(outfile, "version", 0, 0 );
- if (args_info->engine_given)
- write_into_file(outfile, "engine", 0, 0 );
- if (args_info->engine_port_given)
- write_into_file(outfile, "engine-port", args_info->engine_port_orig, 0);
- if (args_info->connect_given)
- write_into_file(outfile, "connect", args_info->connect_orig, 0);
- if (args_info->gui_given)
- write_into_file(outfile, "gui", 0, 0 );
- if (args_info->client_port_given)
- write_into_file(outfile, "client-port", args_info->client_port_orig, 0);
- if (args_info->load_given)
- write_into_file(outfile, "load", args_info->load_orig, 0);
- if (args_info->path_given)
- write_into_file(outfile, "path", args_info->path_orig, 0);
- if (args_info->run_given)
- write_into_file(outfile, "run", args_info->run_orig, 0);
- if (args_info->parallelism_given)
- write_into_file(outfile, "parallelism", args_info->parallelism_orig, 0);
-
-
- i = EXIT_SUCCESS;
- return i;
-}
-
-int
-cmdline_parser_file_save(const char *filename, struct gengetopt_args_info *args_info)
-{
- FILE *outfile;
- int i = 0;
-
- outfile = fopen(filename, "w");
-
- if (!outfile)
- {
- fprintf (stderr, "%s: cannot open file for writing: %s\n", CMDLINE_PARSER_PACKAGE, filename);
- return EXIT_FAILURE;
- }
-
- i = cmdline_parser_dump(outfile, args_info);
- fclose (outfile);
-
- return i;
-}
-
-void
-cmdline_parser_free (struct gengetopt_args_info *args_info)
-{
- cmdline_parser_release (args_info);
-}
-
-/** @brief replacement of strdup, which is not standard */
-char *
-gengetopt_strdup (const char *s)
-{
- char *result = NULL;
- if (!s)
- return result;
-
- result = (char*)malloc(strlen(s) + 1);
- if (result == (char*)0)
- return (char*)0;
- strcpy(result, s);
- return result;
-}
-
-int
-cmdline_parser (int argc, char * const *argv, struct gengetopt_args_info *args_info)
-{
- return cmdline_parser2 (argc, argv, args_info, 0, 1, 1);
-}
-
-int
-cmdline_parser_ext (int argc, char * const *argv, struct gengetopt_args_info *args_info,
- struct cmdline_parser_params *params)
-{
- int result;
- result = cmdline_parser_internal (argc, argv, args_info, params, NULL);
-
- if (result == EXIT_FAILURE)
- {
- cmdline_parser_free (args_info);
- exit (EXIT_FAILURE);
- }
-
- return result;
-}
-
-int
-cmdline_parser2 (int argc, char * const *argv, struct gengetopt_args_info *args_info, int override, int initialize, int check_required)
-{
- int result;
- struct cmdline_parser_params params;
-
- params.override = override;
- params.initialize = initialize;
- params.check_required = check_required;
- params.check_ambiguity = 0;
- params.print_errors = 1;
-
- result = cmdline_parser_internal (argc, argv, args_info, &params, NULL);
-
- if (result == EXIT_FAILURE)
- {
- cmdline_parser_free (args_info);
- exit (EXIT_FAILURE);
- }
-
- return result;
-}
-
-int
-cmdline_parser_required (struct gengetopt_args_info *args_info, const char *prog_name)
-{
- return EXIT_SUCCESS;
-}
-
-
-static char *package_name = 0;
-
-/**
- * @brief updates an option
- * @param field the generic pointer to the field to update
- * @param orig_field the pointer to the orig field
- * @param field_given the pointer to the number of occurrence of this option
- * @param prev_given the pointer to the number of occurrence already seen
- * @param value the argument for this option (if null no arg was specified)
- * @param possible_values the possible values for this option (if specified)
- * @param default_value the default value (in case the option only accepts fixed values)
- * @param arg_type the type of this option
- * @param check_ambiguity @see cmdline_parser_params.check_ambiguity
- * @param override @see cmdline_parser_params.override
- * @param no_free whether to free a possible previous value
- * @param multiple_option whether this is a multiple option
- * @param long_opt the corresponding long option
- * @param short_opt the corresponding short option (or '-' if none)
- * @param additional_error possible further error specification
- */
-static
-int update_arg(void *field, char **orig_field,
- unsigned int *field_given, unsigned int *prev_given,
- char *value, char *possible_values[], const char *default_value,
- cmdline_parser_arg_type arg_type,
- int check_ambiguity, int override,
- int no_free, int multiple_option,
- const char *long_opt, char short_opt,
- const char *additional_error)
-{
- char *stop_char = 0;
- const char *val = value;
- int found;
- char **string_field;
-
- stop_char = 0;
- found = 0;
-
- if (!multiple_option && prev_given && (*prev_given || (check_ambiguity && *field_given)))
- {
- if (short_opt != '-')
- fprintf (stderr, "%s: `--%s' (`-%c') option given more than once%s\n",
- package_name, long_opt, short_opt,
- (additional_error ? additional_error : ""));
- else
- fprintf (stderr, "%s: `--%s' option given more than once%s\n",
- package_name, long_opt,
- (additional_error ? additional_error : ""));
- return 1; /* failure */
- }
-
-
- if (field_given && *field_given && ! override)
- return 0;
- if (prev_given)
- (*prev_given)++;
- if (field_given)
- (*field_given)++;
- if (possible_values)
- val = possible_values[found];
-
- switch(arg_type) {
- case ARG_FLAG:
- *((int *)field) = !*((int *)field);
- break;
- case ARG_INT:
- if (val) *((int *)field) = strtol (val, &stop_char, 0);
- break;
- case ARG_STRING:
- if (val) {
- string_field = (char **)field;
- if (!no_free && *string_field)
- free (*string_field); /* free previous string */
- *string_field = gengetopt_strdup (val);
- }
- break;
- default:
- break;
- };
-
- /* check numeric conversion */
- switch(arg_type) {
- case ARG_INT:
- if (val && !(stop_char && *stop_char == '\0')) {
- fprintf(stderr, "%s: invalid numeric value: %s\n", package_name, val);
- return 1; /* failure */
- }
- break;
- default:
- ;
- };
-
- /* store the original value */
- switch(arg_type) {
- case ARG_NO:
- case ARG_FLAG:
- break;
- default:
- if (value && orig_field) {
- if (no_free) {
- *orig_field = value;
- } else {
- if (*orig_field)
- free (*orig_field); /* free previous string */
- *orig_field = gengetopt_strdup (value);
- }
- }
- };
-
- return 0; /* OK */
-}
-
-
-int
-cmdline_parser_internal (int argc, char * const *argv, struct gengetopt_args_info *args_info,
- struct cmdline_parser_params *params, const char *additional_error)
-{
- int c; /* Character of the parsed option. */
-
- int error = 0;
- struct gengetopt_args_info local_args_info;
-
- int override;
- int initialize;
- int check_required;
- int check_ambiguity;
-
- package_name = argv[0];
-
- override = params->override;
- initialize = params->initialize;
- check_required = params->check_required;
- check_ambiguity = params->check_ambiguity;
-
- if (initialize)
- cmdline_parser_init (args_info);
-
- cmdline_parser_init (&local_args_info);
-
- optarg = 0;
- optind = 0;
- opterr = params->print_errors;
- optopt = '?';
-
- while (1)
- {
- int option_index = 0;
-
- static struct option long_options[] = {
- { "help", 0, NULL, 'h' },
- { "version", 0, NULL, 'V' },
- { "engine", 0, NULL, 'e' },
- { "engine-port", 1, NULL, 'E' },
- { "connect", 1, NULL, 'c' },
- { "gui", 0, NULL, 'g' },
- { "client-port", 1, NULL, 'C' },
- { "load", 1, NULL, 'l' },
- { "path", 1, NULL, 'L' },
- { "run", 1, NULL, 'r' },
- { "parallelism", 1, NULL, 'p' },
- { NULL, 0, NULL, 0 }
- };
-
- c = getopt_long (argc, argv, "hVeE:c:gC:l:L:r:p:", long_options, &option_index);
-
- if (c == -1) break; /* Exit from `while (1)' loop. */
-
- switch (c)
- {
- case 'h': /* Print help and exit. */
- cmdline_parser_print_help ();
- cmdline_parser_free (&local_args_info);
- exit (EXIT_SUCCESS);
-
- case 'V': /* Print version and exit. */
- cmdline_parser_print_version ();
- cmdline_parser_free (&local_args_info);
- exit (EXIT_SUCCESS);
-
- case 'e': /* Run (JACK) engine. */
-
-
- if (update_arg((void *)&(args_info->engine_flag), 0, &(args_info->engine_given),
- &(local_args_info.engine_given), optarg, 0, 0, ARG_FLAG,
- check_ambiguity, override, 1, 0, "engine", 'e',
- additional_error))
- goto failure;
-
- break;
- case 'E': /* Engine OSC port. */
-
-
- if (update_arg( (void *)&(args_info->engine_port_arg),
- &(args_info->engine_port_orig), &(args_info->engine_port_given),
- &(local_args_info.engine_port_given), optarg, 0, "16180", ARG_INT,
- check_ambiguity, override, 0, 0,
- "engine-port", 'E',
- additional_error))
- goto failure;
-
- break;
- case 'c': /* Connect to existing engine at OSC URI. */
-
-
- if (update_arg( (void *)&(args_info->connect_arg),
- &(args_info->connect_orig), &(args_info->connect_given),
- &(local_args_info.connect_given), optarg, 0, "osc.udp://localhost:16180", ARG_STRING,
- check_ambiguity, override, 0, 0,
- "connect", 'c',
- additional_error))
- goto failure;
-
- break;
- case 'g': /* Launch the GTK graphical interface. */
-
-
- if (update_arg((void *)&(args_info->gui_flag), 0, &(args_info->gui_given),
- &(local_args_info.gui_given), optarg, 0, 0, ARG_FLAG,
- check_ambiguity, override, 1, 0, "gui", 'g',
- additional_error))
- goto failure;
-
- break;
- case 'C': /* Client OSC port. */
-
-
- if (update_arg( (void *)&(args_info->client_port_arg),
- &(args_info->client_port_orig), &(args_info->client_port_given),
- &(local_args_info.client_port_given), optarg, 0, 0, ARG_INT,
- check_ambiguity, override, 0, 0,
- "client-port", 'C',
- additional_error))
- goto failure;
-
- break;
- case 'l': /* Load patch. */
-
-
- if (update_arg( (void *)&(args_info->load_arg),
- &(args_info->load_orig), &(args_info->load_given),
- &(local_args_info.load_given), optarg, 0, 0, ARG_STRING,
- check_ambiguity, override, 0, 0,
- "load", 'l',
- additional_error))
- goto failure;
-
- break;
- case 'L': /* Target path for loaded patch. */
-
-
- if (update_arg( (void *)&(args_info->path_arg),
- &(args_info->path_orig), &(args_info->path_given),
- &(local_args_info.path_given), optarg, 0, 0, ARG_STRING,
- check_ambiguity, override, 0, 0,
- "path", 'L',
- additional_error))
- goto failure;
-
- break;
- case 'r': /* Run script. */
-
-
- if (update_arg( (void *)&(args_info->run_arg),
- &(args_info->run_orig), &(args_info->run_given),
- &(local_args_info.run_given), optarg, 0, 0, ARG_STRING,
- check_ambiguity, override, 0, 0,
- "run", 'r',
- additional_error))
- goto failure;
-
- break;
- case 'p': /* Number of concurrent process threads. */
-
-
- if (update_arg( (void *)&(args_info->parallelism_arg),
- &(args_info->parallelism_orig), &(args_info->parallelism_given),
- &(local_args_info.parallelism_given), optarg, 0, "1", ARG_INT,
- check_ambiguity, override, 0, 0,
- "parallelism", 'p',
- additional_error))
- goto failure;
-
- break;
-
- case 0: /* Long option with no short option */
- case '?': /* Invalid option. */
- /* `getopt_long' already printed an error message. */
- goto failure;
-
- default: /* bug: option not considered. */
- fprintf (stderr, "%s: option unknown: %c%s\n", CMDLINE_PARSER_PACKAGE, c, (additional_error ? additional_error : ""));
- abort ();
- } /* switch */
- } /* while */
-
-
-
-
- cmdline_parser_release (&local_args_info);
-
- if ( error )
- return (EXIT_FAILURE);
-
- return 0;
-
-failure:
-
- cmdline_parser_release (&local_args_info);
- return (EXIT_FAILURE);
-}
diff --git a/src/progs/ingen/cmdline.ggo b/src/progs/ingen/cmdline.ggo
deleted file mode 100644
index 994e6ff9..00000000
--- a/src/progs/ingen/cmdline.ggo
+++ /dev/null
@@ -1,36 +0,0 @@
-# Process this file with gengetopt to generate the necessary code (in cmdline.h, cmdline.c)
-
-package "ingen"
-purpose "A modular realtime audio processing system"
-
-description "Ingen can be run in various configurations. The engine can
-run as a stand-alone server controlled by OSC, or internal to
-another process (e.g. the GUI). The GUI can communicate with the engine
-via either method, and many GUIs (or other things) may connect to an
-engine via OSC.
-
-Examples:
-
- ingen -e - Run an engine, listen for OSC
- ingen -g - Run a GUI, connect via OSC
- ingen -eg - Run an engine and a GUI in one process
-
-The -l (load) option can be used in all cases:
-
- ingen -el patch.ingen.ttl - Run an engine and load a patch
- ingen -gl patch.ingen.ttl - Run a GUI and load a patch
- ingen -egl patch.ingen.ttl - Run an engine and a GUI and load a patch
-
-Options:
-"
-
-option "engine" e "Run (JACK) engine" flag off
-option "engine-port" E "Engine OSC port" int no default="16180"
-option "connect" c "Connect to existing engine at OSC URI" string no default="osc.udp://localhost:16180"
-option "gui" g "Launch the GTK graphical interface" flag off
-option "client-port" C "Client OSC port" int no
-option "load" l "Load patch" string no
-option "path" L "Target path for loaded patch" string no
-option "run" r "Run script" string no
-option "parallelism" p "Number of concurrent process threads" int no default="1"
-
diff --git a/src/progs/ingen/cmdline.h b/src/progs/ingen/cmdline.h
deleted file mode 100644
index 80358089..00000000
--- a/src/progs/ingen/cmdline.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/** @file cmdline.h
- * @brief The header file for the command line option parser
- * generated by GNU Gengetopt
- * http://www.gnu.org/software/gengetopt.
- * DO NOT modify this file, since it can be overwritten
- * @author GNU Gengetopt by Lorenzo Bettini */
-
-#ifndef CMDLINE_H
-#define CMDLINE_H
-
-/* If we use autoconf. */
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdio.h> /* for FILE */
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#ifndef CMDLINE_PARSER_PACKAGE
-/** @brief the program name */
-#define CMDLINE_PARSER_PACKAGE "ingen"
-#endif
-
-#ifndef CMDLINE_PARSER_VERSION
-/** @brief the program version */
-#define CMDLINE_PARSER_VERSION VERSION
-#endif
-
-/** @brief Where the command line options are stored */
-struct gengetopt_args_info
-{
- const char *help_help; /**< @brief Print help and exit help description. */
- const char *version_help; /**< @brief Print version and exit help description. */
- int engine_flag; /**< @brief Run (JACK) engine (default=off). */
- const char *engine_help; /**< @brief Run (JACK) engine help description. */
- int engine_port_arg; /**< @brief Engine OSC port (default='16180'). */
- char * engine_port_orig; /**< @brief Engine OSC port original value given at command line. */
- const char *engine_port_help; /**< @brief Engine OSC port help description. */
- char * connect_arg; /**< @brief Connect to existing engine at OSC URI (default='osc.udp://localhost:16180'). */
- char * connect_orig; /**< @brief Connect to existing engine at OSC URI original value given at command line. */
- const char *connect_help; /**< @brief Connect to existing engine at OSC URI help description. */
- int gui_flag; /**< @brief Launch the GTK graphical interface (default=off). */
- const char *gui_help; /**< @brief Launch the GTK graphical interface help description. */
- int client_port_arg; /**< @brief Client OSC port. */
- char * client_port_orig; /**< @brief Client OSC port original value given at command line. */
- const char *client_port_help; /**< @brief Client OSC port help description. */
- char * load_arg; /**< @brief Load patch. */
- char * load_orig; /**< @brief Load patch original value given at command line. */
- const char *load_help; /**< @brief Load patch help description. */
- char * path_arg; /**< @brief Target path for loaded patch. */
- char * path_orig; /**< @brief Target path for loaded patch original value given at command line. */
- const char *path_help; /**< @brief Target path for loaded patch help description. */
- char * run_arg; /**< @brief Run script. */
- char * run_orig; /**< @brief Run script original value given at command line. */
- const char *run_help; /**< @brief Run script help description. */
- int parallelism_arg; /**< @brief Number of concurrent process threads (default='1'). */
- char * parallelism_orig; /**< @brief Number of concurrent process threads original value given at command line. */
- const char *parallelism_help; /**< @brief Number of concurrent process threads help description. */
-
- unsigned int help_given ; /**< @brief Whether help was given. */
- unsigned int version_given ; /**< @brief Whether version was given. */
- unsigned int engine_given ; /**< @brief Whether engine was given. */
- unsigned int engine_port_given ; /**< @brief Whether engine-port was given. */
- unsigned int connect_given ; /**< @brief Whether connect was given. */
- unsigned int gui_given ; /**< @brief Whether gui was given. */
- unsigned int client_port_given ; /**< @brief Whether client-port was given. */
- unsigned int load_given ; /**< @brief Whether load was given. */
- unsigned int path_given ; /**< @brief Whether path was given. */
- unsigned int run_given ; /**< @brief Whether run was given. */
- unsigned int parallelism_given ; /**< @brief Whether parallelism was given. */
-
-} ;
-
-/** @brief The additional parameters to pass to parser functions */
-struct cmdline_parser_params
-{
- int override; /**< @brief whether to override possibly already present options (default 0) */
- int initialize; /**< @brief whether to initialize the option structure gengetopt_args_info (default 1) */
- int check_required; /**< @brief whether to check that all required options were provided (default 1) */
- int check_ambiguity; /**< @brief whether to check for options already specified in the option structure gengetopt_args_info (default 0) */
- int print_errors; /**< @brief whether getopt_long should print an error message for a bad option (default 1) */
-} ;
-
-/** @brief the purpose string of the program */
-extern const char *gengetopt_args_info_purpose;
-/** @brief the usage string of the program */
-extern const char *gengetopt_args_info_usage;
-/** @brief all the lines making the help output */
-extern const char *gengetopt_args_info_help[];
-
-/**
- * The command line parser
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser (int argc, char * const *argv,
- struct gengetopt_args_info *args_info);
-
-/**
- * The command line parser (version with additional parameters - deprecated)
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @param override whether to override possibly already present options
- * @param initialize whether to initialize the option structure my_args_info
- * @param check_required whether to check that all required options were provided
- * @return 0 if everything went fine, NON 0 if an error took place
- * @deprecated use cmdline_parser_ext() instead
- */
-int cmdline_parser2 (int argc, char * const *argv,
- struct gengetopt_args_info *args_info,
- int override, int initialize, int check_required);
-
-/**
- * The command line parser (version with additional parameters)
- * @param argc the number of command line options
- * @param argv the command line options
- * @param args_info the structure where option information will be stored
- * @param params additional parameters for the parser
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_ext (int argc, char * const *argv,
- struct gengetopt_args_info *args_info,
- struct cmdline_parser_params *params);
-
-/**
- * Save the contents of the option struct into an already open FILE stream.
- * @param outfile the stream where to dump options
- * @param args_info the option struct to dump
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_dump(FILE *outfile,
- struct gengetopt_args_info *args_info);
-
-/**
- * Save the contents of the option struct into a (text) file.
- * This file can be read by the config file parser (if generated by gengetopt)
- * @param filename the file where to save
- * @param args_info the option struct to save
- * @return 0 if everything went fine, NON 0 if an error took place
- */
-int cmdline_parser_file_save(const char *filename,
- struct gengetopt_args_info *args_info);
-
-/**
- * Print the help
- */
-void cmdline_parser_print_help(void);
-/**
- * Print the version
- */
-void cmdline_parser_print_version(void);
-
-/**
- * Initializes all the fields a cmdline_parser_params structure
- * to their default values
- * @param params the structure to initialize
- */
-void cmdline_parser_params_init(struct cmdline_parser_params *params);
-
-/**
- * Allocates dynamically a cmdline_parser_params structure and initializes
- * all its fields to their default values
- * @return the created and initialized cmdline_parser_params structure
- */
-struct cmdline_parser_params *cmdline_parser_params_create(void);
-
-/**
- * Initializes the passed gengetopt_args_info structure's fields
- * (also set default values for options that have a default)
- * @param args_info the structure to initialize
- */
-void cmdline_parser_init (struct gengetopt_args_info *args_info);
-/**
- * Deallocates the string fields of the gengetopt_args_info structure
- * (but does not deallocate the structure itself)
- * @param args_info the structure to deallocate
- */
-void cmdline_parser_free (struct gengetopt_args_info *args_info);
-
-/**
- * Checks that all the required options were specified
- * @param args_info the structure to check
- * @param prog_name the name of the program that will be used to print
- * possible errors
- * @return
- */
-int cmdline_parser_required (struct gengetopt_args_info *args_info,
- const char *prog_name);
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* CMDLINE_H */
diff --git a/src/progs/ingen/ingen.dbg b/src/progs/ingen/ingen.dbg
deleted file mode 100755
index 412c89bc..00000000
--- a/src/progs/ingen/ingen.dbg
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env sh
-
-export INGEN_MODULE_PATH="`pwd`/../../libs/engine/.libs:`pwd`/../../libs/serialisation/.libs:`pwd`/../../libs/gui/.libs:`pwd`/../../libs/client/.libs:`pwd`/../../bindings/.libs"
-export INGEN_GLADE_PATH="`pwd`/../../libs/gui/ingen_gui.glade"
-libtool --mode=execute gdb --args ./ingen $@
diff --git a/src/progs/ingen/ingen.desktop.in b/src/progs/ingen/ingen.desktop.in
deleted file mode 100644
index 6bd00e05..00000000
--- a/src/progs/ingen/ingen.desktop.in
+++ /dev/null
@@ -1,9 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=Ingen
-Comment=Create synthesizers and effects processors in a modular environment
-Exec=ingen -g
-Terminal=false
-Icon=ingen-icon.svg
-Type=Application
-Categories=Application;AudioVideo;Sound;Audio
diff --git a/src/progs/ingen/ingen.dev b/src/progs/ingen/ingen.dev
deleted file mode 100755
index 023eba7e..00000000
--- a/src/progs/ingen/ingen.dev
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env sh
-
-export INGEN_MODULE_PATH="`pwd`/../../libs/engine/.libs:`pwd`/../../libs/serialisation/.libs:`pwd`/../../libs/gui/.libs:`pwd`/../../libs/client/.libs:`pwd`/../../bindings/.libs"
-export INGEN_GLADE_PATH="`pwd`/../../libs/gui/ingen_gui.glade"
-./ingen $@
diff --git a/src/progs/ingen/ingen.grind b/src/progs/ingen/ingen.grind
deleted file mode 100644
index 9e597d44..00000000
--- a/src/progs/ingen/ingen.grind
+++ /dev/null
@@ -1,5 +0,0 @@
-#!/usr/bin/env sh
-
-export INGEN_MODULE_PATH="`pwd`/../../libs/engine/.libs:`pwd`/../../libs/serialisation/.libs:`pwd`/../../libs/gui/.libs:`pwd`/../../libs/client/.libs:`pwd`/../../bindings/.libs"
-export INGEN_GLADE_PATH="`pwd`/../../libs/gui/ingen_gui.glade"
-libtool --mode=execute valgrind ./ingen $@
diff --git a/src/progs/ingen/main.cpp b/src/progs/ingen/main.cpp
deleted file mode 100644
index c8adf207..00000000
--- a/src/progs/ingen/main.cpp
+++ /dev/null
@@ -1,259 +0,0 @@
-/* This file is part of Ingen.
- * Copyright (C) 2007 Dave Robillard <http://drobilla.net>
- *
- * Ingen is free software; you can redistribute it and/or modify it under the
- * terms of the GNU General Public License as published by the Free Software
- * Foundation; either version 2 of the License, or (at your option) any later
- * version.
- *
- * Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include CONFIG_H_PATH
-#include <iostream>
-#include <string>
-#include <signal.h>
-#include <dlfcn.h>
-#include <boost/optional.hpp>
-#include <glibmm/convert.h>
-#include <glibmm/miscutils.h>
-#include <glibmm/spawn.h>
-#include <glibmm/thread.h>
-#include <raul/Path.hpp>
-#include <raul/SharedPtr.hpp>
-#include <redlandmm/World.hpp>
-#include "module/global.hpp"
-#include "module/Module.hpp"
-#include "module/World.hpp"
-#include "engine/Engine.hpp"
-#include "engine/QueuedEngineInterface.hpp"
-#include "serialisation/Parser.hpp"
-#include "cmdline.h"
-
-#ifdef WITH_BINDINGS
-#include "bindings/ingen_bindings.hpp"
-#endif
-
-
-using namespace std;
-using namespace Ingen;
-
-
-SharedPtr<Engine> engine;
-
-void
-catch_int(int)
-{
- signal(SIGINT, catch_int);
- signal(SIGTERM, catch_int);
-
- cout << "[Main] Ingen interrupted." << endl;
- engine->quit();
-}
-
-int
-main(int argc, char** argv)
-{
- /* Parse command line options */
- gengetopt_args_info args;
- if (cmdline_parser (argc, argv, &args) != 0)
- return 1;
-
- if (argc <= 1) {
- cmdline_parser_print_help();
- cerr << endl << "*** Ingen requires at least one command line parameter" << endl;
- cerr << "*** Just want to use a graphical app? Try 'ingen -eg'" << endl;
- return 1;
- } else if (args.connect_given && args.engine_flag) {
- cerr << "\n*** Nonsense arguments, can't both run a local engine "
- << "and connect to a remote one." << endl
- << "*** Run separate instances if that is what you want" << endl;
- return 1;
- }
-
- SharedPtr<Glib::Module> engine_module;
- SharedPtr<Glib::Module> client_module;
- SharedPtr<Glib::Module> gui_module;
- SharedPtr<Glib::Module> bindings_module;
-
- SharedPtr<Shared::EngineInterface> engine_interface;
-
- Glib::thread_init();
-#if HAVE_SOUP
- g_type_init();
-#endif
-
- Ingen::Shared::World* world = Ingen::Shared::get_world();
-
- /* Set up RDF world */
- world->rdf_world->add_prefix("xsd", "http://www.w3.org/2001/XMLSchema#");
- world->rdf_world->add_prefix("ingen", "http://drobilla.net/ns/ingen#");
- world->rdf_world->add_prefix("ingenuity", "http://drobilla.net/ns/ingenuity#");
- world->rdf_world->add_prefix("lv2", "http://lv2plug.in/ns/lv2core#");
- world->rdf_world->add_prefix("lv2var", "http://lv2plug.in/ns/ext/instance-var#");
- world->rdf_world->add_prefix("lv2_midi", "http://lv2plug.in/ns/ext/midi");
- world->rdf_world->add_prefix("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
- world->rdf_world->add_prefix("doap", "http://usefulinc.com/ns/doap#");
- world->rdf_world->add_prefix("dc", "http://purl.org/dc/elements/1.1/");
-
- /* Run engine */
- if (args.engine_flag) {
- engine_module = Ingen::Shared::load_module("ingen_engine");
- if (engine_module) {
- Engine* (*new_engine)(Ingen::Shared::World* world) = NULL;
- if (engine_module->get_symbol("new_engine", (void*&)new_engine)) {
- engine = SharedPtr<Engine>(new_engine(world));
- world->local_engine = engine;
- /* Load queued (direct in-process) engine interface */
- if (args.gui_given) {
- engine_interface = engine->new_queued_interface();
- world->engine = engine_interface;
- } else {
- engine->start_osc_driver(args.engine_port_arg);
- engine->start_http_driver(args.engine_port_arg);
- }
- } else {
- engine_module.reset();
- }
- } else {
- cerr << "Unable to load engine module." << endl;
- }
- }
-
- /* Load client library */
- if (args.load_given || args.gui_given) {
- client_module = Ingen::Shared::load_module("ingen_client");
- if (!client_module)
- cerr << "Unable to load client module." << endl;
- }
-
- /* If we don't have a local engine interface (for GUI), use network */
- if (client_module && ! engine_interface) {
- SharedPtr<Shared::EngineInterface> (*new_remote_interface)(const std::string&) = NULL;
-
- if (client_module->get_symbol("new_remote_interface", (void*&)new_remote_interface)) {
- engine_interface = new_remote_interface(args.connect_arg);
- } else {
- cerr << "Unable to find symbol 'new_remote_interface' in "
- "ingen_client module, aborting." << endl;
- return -1;
- }
- }
-
- /* Activate the engine, if we have one */
- if (engine) {
- engine->start_jack_driver();
- engine->activate(args.parallelism_arg);
- }
-
- world->engine = engine_interface;
-
- /* Load a patch */
- if (args.load_given && engine_interface) {
-
- Glib::ustring engine_base = "/";
- if (args.path_given)
- engine_base = string(args.path_arg) + "/";
-
- bool found = false;
- if (!world->serialisation_module)
- world->serialisation_module = Ingen::Shared::load_module("ingen_serialisation");
-
- Serialisation::Parser* (*new_parser)() = NULL;
-
- if (world->serialisation_module)
- found = world->serialisation_module->get_symbol("new_parser", (void*&)new_parser);
-
- if (world->serialisation_module && found) {
- SharedPtr<Serialisation::Parser> parser(new_parser());
-
- // Assumption: Containing ':' means URI, otherwise filename
- string uri = args.load_arg;
- if (uri.find(':') == string::npos) {
- if (Glib::path_is_absolute(args.load_arg))
- uri = Glib::filename_to_uri(args.load_arg);
- else
- uri = Glib::filename_to_uri(Glib::build_filename(
- Glib::get_current_dir(), args.load_arg));
- }
-
-
- engine_interface->load_plugins();
- parser->parse_document(world, engine_interface.get(), uri, engine_base, uri);
-
- } else {
- cerr << "Unable to load serialisation module, aborting." << endl;
- return -1;
- }
- }
-
-
- /* Run GUI */
- bool ran_gui = false;
- if (args.gui_given) {
- gui_module = Ingen::Shared::load_module("ingen_gui");
- void (*run)(int, char**, Ingen::Shared::World*);
- bool found = gui_module->get_symbol("run", (void*&)run);
-
- if (found) {
- ran_gui = true;
- run(argc, argv, world);
- } else {
- cerr << "Unable to find GUI module, GUI not loaded." << endl;
- }
- }
-
- /* Run a script */
- if (args.run_given) {
-#ifdef WITH_BINDINGS
- bool (*run_script)(Ingen::Shared::World*, const char*) = NULL;
- SharedPtr<Glib::Module> bindings_module = Ingen::Shared::load_module("ingen_bindings");
- if (!bindings_module)
- cerr << Glib::Module::get_last_error() << endl;
-
- bindings_module->make_resident();
-
- bool found = bindings_module->get_symbol("run", (void*&)(run_script));
- if (found) {
- cerr << "WORLD: " << world << endl;
- cerr << "ENGINE: " << world->engine << endl;
- setenv("PYTHONPATH", "../../bindings", 1);
- run_script(world, args.run_arg);
- } else {
- cerr << "FAILED: " << Glib::Module::get_last_error() << endl;
- }
-#else
- cerr << "This build of ingen does not support scripting." << endl;
-#endif
-
- /* Listen to OSC and do our own main thing. */
- } else if (engine && !ran_gui) {
- signal(SIGINT, catch_int);
- signal(SIGTERM, catch_int);
- engine->main();
- }
-
- cout << "Exiting." << endl;
-
- if (engine) {
- engine->deactivate();
- engine.reset();
- }
-
- engine_interface.reset();
- client_module.reset();
- world->serialisation_module.reset();
- gui_module.reset();
- engine_module.reset();
-
- Ingen::Shared::destroy_world();
-
- return 0;
-}
-
diff --git a/src/progs/ingen/wscript b/src/progs/ingen/wscript
deleted file mode 100644
index d2e42c51..00000000
--- a/src/progs/ingen/wscript
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/usr/bin/env python
-
-def build(bld):
- obj = bld.create_obj('cpp', 'program')
- obj.target = 'ingen'
- obj.source = 'main.cpp cmdline.c'
- obj.includes = ['.', '../../common', '../..', '../../libs']
- obj.defines = 'VERSION=\\\"' + bld.env()['INGEN_VERSION'] + '\\\"'
- obj.uselib = 'GTHREAD GLIBMM REDLANDMM RAUL SLV2 INGEN LIBLO'
- obj.uselib_local = 'libingen_module libingen_shared'
-
diff --git a/src/progs/python/Makefile.am b/src/progs/python/Makefile.am
deleted file mode 100644
index c6da5467..00000000
--- a/src/progs/python/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-SUBDIRS = scripts
-
-EXTRA_DIST = ingen.py ingenecho.py OSC.py
-
diff --git a/src/progs/python/OSC.py b/src/progs/python/OSC.py
deleted file mode 100755
index ea93dc52..00000000
--- a/src/progs/python/OSC.py
+++ /dev/null
@@ -1,373 +0,0 @@
-#!/usr/bin/python
-#
-# Open SoundControl for Python
-# Copyright (C) 2002 Daniel Holth, Clinton McChesney
-# Modified by Leonard Ritter
-#
-# This library is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Lesser General Public License as published
-# by the Free Software Foundation; either version 2.1 of the License, or
-# (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
-# License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public License
-# along with this library; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-# For questions regarding this module contact Daniel Holth <dholth@stetson.edu>
-# or visit http://www.stetson.edu/~ProctoLogic/
-
-import socket
-import struct
-import math
-import sys
-import string
-
-
-def hexDump(bytes):
- """Useful utility; prints the string in hexadecimal"""
- for i in range(len(bytes)):
- sys.stdout.write("%2x " % (ord(bytes[i])))
- if (i+1) % 8 == 0:
- print repr(bytes[i-7:i+1])
-
- if(len(bytes) % 8 != 0):
- print string.rjust("", 11), repr(bytes[i-7:i+1])
-
-
-class OSCMessage:
- """Builds typetagged OSC messages."""
- def __init__(self):
- self.address = ""
- self.typetags = ","
- self.message = ""
-
- def setAddress(self, address):
- self.address = address
-
- def setMessage(self, message):
- self.message = message
-
- def setTypetags(self, typetags):
- self.typetags = typetags
-
- def clear(self):
- self.address = ""
- self.clearData()
-
- def clearData(self):
- self.typetags = ","
- self.message = ""
-
- def append(self, argument, typehint = None):
- """Appends data to the message,
- updating the typetags based on
- the argument's type.
- If the argument is a blob (counted string)
- pass in 'b' as typehint."""
-
- if typehint == 'b':
- binary = OSCBlob(argument)
- else:
- binary = OSCArgument(argument)
-
- self.typetags = self.typetags + binary[0]
- self.rawAppend(binary[1])
-
- def rawAppend(self, data):
- """Appends raw data to the message. Use append()."""
- self.message = self.message + data
-
- def getBinary(self):
- """Returns the binary message (so far) with typetags."""
- address = OSCArgument(self.address)[1]
- typetags = OSCArgument(self.typetags)[1]
- return address + typetags + self.message
-
- def __repr__(self):
- return self.getBinary()
-
-def readString(data):
- length = string.find(data,"\0")
- nextData = int(math.ceil((length+1) / 4.0) * 4)
- return (data[0:length], data[nextData:])
-
-
-def readBlob(data):
- length = struct.unpack(">i", data[0:4])[0]
- nextData = int(math.ceil((length) / 4.0) * 4) + 4
- return (data[4:length+4], data[nextData:])
-
-
-def readInt(data):
- if(len(data)<4):
- print "Error: too few bytes for int", data, len(data)
- rest = data
- integer = 0
- else:
- integer = struct.unpack(">i", data[0:4])[0]
- rest = data[4:]
-
- return (integer, rest)
-
-
-
-def readLong(data):
- """Tries to interpret the next 8 bytes of the data
- as a 64-bit signed integer."""
- high, low = struct.unpack(">ll", data[0:8])
- big = (long(high) << 32) + low
- rest = data[8:]
- return (big, rest)
-
-
-
-def readFloat(data):
- if(len(data)<4):
- print "Error: too few bytes for float", data, len(data)
- rest = data
- float = 0
- else:
- float = struct.unpack(">f", data[0:4])[0]
- rest = data[4:]
-
- return (float, rest)
-
-
-def OSCBlob(next):
- """Convert a string into an OSC Blob,
- returning a (typetag, data) tuple."""
-
- if type(next) == type(""):
- length = len(next)
- padded = math.ceil((len(next)) / 4.0) * 4
- binary = struct.pack(">i%ds" % (padded), length, next)
- tag = 'b'
- else:
- tag = ''
- binary = ''
-
- return (tag, binary)
-
-
-def OSCArgument(next):
- """Convert some Python types to their
- OSC binary representations, returning a
- (typetag, data) tuple."""
-
- if type(next) == type(""):
- OSCstringLength = math.ceil((len(next)+1) / 4.0) * 4
- binary = struct.pack(">%ds" % (OSCstringLength), next)
- tag = "s"
- elif type(next) == type(42.5):
- binary = struct.pack(">f", next)
- tag = "f"
- elif type(next) == type(13):
- binary = struct.pack(">i", next)
- tag = "i"
- else:
- binary = ""
- tag = ""
-
- return (tag, binary)
-
-
-def parseArgs(args):
- """Given a list of strings, produces a list
- where those strings have been parsed (where
- possible) as floats or integers."""
- parsed = []
- for arg in args:
- print arg
- arg = arg.strip()
- interpretation = None
- try:
- interpretation = float(arg)
- if string.find(arg, ".") == -1:
- interpretation = int(interpretation)
- except:
- # Oh - it was a string.
- interpretation = arg
- pass
- parsed.append(interpretation)
- return parsed
-
-
-
-def decodeOSC(data):
- """Converts a typetagged OSC message to a Python list."""
- table = {"i":readInt, "f":readFloat, "s":readString, "b":readBlob}
- decoded = []
- address, rest = readString(data)
- typetags = ""
-
- if address == "#bundle":
- time, rest = readLong(rest)
- decoded.append(address)
- decoded.append(time)
- while len(rest)>0:
- length, rest = readInt(rest)
- decoded.append(decodeOSC(rest[:length]))
- rest = rest[length:]
-
- elif len(rest)>0:
- typetags, rest = readString(rest)
- decoded.append(address)
- decoded.append(typetags)
- if(typetags[0] == ","):
- for tag in typetags[1:]:
- value, rest = table[tag](rest)
- decoded.append(value)
- else:
- print "Oops, typetag lacks the magic ,"
-
- # return only the data
- return address,decoded[2:]
-
-
-class CallbackManager:
- """This utility class maps OSC addresses to callables.
-
- The CallbackManager calls its callbacks with a list
- of decoded OSC arguments, including the address and
- the typetags as the first two arguments."""
-
- def __init__(self):
- self.callbacks = {}
- self.addCallback(self.unbundler, "#bundle")
-
- def handle(self, data, source = None):
- """Given OSC data, tries to call the callback with the
- right address."""
- decoded = decodeOSC(data)
- self.dispatch(decoded)
-
- def dispatch(self, message):
- """Sends decoded OSC data to an appropriate calback"""
- try:
- address = message[0]
- self.callbacks[address](message)
- except KeyError, e:
- # address not found
- print "no handler for '%s'" % address
- pass
- except None, e:
- print "Exception in", address, "callback :", e
-
- return
-
- def addCallback(self, callback, name):
- """Adds a callback to our set of callbacks,
- or removes the callback with name if callback
- is None."""
- if callback == None:
- del self.callbacks[name]
- else:
- self.callbacks[name] = callback
-
- def unbundler(self, messages):
- """Dispatch the messages in a decoded bundle."""
- # first two elements are #bundle and the time tag, rest are messages.
- for message in messages[2:]:
- self.dispatch(message)
-
-
-if __name__ == "__main__":
- hexDump("Welcome to the OSC testing program.")
- print
- message = OSCMessage()
- message.setAddress("/foo/play")
- message.append(44)
- message.append(11)
- message.append(4.5)
- message.append("the white cliffs of dover")
- hexDump(message.getBinary())
-
- print "Making and unmaking a message.."
-
- strings = OSCMessage()
- strings.append("Mary had a little lamb")
- strings.append("its fleece was white as snow")
- strings.append("and everywhere that Mary went,")
- strings.append("the lamb was sure to go.")
- strings.append(14.5)
- strings.append(14.5)
- strings.append(-400)
-
- raw = strings.getBinary()
-
- hexDump(raw)
-
- print "Retrieving arguments..."
- data = raw
- for i in range(6):
- text, data = readString(data)
- print text
-
- number, data = readFloat(data)
- print number
-
- number, data = readFloat(data)
- print number
-
- number, data = readInt(data)
- print number
-
- hexDump(raw)
- print decodeOSC(raw)
- print decodeOSC(message.getBinary())
-
- print "Testing Blob types."
-
- blob = OSCMessage()
- blob.append("","b")
- blob.append("b","b")
- blob.append("bl","b")
- blob.append("blo","b")
- blob.append("blob","b")
- blob.append("blobs","b")
- blob.append(42)
-
- hexDump(blob.getBinary())
-
- print decodeOSC(blob.getBinary())
-
- def printingCallback(stuff):
- sys.stdout.write("Got: ")
- for i in stuff:
- sys.stdout.write(str(i) + " ")
- sys.stdout.write("\n")
-
- print "Testing the callback manager."
-
- c = CallbackManager()
- c.add(printingCallback, "/print")
-
- c.handle(message.getBinary())
- message.setAddress("/print")
- c.handle(message.getBinary())
-
- print1 = OSCMessage()
- print1.setAddress("/print")
- print1.append("Hey man, that's cool.")
- print1.append(42)
- print1.append(3.1415926)
-
- c.handle(print1.getBinary())
-
- bundle = OSCMessage()
- bundle.setAddress("")
- bundle.append("#bundle")
- bundle.append(0)
- bundle.append(0)
- bundle.append(print1.getBinary(), 'b')
- bundle.append(print1.getBinary(), 'b')
-
- bundlebinary = bundle.message
-
- print "sending a bundle to the callback manager"
- c.handle(bundlebinary)
diff --git a/src/progs/python/ingen.py b/src/progs/python/ingen.py
deleted file mode 100644
index 07698719..00000000
--- a/src/progs/python/ingen.py
+++ /dev/null
@@ -1,636 +0,0 @@
-#!/usr/bin/python
-#
-# Python bindings for Ingen
-# Copyright (C) 2005 Leonard Ritter
-# Copyright (C) 2006 Dave Robillard
-
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import os,sys,thread,time
-
-from OSC import OSCMessage, decodeOSC
-
-from twisted.internet.protocol import DatagramProtocol
-from twisted.internet import reactor
-
-INGEN_CALL_TIMEOUT = 5
-INGEN_CALL_POLLTIME = 0.1
-
-class TreeElement:
- def __init__(self,environment,parent,name):
- self.environment = environment
- self.parent = parent
- self.name = name
- self.metadata = {}
-
- def __del__(self):
- print "'%s': gone" % self.name
-
- def removeChild(self, child):
- pass
-
- def remove(self):
- self.parent.removeChild(self.name)
- self.parent = None
- del self
-
- def getParent(self):
- return self.parent
-
- def getName(self):
- return self.name
-
- def getPath(self):
- if self.parent:
- return self.parent.getPath() + "/" + self.name
- else:
- return self.name
-
- def getDepth(self):
- if self.parent:
- return self.parent.getDepth() + 1
- else:
- return 0
-
- def setMetaData(self,key,value):
- if (not self.metadata.has_key(value)) or (self.metadata[key] != value):
- print "||| '%s': '%s' = '%s'" % (self.getPath(), key, value)
- self.metadata[key] = value
-
-class Port(TreeElement):
- def __init__(self,environment,parent,name):
- TreeElement.__init__(self,environment,parent,name)
- self.porttype = ""
- self.direction = ""
- self.hint = ""
- self.defaultvalue = 0.0
- self.minvalue = 0.0
- self.maxvalue = 0.0
- self.value = 0.0
- self.connections = {}
- print "*** '%s': new port" % self.getPath()
-
- def remove(self):
- for connection in self.getConnections():
- connection.remove()
- TreeElement.remove(self)
-
- def getConnections(self):
- return self.connections
-
- def addConnection(self,target,connection):
- self.connections[target] = connection
-
- def removeConnection(self,target):
- del self.connections[target]
-
- def setPortType(self,porttype):
- if self.porttype != porttype:
- print "*** '%s': changing porttype from '%s' to '%s'" % (self.getPath(), self.porttype, porttype)
- self.porttype = porttype
-
- def setDirection(self,direction):
- if self.direction != direction:
- print "*** '%s': changing direction from '%s' to '%s'" % (self.getPath(), self.direction, direction)
- self.direction = direction
-
- def setHint(self,hint):
- if self.hint != hint:
- print "*** '%s': changing hint from '%s' to '%s'" % (self.getPath(), self.hint, hint)
- self.hint = hint
-
- def setDefaultValue(self,defaultvalue):
- if self.defaultvalue != defaultvalue:
- print "*** '%s': changing defaultvalue from '%.3f' to '%.3f'" % (self.getPath(), self.defaultvalue, defaultvalue)
- self.defaultvalue = defaultvalue
-
- def setMinValue(self,minvalue):
- if self.minvalue != minvalue:
- print "*** '%s': changing minvalue from '%.3f' to '%.3f'" % (self.getPath(), self.minvalue, minvalue)
- self.minvalue = minvalue
-
- def setMaxValue(self,maxvalue):
- if self.maxvalue != maxvalue:
- print "*** '%s': changing maxvalue from '%.3f' to '%.3f'" % (self.getPath(), self.maxvalue, maxvalue)
- self.maxvalue = maxvalue
-
- def setValue(self,value):
- if self.value != value:
- print "*** '%s': changing value from '%.3f' to '%.3f'" % (self.getPath(), self.value, value)
- self.value = value
-
-class Node(TreeElement):
- def __init__(self,environment,parent,name):
- TreeElement.__init__(self,environment,parent,name)
- self.ports = {}
- self.polyphonic = 0
- self.plugintype = ""
- self.libname = ""
- self.pluginlabel = ""
- print "+++ '%s': new node" % self.getPath()
-
- def remove(self):
- for port in self.getPorts():
- port.remove()
- TreeElement.remove(self)
-
- def removeChild(self, child):
- del self.ports[child]
-
- def getPorts(self):
- return self.ports.values()
-
- def setPluginLabel(self,pluginlabel):
- if pluginlabel != self.pluginlabel:
- print "+++ '%s': changing pluginlabel from '%s' to '%s'" % (self.getPath(), self.pluginlabel, pluginlabel)
- self.pluginlabel = pluginlabel
-
- def setLibName(self,libname):
- if libname != self.libname:
- print "+++ '%s': changing libname from '%s' to '%s'" % (self.getPath(), self.libname, libname)
- self.libname = libname
-
- def setPluginType(self,plugintype):
- if plugintype != self.plugintype:
- print "+++ '%s': changing plugintype from '%s' to '%s'" % (self.getPath(), self.plugintype, plugintype)
- self.plugintype = plugintype
-
- def setPolyphonic(self,polyphonic):
- if polyphonic != self.polyphonic:
- print "+++ '%s': changing polyphony from %i to %i" % (self.getPath(), self.polyphonic, polyphonic)
- self.polyphonic = polyphonic
-
- def hasPort(self,name):
- return self.ports.has_key(name)
-
- def getPort(self,name,mustexist=False):
- if not self.hasPort(name):
- if mustexist:
- return None
- self.ports[name] = self.environment.getPortClass()(self.environment,self,name)
- return self.ports[name]
-
-class Patch(Node):
- def __init__(self,environment,parent,name):
- Node.__init__(self,environment,parent,name)
- self.nodes = {}
- self.patches = {}
- self.poly = 0
- self.enabled = False
- print "### '%s': new patch" % self.getPath()
-
- def remove(self):
- for patch in self.getPatches():
- patch.remove()
- for node in self.getNodes():
- node.remove()
- Node.remove(self)
-
- def removeChild(self, child):
- if self.hasNode(child):
- del self.nodes[child]
- elif self.hasPatch(child):
- del self.patches[child]
- else:
- Node.removeChild(self,child)
-
- def getPatches(self):
- return self.patches.values()
-
- def getNodes(self):
- return self.nodes.values()
-
- def getEnabled(self):
- return self.enabled
-
- def setEnabled(self,enabled):
- if enabled != self.enabled:
- print "### '%s': changing enabled from %s to %s" % (self.getPath(), str(self.enabled), str(enabled))
- enabled = self.enabled
-
- def getPoly(self):
- return self.poly
-
- def setPoly(self,poly):
- if poly != self.poly:
- print "### '%s': changing polyphony from %i to %i" % (self.getPath(), self.poly, poly)
- self.poly = poly
-
- def hasNode(self,name):
- return self.nodes.has_key(name)
-
- def getNode(self,name,mustexist=False):
- if not self.hasNode(name):
- if mustexist:
- return None
- self.nodes[name] = self.environment.getNodeClass()(self.environment,self,name)
- return self.nodes[name]
-
- def hasPatch(self,name):
- return self.patches.has_key(name)
-
- def getPatch(self,name,mustexist=False):
- if not self.hasPatch(name):
- if mustexist:
- return None
- self.patches[name] = self.environment.getPatchClass()(self.environment,self,name)
- return self.patches[name]
-
-class Connection:
- def __init__(self,environment,srcport,dstport):
- self.environment = environment
- self.srcport = srcport
- self.dstport = dstport
- self.srcport.addConnection(self.dstport,self)
- self.dstport.addConnection(self.srcport,self)
- print ">>> '%s'->'%s': new connection" % (self.srcport.getPath(),self.dstport.getPath())
-
- def __del__(self):
- print "connection gone"
-
- def remove(self):
- self.srcport.removeConnection(self.dstport)
- self.dstport.removeConnection(self.srcport)
- del self
-
- def getSrcPort(self):
- return self.srcport
-
- def getDstPort(self):
- return self.dstport
-
- def getPortPair(self):
- return self.srcport, self.dstport
-
-class Environment:
- def __init__(self):
- self.omPatch = self.getPatchClass()(self,None,"")
- self.enabled = False
- self.connections = {}
-
- def getConnectionClass(self):
- return Connection
-
- def getPatchClass(self):
- return Patch
-
- def getNodeClass(self):
- return Node
-
- def getPortClass(self):
- return Port
-
- def getConnection(self,srcportpath,dstportpath,mustexist=False):
- srcport = self.getPort(srcportpath,True)
- if not srcport:
- return None
- dstport = self.getPort(dstportpath,True)
- if not dstport:
- return None
- if not self.connections.has_key((srcport,dstport)):
- if mustexist:
- return None
- self.connections[(srcport,dstport)] = self.getConnectionClass()(self,srcport,dstport)
- return self.connections[(srcport,dstport)]
-
- def getConnections(self):
- return self.connections.values()
-
- def getPatch(self,path,mustexist=False):
- elements = path.split("/")
- currentPatch = None
- for element in elements:
- if element == "":
- currentPatch = self.omPatch
- else:
- currentPatch = currentPatch.getPatch(element,mustexist)
- if not currentPatch:
- break
- return currentPatch
-
- def getNode(self,path,mustexist=False):
- elements = path.split("/")
- basepath = "/".join(elements[:-1])
- nodename = elements[-1]
- patch = self.getPatch(basepath,True)
- if patch:
- return patch.getNode(nodename,mustexist)
- return None
-
- def getPort(self,path,mustexist=False):
- elements = path.split("/")
- basepath = "/".join(elements[:-1])
- portname = elements[-1]
- node = self.getNode(basepath,True)
- if node:
- return node.getPort(portname,mustexist)
- patch = self.getPatch(basepath,True)
- if patch:
- return patch.getPort(portname,mustexist)
- return None
-
- def getObject(self,path):
- patch = self.getPatch(path,True)
- if patch:
- return patch
- node = self.getNode(path,True)
- if node:
- return node
- return self.getPort(path,True)
-
- def printPatch(self,patch=None):
- if not patch:
- patch = self.omPatch
- print patch.getDepth()*' ' + "### " + patch.getPath()
- for node in patch.getNodes():
- print node.getDepth()*' ' + "+++ " + node.getPath()
- for port in node.getPorts():
- print port.getDepth()*' ' + "*** " + port.getPath()
- for port in patch.getPorts():
- print port.getDepth()*' ' + "*** " + port.getPath()
- for subpatch in patch.getPatches():
- self.printPatch(subpatch)
-
- def printConnections(self):
- for connection in self.getConnections():
- print ">>> %s -> %s" % (connection.getSrcPort().getPath(), connection.getDstPort().getPath())
-
- #~ /ingen/engine_enabled - Notification engine's DSP has been enabled.
- def __ingen__engine_enabled(self):
- self.enabled = True
-
- #~ /ingen/engine_disabled - Notification engine's DSP has been disabled.
- def __ingen__engine_disabled(self):
- self.enabled = False
-
- #~ /ingen/new_node - Notification of a new node's creation.
- #~ * path (string) - Path of the new node
- #~ * polyphonic (integer-boolean) - Node is polyphonic (1 for yes, 0 for no)
- #~ * type (string) - Type of plugin (LADSPA, DSSI, Internal, Patch)
- #~ * lib-name (string) - Name of library if a plugin (ie cmt.so)
- #~ * plug-label (string) - Label of plugin in library (ie adsr_env)
-
- #~ * New nodes are sent as a blob. The first message in the blob will be this one (/ingen/new_node), followed by a series of /om/new_port commands, followed by /om/new_node_end.
- def __ingen__new_node(self,path,polyphonic,plugintype,libname,pluginlabel):
- node = self.getNode(path)
- node.setPolyphonic(polyphonic)
- node.setPluginType(plugintype)
- node.setLibName(libname)
- node.setPluginLabel(pluginlabel)
-
- def __ingen__new_node_end(self):
- pass
-
- #~ /ingen/node_removal - Notification of a node's destruction.
- #~ * path (string) - Path of node (which no longer exists)
- def __ingen__node_removal(self,path):
- node = self.getNode(path)
- node.remove()
-
- #~ /ingen/new_port - Notification of a node's destruction.
-
- #~ * path (string) - Path of new port
- #~ * type (string) - Type of port (CONTROL or AUDIO)
- #~ * direction (string) - Direction of data flow (INPUT or OUTPUT)
- #~ * hint (string) - Hint (INTEGER, LOGARITHMIC, TOGGLE, or NONE)
- #~ * default-value (float) - Default (initial) value
- #~ * min-value (float) - Suggested minimum value
- #~ * min-value (float) - Suggested maximum value
-
- #~ * Note that in the event of loading a patch, this message could be followed immediately by a control change, meaning the default-value is not actually the current value of the port (ahem, Lachlan).
- #~ * The minimum and maximum values are suggestions only, they are not enforced in any way, and going outside them is perfectly fine. Also note that the port ranges in ingenuity are not these ones! Those ranges are set as metadata.
- def __ingen__new_port(self,path,porttype,direction,hint,defaultvalue,minvalue,maxvalue):
- port = self.getPort(path)
- port.setPortType(porttype)
- port.setDirection(direction)
- port.setHint(hint)
- port.setDefaultValue(defaultvalue)
- port.setMinValue(minvalue)
- port.setMaxValue(maxvalue)
-
- #~ /ingen/port_removal - Notification of a port's destruction.
- #~ * path (string) - Path of port (which no longer exists)
- def __ingen__port_removal(self,path):
- port = self.getPort(path)
- port.remove()
-
- #~ /ingen/patch_destruction - Notification of a patch's destruction.
- #~ * path (string) - Path of patch (which no longer exists)
- def __ingen__patch_destruction(self,path):
- patch = self.getPatch(path)
- patch.remove()
-
- #~ /ingen/patch_enabled - Notification a patch's DSP processing has been enabled.
- #~ * path (string) - Path of enabled patch
- def __ingen__patch_enabled(self,path):
- patch = self.getPatch(path)
- patch.setEnabled(True)
-
- #~ /ingen/patch_disabled - Notification a patch's DSP processing has been disabled.
- #~ * path (string) - Path of disabled patch
- def __ingen__patch_disabled(self,path):
- patch = self.getPatch(path)
- patch.setEnabled(False)
-
- #~ /ingen/new_connection - Notification a new connection has been made.
- #~ * src-path (string) - Path of the source port
- #~ * dst-path (string) - Path of the destination port
- def __ingen__new_connection(self,srcpath,dstpath):
- self.getConnection(srcpath,dstpath)
-
- #~ /ingen/disconnection - Notification a connection has been unmade.
- #~ * src-path (string) - Path of the source port
- #~ * dst-path (string) - Path of the destination port
- def __ingen__disconnection(self,srcpath,dstpath):
- connection = self.getConnection(srcpath,dstpath)
- portpair = connection.getPortPair()
- connection.remove()
- del self.connections[portpair]
-
- #~ /ingen/metadata/update - Notification of a piece of metadata.
- #~ * path (string) - Path of the object associated with metadata (can be a node, patch, or port)
- #~ * key (string)
- #~ * value (string)
- def __ingen__metadata__update(self,path,key,value):
- object = self.getObject(path)
- object.setMetaData(key,value)
-
- #~ /ingen/control_change - Notification the value of a port has changed
- #~ * path (string) - Path of port
- #~ * value (float) - New value of port
- #~ * This will only send updates for values set by clients of course - not values changing because of connections to other ports!
- def __ingen__control_change(self,path,value):
- port = self.getPort(path)
- port.setValue(value)
-
- #~ /ingen/new_patch - Notification of a new patch
- #~ * path (string) - Path of new patch
- #~ * poly (int) - Polyphony of new patch (not a boolean like new_node)
- def __ingen__new_patch(self,path,poly):
- patch = self.getPatch(path)
- patch.setPoly(poly)
-
-class SocketError:
- pass
-
-class Call:
- pass
-
-class ClientProxy:
- def __init__(self, om, name, is_async = False):
- self.name = name
- self.om = om
- self.is_async = is_async
-
- def __call__(self, *args):
- if (self.is_async):
- self.om.sendMsg(self.name, *args)
- return True
-
- result = self.om.sendMsgBlocking(self.name, *args)
- if not result:
- return None
- if result[0] == "/ingen/response/ok":
- return True
- print "ERROR: %s" % result[1][1]
- return False
-
- def __getattr__(self, name):
- if (name[:2] == "__") and (name[-2:] == "__"): # special function
- raise AttributeError, name
- if name in self.__dict__:
- raise AttributeError, name
- if name == 'async':
- return ClientProxy(self.om, self.name, True)
- else:
- return ClientProxy(self.om, self.name + '/' + name)
-
-class Client(DatagramProtocol, ClientProxy):
- def __init__(self):
- ClientProxy.__init__(self, self, "/ingen")
-
- def startProtocol(self):
- self.transport.connect("127.0.0.1", 16180)
- host = self.transport.getHost()
- self.host = host.host
- self.port = host.port
- self.environment = None
- self.handlers = {}
- self.calls = {}
- #print "opened port at %s" % (str((self.host,self.port)))
- self.nextPacketNumber = 1
-
- def setEnvironment(self, environment):
- self.handlers = {}
- self.environment = environment
- for name in dir(self.environment):
- element = getattr(self.environment,name)
- if (type(element).__name__ == 'instancemethod') and (element.__name__[:6] == "__ingen__"):
- handlername = element.__name__.replace("__","/")
- print "registering handler for '%s'" % handlername
- self.handlers[handlername] = element
-
- def getEnvironment(self):
- return self.environment
-
- def connectionRefused(self):
- print "Noone listening, aborting."
- os._exit(-1)
-
- def messageReceived(self, (msg, args)):
- if msg == "/ingen/error":
- print "ERROR: %r" % args
- return
- if msg == "/ingen/response/ok":
- omcall = self.calls[args[0]]
- omcall.result = (msg,args)
- omcall.done = True
- return
- if msg == "/ingen/response/error":
- omcall = self.calls[args[0]]
- omcall.result = (msg,args)
- omcall.done = True
- return
- if msg == "#bundle":
- for arg in args:
- self.messageReceived(arg)
- return
- if self.handlers.has_key(msg):
- try:
- self.handlers[msg](*args)
- except:
- a,b,c = sys.exc_info()
- sys.excepthook(a,b,c)
- print "with '%s'" % repr((msg,args))
- return
- print "no handler for '%s'" % repr((msg,args))
-
- def datagramReceived(self, data, (host, port)):
- self.messageReceived(decodeOSC(data))
-
- def getPacketNumber(self):
- packetNumber = self.nextPacketNumber
- self.nextPacketNumber = (self.nextPacketNumber + 1)
- return packetNumber
-
- def sendMsg(self,msg,*args):
- packetNumber = self.getPacketNumber()
- print "Sending %r (#%i)..." % (msg,packetNumber)
- omcall = Call()
- omcall.result = None
- omcall.done = False
- self.calls[packetNumber] = omcall
- message = OSCMessage()
- message.setAddress(msg)
- message.append(packetNumber)
- for arg in args:
- message.append(arg)
- self.transport.write(message.getBinary())
- time.sleep(0.01)
- return True
-
- def sendMsgBlocking(self,msg,*args):
- packetNumber = self.getPacketNumber()
- print "Sending %r (#%i)..." % (msg,packetNumber)
- omcall = Call()
- omcall.result = None
- omcall.done = False
- self.calls[packetNumber] = omcall
- message = OSCMessage()
- message.setAddress(msg)
- message.append(packetNumber)
- for arg in args:
- message.append(arg)
- self.transport.write(message.getBinary())
- now = time.time()
- while not omcall.done:
- time.sleep(INGEN_CALL_POLLTIME)
- distance = time.time() - now
- if distance > INGEN_CALL_TIMEOUT:
- print "timeout"
- break
- del self.calls[packetNumber]
- return omcall.result
-
- def getAddressAsString(self):
- return "osc.udp://%s:%d" % (self.host, self.port)
-
-
-
-def startClient(func):
- om = Client()
- reactor.listenUDP(0, om)
- thread.start_new_thread(func,(om,))
- reactor.run()
diff --git a/src/progs/python/ingenecho.py b/src/progs/python/ingenecho.py
deleted file mode 100644
index 1dcfc313..00000000
--- a/src/progs/python/ingenecho.py
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/python
-#
-# Python bindings for Om
-# Copyright (C) 2005 Leonard Ritter
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import ingen
-import os,time,sys
-
-def main(om):
- om.setEnvironment(ingen.Environment())
- om.engine.activate()
- om.engine.register_client(om.getAddressAsString())
- om.request.all_objects(om.getAddressAsString())
-
- om.request.all_objects()
- time.sleep(3)
- om.getEnvironment().printPatch()
- om.getEnvironment().printConnections()
- print "ingenecho will now monitor and mirror changes in the structure"
- print "hit return to exit when youre done"
- sys.stdin.readline()
- om.engine.unregister_client(om.getAddressAsString())
- os._exit(0)
-
-if __name__ == "__main__":
- ingen.startClient(main)
diff --git a/src/progs/python/scripts/Makefile.am b/src/progs/python/scripts/Makefile.am
deleted file mode 100644
index 3e070601..00000000
--- a/src/progs/python/scripts/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-EXTRA_DIST = sillysinepatch.py
-
diff --git a/src/progs/python/scripts/flatten.py b/src/progs/python/scripts/flatten.py
deleted file mode 100755
index 530e4291..00000000
--- a/src/progs/python/scripts/flatten.py
+++ /dev/null
@@ -1,232 +0,0 @@
-#!/usr/bin/python
-
-###############################################################################
-#
-# flatten.py - a python script that merges all subpatches in an Ingen patch
-# into the parent patch
-#
-# Copyright (C) 2005 Lars Luthman
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-#
-###############################################################################
-
-import ingen
-import os,time,sys
-
-
-def getPatchBounds(patch):
- """Returns the smallest rectangle that contains all modules in the patch."""
- min_x = None
- min_y = None
- max_x = None
- max_y = None
- for node in patch.getNodes():
- x = node.metadata['module-x']
- y = node.metadata['module-y']
- if (x != None):
- if (min_x == None or float(x) < min_x):
- min_x = float(x)
- if (max_x == None or float(x) > max_x):
- max_x = float(x)
- if (y != None):
- if (min_y == None or float(y) < min_y):
- min_y = float(y)
- if (max_y == None or float(y) > max_y):
- max_y = float(y)
- if min_x == None:
- min_x = 0
- max_x = 0
- if min_y == None:
- min_y = 0
- max_y = 0
-
- return (min_x, min_y, max_x, max_y)
-
-
-def cloneNode(om, node, patch):
- """Copy a node into a patch, return the new node's name."""
-
- # create a node with a free name in the parent
- names = []
- for node2 in patch.getNodes():
- names.append(node2.getName())
- for patch2 in patch.getPatches():
- names.append(patch2.getName())
- names.sort()
- name = node.getName()
- for name2 in names:
- if name2 == name:
- name = name + '_'
- om.synth.create_node.async(patch.getPath() + '/' + name,
- node.plugintype, node.libname,
- node.pluginlabel, node.polyphonic)
-
- # copy port values
- for port in node.getPorts():
- path = '%s/%s/%s' % (patch.getPath(), name, port.getName())
- om.synth.set_port_value_slow.async(path, port.value)
- om.metadata.set.async(path, 'user-min', '%f' % port.minvalue)
- om.metadata.set.async(path, 'user-max', '%f' % port.maxvalue)
- return name
-
-
-def flatten(om, patch):
- """Merge all subpatches into the parent patch."""
-
- # something is wrong, we don't have a patch
- if patch == None:
- return
-
- # iterate over all subpatches
- for subpatch in patch.getPatches():
- flatten(om, subpatch)
- lookup = {}
-
- # copy all nodes from the subpatch to the parent patch
- for node in subpatch.getNodes():
- lookup[node.getName()] = cloneNode(om, node, patch)
-
- # copy all connections
- for node in subpatch.getNodes():
- for port in node.getPorts():
- if port.direction == 'OUTPUT':
- for target in port.getConnections().keys():
- targetname = '%s/%s' % (lookup[target.getParent().getName()], target.getName())
- om.synth.connect.async(patch.getPath() + '/' +
- lookup[node.getName()] + '/' +
- port.getName(),
- patch.getPath() + '/' +
- targetname)
-
- # make external connections
- for node in subpatch.getNodes():
- if node.libname == '':
- lbl = node.pluginlabel
-
- if lbl == 'audio_input' or lbl == 'control_input':
- port1 = node.getPort('in')
- for port2 in port1.getConnections().keys():
- dst = '%s/%s/%s' % (patch.getPath(), lookup[port2.getParent().getName()], port2.getName())
- port4 = subpatch.getPort(node.getName())
- conns = port4.getConnections().keys()
- if len(conns) == 0:
- portValue = port4.value
- om.synth.set_port_value_slow.async(dst, portValue)
- else:
- for port3 in port4.getConnections().keys():
- src = port3.getPath()
- om.synth.connect.async(src, dst)
-
- if lbl == 'audio_output' or lbl == 'control_output':
- port2 = node.getPort('out', True)
- for port1 in port2.getConnections().keys():
- src = '%s/%s/%s' % (patch.getPath(), lookup[port1.getParent().getName()], port1.getName())
- port3 = subpatch.getPort(node.getName())
- for port4 in port3.getConnections().keys():
- dst = port4.getPath()
- om.synth.connect.async(src, dst)
-
- # destroy all input and output nodes from the subpatch
- for node in subpatch.getNodes():
- if node.libname == '':
- lbl = node.pluginlabel
- if (lbl == 'audio_input' or lbl == 'control_input' or
- lbl == 'audio_output' or lbl == 'control_output'):
- om.synth.destroy_node.async('%s/%s' % (patch.getPath(),
- lookup[node.getName()]))
-
- # calculate where to move all the new nodes
- (min_x, min_y, max_x, max_y) = getPatchBounds(subpatch)
- sub_x = subpatch.metadata['module-x']
- if sub_x == None:
- sub_x = 0
- sub_y = subpatch.metadata['module-y']
- if sub_y == None:
- sub_y = 0
- x_offset = float(sub_x)
- if min_x != None:
- x_offset = float(sub_x) - min_x
- y_offset = float(sub_y)
- if min_y != None:
- y_offset = float(sub_y) - min_y
-
- # move the new nodes
- for node in subpatch.getNodes():
- x = float(node.metadata['module-x'])
- if x == None:
- x = 0
- om.metadata.set.async('%s/%s' % (patch.getPath(),
- lookup[node.getName()]),
- 'module-x', '%f' % (x + x_offset))
- y = float(node.metadata['module-y'])
- if y == None:
- y = 0
- om.metadata.set.async('%s/%s' % (patch.getPath(),
- lookup[node.getName()]),
- 'module-y', '%f' % (y + y_offset))
-
- # move the old nodes in the patch
- x_offset = 0
- if min_x != None and max_x != None:
- x_offset = max_x - min_x
- y_offset = 0
- if min_y != None and max_y != None:
- y_offset = max_y - min_y
- for node in patch.getNodes():
- if node.getName() not in lookup.values():
- x = node.metadata['module-x']
- if x != None and float(x) > float(sub_x):
- om.metadata.set.async(node.getPath(), 'module-x',
- '%f' % (float(x) + x_offset))
- y = node.metadata['module-y']
- if y != None and float(y) > float(sub_y):
- om.metadata.set.async(node.getPath(), 'module-y',
- '%f' % (float(y) + y_offset))
- # destroy the subpatch
- om.synth.destroy_patch(subpatch.getPath())
-
-
-def main(om):
- om.setEnvironment(ingen.Environment())
- om.engine.activate.async()
- om.engine.load_plugins.async()
- om.request.all_objects(om.getAddressAsString())
-
- # wait for all the data to arrive (there should be a cleaner way)
- time.sleep(3)
-
- patch = om.getEnvironment().getPatch(sys.argv[1], True);
- flatten(om, patch)
-
- os._exit(0)
-
-
-if len(sys.argv) > 1:
- if sys.argv[1] == "--name":
- print "Flatten patch"
- os._exit(0)
- elif sys.argv[1] == "--shortdesc":
- print "Merge the contents of all subpatches into the parent patch";
- os._exit(0)
- elif sys.argv[1] == "--signature":
- print "%p";
- os._exit(0)
- else:
- ingen.startClient(main)
-
-else:
- print "Which patch do you want to flatten?"
- os._exit(0)
diff --git a/src/progs/python/scripts/sillysinepatch.py b/src/progs/python/scripts/sillysinepatch.py
deleted file mode 100644
index dcb37a97..00000000
--- a/src/progs/python/scripts/sillysinepatch.py
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/usr/bin/python
-#
-# Python bindings for Om
-# Copyright (C) 2005 Leonard Ritter
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-import ingen
-import os,time,sys
-
-def main(om):
- om.setEnvironment(ingen.Environment())
- om.engine.activate()
- om.engine.load_plugins()
- om.engine.register_client(om.getAddressAsString())
- om.request.all_objects(om.getAddressAsString())
- om.synth.create_patch("/silly_sine", 1)
- om.synth.create_node("/silly_sine/output", "Internal", "", "audio_output", 0)
- om.synth.create_node("/silly_sine/sine", "LADSPA", "cmt.so", "sine_fcac", 0)
- om.synth.set_port_value("/silly_sine/sine/Frequency", 440.0)
- om.synth.set_port_value("/silly_sine/sine/Amplitude", 1.0)
- om.synth.connect("/silly_sine/sine/Output", "/silly_sine/output/out")
- om.synth.enable_patch("/silly_sine")
- om.engine.enable()
- om.engine.unregister_client(om.getAddressAsString())
- os._exit(0)
-
-if __name__ == "__main__":
- ingen.startClient(main)
diff --git a/src/progs/supercollider/Ingen.sc b/src/progs/supercollider/Ingen.sc
deleted file mode 100644
index 873c8c2b..00000000
--- a/src/progs/supercollider/Ingen.sc
+++ /dev/null
@@ -1,746 +0,0 @@
-// TODO:
-// * Keep track of established connections.
-Ingen : Model {
- classvar <>program = "om", <>patchLoader = "om_patch_loader";
- classvar <>oscURL, <nodeTypeMap, <>uiClass;
- var <addr;
- var <>loadIntoJack = true;
- var allocator, requestResponders, requestHandlers, notificationResponders;
- var creatingNode, newNodeEnd;
- var <registered = false, <booting = false;
- var <root;
- var <plugins, pluginParentEvent;
- var onNewPatch;
- *initClass {
- Class.initClassTree(Event);
- Class.initClassTree(NetAddr);
- Event.parentEvents.default[\omcmd] = \noteOn;
- Event.parentEvents.default[\omEventFunctions] = (
- noteOn: #{ arg midinote=60, amp=0.1;
- [midinote, asInteger((amp * 127).clip(0, 127)) ] },
- noteOff: #{ arg midinote=60; [ midinote ] },
- setPortValue: #{|portValue=0| [portValue] }
- );
- Event.parentEvents.default.eventTypes[\om]=#{|server|
- var freqs, lag, dur, sustain, strum, target, bndl, omcmd;
- freqs = ~freq = ~freq.value + ~detune;
- if (freqs.isKindOf(Symbol).not) {
- ~amp = ~amp.value;
- strum = ~strum;
- lag = ~lag + server.latency;
- sustain = ~sustain = ~sustain.value;
- omcmd = ~omcmd;
- target = ~target;
- ~midinote = ~midinote.value;
- ~portValue = ~portValue.value;
- bndl = ~omEventFunctions[omcmd].valueEnvir.asCollection;
- bndl = bndl.flop;
- bndl.do {|msgArgs, i|
- var latency;
- latency = i * strum + lag;
- if(latency == 0.0) {
- target.performList(omcmd, msgArgs)
- } {
- thisThread.clock.sched(latency, {
- target.performList(omcmd, msgArgs);
- })
- };
- if(omcmd === \noteOn) {
- thisThread.clock.sched(sustain + latency, {
- target.noteOff(msgArgs[0])
- })
- }
- }
- }
- };
- oscURL="osc.udp://"++NetAddr.localAddr.ip++$:++NetAddr.localAddr.port;
- nodeTypeMap = IdentityDictionary[
- \Internal -> IngenInternalNode,
- \LADSPA -> IngenLADSPANode,
- \DSSI -> IngenDSSINode
- ];
- uiClass = IngenEmacsUI
- }
- *new { | netaddr |
- ^super.new.init(netaddr)
- }
- gui { ^uiClass.new(this) }
- init { |netaddr|
- addr = netaddr ? NetAddr("127.0.0.1", 16180);
- onNewPatch = IdentityDictionary.new;
- allocator = StackNumberAllocator(0,1024);
- requestHandlers = IdentityDictionary.new;
- requestResponders = [
- "response/ok" -> {|id|
- requestHandlers.removeAt(id).value; allocator.free(id) },
- "response/error" -> {|id,text|
- requestHandlers.removeAt(id);
- allocator.free(id);
- ("Ingen"+text).error }
- ].collect({|a|
- var func = a.value;
- OSCresponder(addr, "/om/"++a.key, {|time,resp,msg|
- func.value(*msg[1..])
- })
- });
- notificationResponders = [
- "new_patch" -> {|path,poly|
- var func = onNewPatch.removeAt(path);
- if (func.notNil) {
- func.value(this.getPatch(path,false).prSetPoly(poly))
- }
- },
- "metadata/update" -> {|path,key,value|
- this.getObject(path).metadata.prSetMetadata(key, value) },
- "new_node" -> {|path,poly,type,lib,label|
- var patchPath, nodeName, patch, node;
- var lastSlash = path.asString.inject(nil,{|last,char,i|
- if(char==$/,i,last)
- });
- if (lastSlash.notNil) {
- patchPath = path.asString.copyFromStart(lastSlash-1);
- nodeName = path.asString.copyToEnd(lastSlash+1);
- patch = this.getPatch(patchPath);
- if (patch.notNil) {
- if (patch.hasNode(nodeName).not) {
- node = nodeTypeMap[type].new
- (nodeName, patch, poly, label, lib);
- creatingNode = node;
- patch.nodes[nodeName.asSymbol] = node;
- patch.changed(\newNode, node);
- } {
- if (patch.getNode(nodeName).class != nodeTypeMap[type]) {
- ("Ingen sent an existng node with differing type"+path).warn
- }
- }
- } {
- ("Ingen tried to create node in non-existing patch"+patchPath).warn
- }
- } {
- ("Invalid path in node creation"+path).warn
- }
- },
- "new_node_end" -> {
- newNodeEnd.value(creatingNode);
- newNodeEnd = nil;
- creatingNode = nil },
- "new_port" -> {|path,type,dir,hint,def,min,max|
- var basePath, portName, parent, port;
- var lastSlash = path.asString.inject(nil,{|last,char,i|
- if(char==$/,i,last)
- });
- if (lastSlash.notNil) {
- basePath = path.asString.copyFromStart(lastSlash-1);
- portName = path.asString.copyToEnd(lastSlash+1);
- parent = this.getNode(basePath) ? this.getPatch(basePath);
- if (parent.notNil) {
- if (parent.hasPort(portName).not) {
- port = IngenPort.new(portName, parent, type, dir, hint, def, min, max);
- parent.ports[portName.asSymbol] = port;
- parent.changed(\newPort, port)
- } {
- if (parent.getPort(portName).porttype != type) {
- ("Ingen tried to create an already existing port with differing type"
- +path).warn
- }
- }
- } {
- ("Ingen tried to create port on non-existing object"+basePath).warn
- }
- } {
- ("Invalid path in port creation"+path).warn
- }
- },
- "control_change" -> {|path,value|
- this.getPort(path).prSetValue(value) },
- "patch_enabled" -> {|path| this.getPatch(path).prSetEnabled(true) },
- "patch_disabled" -> {|path| this.getPatch(path).prSetEnabled(false) },
- "plugin" -> {|lib,label,name,type|
- plugins.add(Event.new(4,nil,pluginParentEvent).putAll(
- (type:type, lib:lib, label:label, name:name))) },
- "node_removal" -> {|path|
- var node = this.getNode(path);
- if (node.notNil) {
- node.parent.nodes.removeAt(node.name.asSymbol).free
- } {
- ("Ingen attempting to remove non-existing node"+path).warn
- }
- },
- "port_removal" -> {|path|
- var port = this.getPort(path);
- if (port.notNil) {
- port.parent.ports.removeAt(port.name.asSymbol).free
- } {
- ("Ingen attempting to remove non-existing port"+path).warn
- }
- },
- "patch_destruction" -> {|path|
- var patch = this.getPatch(path);
- if (patch.notNil) {
- patch.parent.patches.removeAt(patch.name.asSymbol).free
- } {
- ("Ingen attempting to remove non-existing patch"+path).warn
- }
- },
- "program_add" -> {|path,bank,program,name|
- var node = this.getNode(path);
- if (node.respondsTo(\prProgramAdd)) {
- node.prProgramAdd(bank,program,name)
- } {
- ("Ingen tried to add program info to"+node).warn
- }
- }
- ].collect({|a|
- var func = a.value;
- OSCresponder(addr, "/om/"++a.key, {|time,resp,msg|
- func.value(*msg[1..])
- })
- });
- pluginParentEvent = Event.new(2,nil,nil).putAll((
- engine:this,
- new:{|self,path,poly=1,handler|self.engine.createNode(path?("/"++self.name),self.type,self.lib,self.label,poly,created:handler)}
- ));
- }
- *waitForBoot {|func| ^this.new.waitForBoot(func) }
- waitForBoot {|func|
- var r, id = 727;
- requestHandlers[id] = {
- r.stop;
- booting=false;
- this.changed(\running, true);
- func.value(this)
- };
- if (booting.not) {this.boot};
- r = Routine.run {
- 50.do {
- 0.1.wait;
- addr.sendMsg("/om/ping", id)
- };
- requestHandlers.removeAt(id);
- "Ingen engine boot failed".error;
- }
- }
- getPatch {|path, mustExist=true|
- var elements, currentPatch;
- if (path.class == Array) { elements = path
- } { elements = path.asString.split($/) };
- elements.do{|elem|
- if (elem=="") {
- currentPatch = root
- } {
- currentPatch = currentPatch.getPatch(elem,mustExist);
- if (currentPatch.isNil) { ^nil }
- }
- };
- ^currentPatch;
- }
- getNode {|path|
- var basePath, nodeName, patch;
- if (path.class == Array) { basePath = path
- } { basePath = path.asString.split($/) };
- nodeName = basePath.pop;
- patch = this.getPatch(basePath,true);
- if (patch.notNil) {
- ^patch.getNode(nodeName)
- };
- ^nil
- }
- getPort {|path|
- var basePath, portName, node, patch;
- basePath = path.asString.split($/);
- portName = basePath.pop;
- node = this.getNode(basePath.copy);
- if (node.notNil) { ^node.getPort(portName) };
- patch = this.getPatch(basePath,true);
- if (patch.notNil) { ^patch.getPort(portName) };
- ^nil
- }
- getObject {|path|
- var patch,node,port;
- patch = this.getPatch(path,true);
- if (patch.notNil) { ^patch };
- node = this.getNode(path);
- if (node.notNil) { ^node };
- port = this.getPort(path,true);
- if (port.notNil) { ^port };
- ^nil
- }
- at {|path|^this.getObject(path.asString)}
- *boot {|func|
- ^Ingen.new.waitForBoot {|e|
- e.activate {
- e.register {
- e.loadPlugins {
- e.requestPlugins {
- e.requestAllObjects {
- func.value(e)
- }
- }
- }
- }
- }
- }
- }
- boot {
- requestResponders.do({|resp| resp.add});
- booting = true;
- if (addr.addr == 2130706433) {
- if (loadIntoJack) {
- ("jack_load"+"-i"+addr.port+"Ingen"+"om").unixCmd
- } {
- (program+"-p"+addr.port).unixCmd
- }
- } {
- "You have to manually boot Ingen now".postln
- }
- }
- loadPatch {|patchPath| (patchLoader + patchPath).unixCmd }
- activate { | handler |
- this.sendReq("engine/activate", {
- root = IngenPatch("",nil,this);
- this.changed(\newPatch, root);
- handler.value
- })
- }
- register { | handler |
- this.sendReq("engine/register_client", {
- registered=true;
- notificationResponders.do({|resp| resp.add});
- this.changed(\registered, registered);
- handler.value(this)
- })
- }
- unregister { | handler |
- this.sendReq("engine/unregister_client", {
- registered=false;
- notificationResponders.do({|resp| resp.remove});
- this.changed(\registered, registered);
- handler.value(this)
- })
- }
- registered_ {|flag|
- if (flag and: registered.not) {
- this.register
- } {
- if (flag.not and: registered) {
- this.unregister
- }
- }
- }
- loadPlugins { | handler | this.sendReq("engine/load_plugins", handler) }
- requestPlugins {|handler|
- var startTime = Main.elapsedTime;
- plugins = Set.new;
- this.sendReq("request/plugins", {
- ("Received info about"+plugins.size+"plugins in"+(Main.elapsedTime-startTime)+"seconds").postln;
- this.changed(\plugins, plugins);
- handler.value(this);
- })
- }
- requestAllObjects { |handler|
- this.sendReq("request/all_objects", handler)
- }
- createPatch { | path, poly=1, handler |
- onNewPatch[path.asSymbol] = handler;
- this.sendReq("synth/create_patch", nil, path.asString, poly.asInteger)
- }
- createNode { | path, type='LADSPA', lib, label, poly=1, created, handler |
- newNodeEnd = created;
- this.sendReq("synth/create_node",handler,path,type,lib,label,poly)
- }
- createAudioInput { | path, handler |
- this.createNode(path,"Internal","","audio_input",0,handler)
- }
- createAudioOutput {|path,handler|
- this.createNode(path,"Internal","","audio_output",0,handler)
- }
- createMIDIInput {|path,handler|
- this.createNode(path,"Internal","","midi_input",1,handler)
- }
- createMIDIOutput {|path,handler|
- this.createNode(path,"Internal","","midi_output",1,handler)
- }
- createNoteIn {|path| this.createNode(path,"Internal","","note_in") }
- connect {|fromPath,toPath,handler|
- this.sendReq("synth/connect",handler,fromPath.asString,toPath.asString)
- }
- disconnect { | fromPath, toPath, handler |
- this.sendReq("synth/disconnect",handler,fromPath.asString,toPath.asString)
- }
- disconnectAll { | path, handler |
- this.sendReq("synth/disconnect_all",handler,path);
- }
- sendReq { | path, handler...args |
- var id = allocator.alloc;
- requestHandlers[id] = handler;
- addr.sendMsg("/om/"++path, id, *args)
- }
- quit {
- if (loadIntoJack) {
- ("jack_unload"+"Ingen").unixCmd;
- booting=false;
- requestResponders.do(_.remove);
- notificationResponders.do(_.remove);
- this.changed(\running, false);
- } {
- this.sendReq("engine/quit", {
- booting=false;
- requestResponders.do(_.remove);
- notificationResponders.do(_.remove);
- this.changed(\running, false);
- })
- }
- }
- ping {| n=1, func |
- var id, result, start;
- id = allocator.alloc;
- result = 0;
- requestHandlers[id] = {
- var end;
- end = Main.elapsedTime;
- result=max((end-start).postln,result);
- n=n-1;
- if (n > 0) {
- start = Main.elapsedTime;
- addr.sendMsg("/om/ping", id)
- } {
- allocator.free(id);
- func.value(result)
- }
- };
- start = Main.elapsedTime;
- addr.sendMsg("/om/ping", id)
- }
- setPortValue {|path, val| this.getPort(path.asString).value=val }
- jackConnect {|path, jackPort|
- this.getPort(path).jackConnect(jackPort)
- }
- noteOn {|path, note, vel|
- var patch,node;
- patch = this.getPatch(path,true);
- if (patch.notNil) { patch.noteOn(note,vel) };
- node = this.getNode(path);
- if (node.notNil) { node.noteOn(note,vel) };
- }
- noteOff {|path, note|
- var patch,node;
- patch = this.getPatch(path,true);
- if (patch.notNil) { patch.noteOff(note) };
- node = this.getNode(path);
- if (node.notNil) { node.noteOff(note) };
- }
- matchPlugins{ | label, lib, name, type |
- ^plugins.select{ |p|
- label.matchItem(p.label) and: {
- lib.matchItem(p.lib) and: {
- name.matchItem(p.name) and: {
- type.matchItem(p.type)
- }
- }
- }
- }
- }
- dssiMsg {|path,reqType="program" ...args|
- addr.sendMsg("/dssi"++path++$/++reqType,*args)
- }
-}
-
-IngenMetadata {
- var object, dict;
- *new {|obj|^super.new.metadataInit(obj)}
- metadataInit {|obj|
- dict=Dictionary.new;
- object=obj
- }
- put {|key,val|
- object.engine.sendReq("metadata/set", nil,
- object.path, key.asString, val.asString)
- }
- at {|key|^dict.at(key.asSymbol)}
- prSetMetadata {|key,val|
- dict.put(key,val);
- object.changed(\metadata, key, val)
- }
-}
-
-IngenObject : Model {
- var <name, <parent, <metadata;
- *new {|name, parent|
- ^super.new.initIngenObject(name,parent);
- }
- initIngenObject {|argName, argParent|
- name = argName;
- parent = argParent;
- metadata=IngenMetadata(this)
- }
- path { ^parent.notNil.if({ parent.path ++ $/ ++ name }, name).asString }
- depth { ^parent.notNil.if({ parent.depth + 1 }, 0) }
- engine { ^parent.engine }
-}
-
-IngenPort : IngenObject {
- var <porttype, <direction, <spec, <value, <connections;
- *new {|name,parent,type,dir,hint,def,min,max|
- ^super.new(name,parent).initPort(type,dir,hint,def,min,max)
- }
- initPort {|type,dir,hint,def,min,max|
- porttype = type;
- direction = dir;
- spec = ControlSpec(min, max,
- if (hint == 'LOGARITHMIC', 'exp', 'lin'),
- if (hint == 'INTEGER', 1, 0),
- def);
- connections = IdentityDictionary.new;
- }
- jackConnect {|jackPort|
- if (porttype.asSymbol != \AUDIO
- || direction.asSymbol!=\OUTPUT) {
- Error("Not a audio output port").throw
- };
- ("jack_connect" + "Ingen:"++(this.path) + jackPort).unixCmd
- }
- value_ {|val|
- if (porttype == \CONTROL and: {direction == \INPUT}) {
- this.engine.sendReq("synth/set_port_value", nil, this.path, val)
- } {
- Error("Not a input control port"+this.path).throw
- }
- }
- connectTo {|destPort|
- if (this.direction!=destPort.direction) {
- this.engine.connect(this,destPort)
- } {
- Error("Unable to connect ports with same direction").throw
- }
- }
-
- // Setters for OSC responders
- prSetValue {|argValue|
- if (value != argValue) {
- value = argValue;
- this.changed(\value, value)
- }
- }
-}
-
-IngenNode : IngenObject { // Abstract class
- var <ports, <polyphonic;
- *new {|name,parent,poly|
- ^super.new(name,parent).initNode(poly)
- }
- initNode {|argPoly|
- polyphonic = argPoly;
- ports = IdentityDictionary.new;
- }
- hasPort {|name| ^ports[name.asSymbol].notNil }
- getPort {|name| ^ports[name.asSymbol] }
- portArray {|type=\AUDIO,dir=\OUTPUT|
- var result = Array.new(8);
- ports.do {|port|
- if (port.porttype==type and: {port.direction==dir}) {
- result=result.add(port)
- }
- };
- ^result
- }
- audioOut {
- ^this.portArray(\AUDIO, \OUTPUT)
- }
- audioIn {
- ^this.portArray(\AUDIO, \INPUT)
- }
-}
-
-IngenInternalNode : IngenNode {
- var <pluginlabel;
- *new {|name,parent,poly,label|
- ^super.new(name,parent,poly).initInternalNode(label)
- }
- initInternalNode {|label|
- pluginlabel = label
- }
- noteOn { |note,vel|
- if (pluginlabel == \note_in or:
- {pluginlabel == \trigger_in and: {this.value == note}}) {
- this.engine.sendReq("synth/note_on", nil, this.path, note, vel)
- } {
- Error("Not a trigger_in or note_in node").throw
- }
- }
- noteOff {|note|
- if (pluginlabel == \note_in or:
- {pluginlabel == \trigger_in and: {this.value == note}}) {
- this.engine.sendReq("synth/note_off", nil, this.path, note)
- } {
- Error("Not a trigger_in or note_in node").throw
- }
- }
-}
-
-IngenLADSPANode : IngenNode {
- var <pluginlabel, <libname;
- *new {|name, parent, poly, label, lib|
- ^super.new(name,parent,poly).initLADSPANode(label,lib)
- }
- initLADSPANode {|label,lib|
- pluginlabel = label;
- libname = lib
- }
-}
-
-IngenDSSINode : IngenLADSPANode {
- var programs;
- *new {|name,parent,poly,label,lib|
- ^super.new(name,parent,poly,label,lib).initDSSI
- }
- initDSSI {
- programs = Set.new;
- }
- program {|bank, prog|
- this.engine.dssiMsg(this.path,"program",bank.asInteger,prog.asInteger)
- }
- prProgramAdd {|bank,program,name|
- var info = (bank:bank, program:program, name:name);
- if (programs.includes(info).not) {
- programs.add(info);
- this.changed(\programAdded, info)
- }
- }
-}
-
-IngenPatch : IngenNode {
- var <nodes, <patches, <poly, <enabled;
- var om;
- *new {|name,parent,engine|
- ^super.new(name,parent).initPatch(engine);
- }
- initPatch {|argEngine|
- nodes = IdentityDictionary.new;
- patches = IdentityDictionary.new;
- om = argEngine
- }
- hasNode {|name|
- ^nodes[name.asSymbol].notNil
- }
- getNode {|name|
- ^nodes[name.asSymbol]
- }
- hasPatch {|name|
- ^patches[name.asSymbol].notNil
- }
- getPatch {|name,mustExist=false|
- if (this.hasPatch(name).not) {
- if (mustExist) { ^nil };
- patches[name.asSymbol] = IngenPatch(name,this);
- };
- ^patches[name.asSymbol]
- }
- engine {
- if (om.notNil) { ^om } { ^parent.engine };
- }
- connect {|fromPort, toPort|
- this.engine.connect(this.path++$/++fromPort, this.path++$/++toPort)
- }
- dumpX {
- (String.fill(this.depth,$ )++"*"+this.path).postln;
- nodes.do{|node|
- (String.fill(node.depth,$ )++"**"+node.path).postln;
- node.ports.do{|port|
- (String.fill(port.depth,$ )++"***"+port.path).postln };
- };
- ports.do{|port| (String.fill(port.depth,$ )++"***"+port.path).postln };
- patches.do(_.dump)
- }
- noteOn {|note,vel|
- var targetNode;
- this.nodes.do{|node|
- if (node.class == IngenInternalNode) {
- node.pluginlabel.switch(
- \trigger_in, {
- if (node.ports['Note Number'].value == note) {
- targetNode = node;
- }
- },
- \note_in, {
- targetNode = node;
- }
- )
- }
- };
- if (targetNode.notNil) {
- targetNode.noteOn(note, vel)
- } {
- Error("Unable to find trigger_in for note "++note).throw
- }
- }
- noteOff {|note|
- var targetNode;
- this.nodes.do{|node|
- if (node.class == IngenInternalNode) {
- node.pluginlabel.switch(
- \trigger_in, {
- if (node.ports['Note Number'].value == note) {
- targetNode = node;
- }
- },
- \note_in, {
- targetNode = node;
- }
- )
- }
- };
- if (targetNode.notNil) {
- targetNode.noteOff(note)
- } {
- Error("Unable to find node for note_off "++note).throw
- }
- }
- newPatch {|name, poly=1, handler|
- this.engine.createPatch(this.path++$/++name, poly, handler)
- }
- newNode {|name, poly=1, type, lib, label, fullname, handler|
- var candidates = this.engine.matchPlugins(label,lib,fullname,type);
- if (candidates.size == 1) {
- candidates.pop.new(this.path++"/"++name, poly, handler)
- } {
- if (candidates.size==0) {
- Error("Plugin not found").throw
- } {
- Error("Plugin info not unique").throw
- }
- }
- }
-
- // Setters for OSC responders
- prSetPoly {|argPoly| poly = argPoly }
- prSetEnabled {|flag|
- if (flag != enabled) {
- enabled = flag;
- this.changed(\enabled, flag)
- }
- }
-}
-
-
-IngenEmacsUI {
- var engine, window, bootBtn;
- *new {|engine| ^super.newCopyArgs(engine).init }
- init {
- window = EmacsBuffer("*Ingen -"+engine.addr.ip++$:++engine.addr.port);
- bootBtn = EmacsButton(window, ["Boot","Quit"], {|value|
- if (value==1) {
- engine.boot
- } {
- engine.quit
- }
- }).value=engine.registered.binaryValue;
- engine.addDependant(this);
- window.front;
- }
- update {|who, what ... args|
- Emacs.message(who.asString+what+args);
- if (what == \newPatch or: {what == \newNode or: {what == \newPort}}) {
- args[0].addDependant(this)
- };
- }
-}
diff --git a/src/progs/supercollider/Makefile.am b/src/progs/supercollider/Makefile.am
deleted file mode 100644
index a6001b7a..00000000
--- a/src/progs/supercollider/Makefile.am
+++ /dev/null
@@ -1,2 +0,0 @@
-EXTRA_DIST = Ingen.sc example.sc
-
diff --git a/src/progs/supercollider/README b/src/progs/supercollider/README
deleted file mode 100644
index 850bca6a..00000000
--- a/src/progs/supercollider/README
+++ /dev/null
@@ -1,11 +0,0 @@
-Ingen bindings for SuperCollider
------------------------------
-
-Installation:
-Copy the Ingen.sc file into some directory in your SC class path and
-reboot sclang.
-
-Usage:
-See example.sc for inspiration.
-
- -- Mario Lang <mlang@delysid.org>
diff --git a/src/progs/supercollider/example.sc b/src/progs/supercollider/example.sc
deleted file mode 100644
index 80a72a7b..00000000
--- a/src/progs/supercollider/example.sc
+++ /dev/null
@@ -1,27 +0,0 @@
-// Boot Ingen (inside SC) and the scsynth server
-(
-o=Ingen.boot {
- o.loadPatch("/home/mlang/src/om-synth/src/clients/patches/303.om");
- s.boot;
-}
-)
-// Connect patch output to one SC input
-o.jackConnect("/303/output", "SuperCollider:in_3");
-// Play this input on the default output bus (most simple postprocessor)
-{AudioIn.ar(3).dup}.play;
-// A simple 303 pattern
-(
-Tempo.bpm=170;
-Ppar([
- Pbind(\type, \om, \target, o.getPatch("/303",true),
- \dur, 1/1, \octave,2,\degree, Pseq([Pshuf([0,2,4,6],16)],2)),
- Pbind(\type, \om, \target, o.getPatch("/303",true),
- \dur, Prand([Pshuf([1/2,1/4,1/4],4),Pshuf([1/3,1/3,1/6,1/6],4)],inf),
- \legato, Prand((0.5,0.55..0.9),inf),
- \octave,3,\degree, Pseq([Pshuf([0,2,4,6],2)],40)),
- Pbind(\type, \om, \omcmd, \setPortValue,
- \target, o.getPort("/303/cutoff",true),
- \dur, 1/10, \portValue, Pseq((0,0.005..1).mirror,2)),
- Pbind(\type, \om, \omcmd, \setPortValue,
- \target, o.getPort("/303/resonance",true), \portValue, 1)]).play(quant:4)
-)