4 * Copyright (C) 2002 Robert Ham <rah@bash.sh>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
25 #include <sys/types.h>
33 #include "lash/lash.h"
37 # include "interface.h"
43 #define MODULATION_DEFAULT 0.8
44 #define HARMONIC_DEFAULT 1
45 #define SUBHARMONIC_DEFAULT 3
46 #define TRANSPOSE_DEFAULT 12
47 #define ATTACK_DEFAULT 0.05
48 #define DECAY_DEFAULT 0.3
49 #define SUSTAIN_DEFAULT 0.8
50 #define RELEASE_DEFAULT 0.2
51 #define GAIN_DEFAULT 1.0
53 #define CLIENT_NAME_BASE "lash_synth"
58 printf("LASH Synth version %s\n", PACKAGE_VERSION
);
59 printf("Copyright (C) 2002 Robert Ham <rah@bash.sh>\n");
62 ("This program comes with ABSOLUTELY NO WARRANTY. You are licensed to use it\n");
64 ("under the terms of the GNU General Public License, version 2 or later. See\n");
65 printf("the COPYING file that came with this software for details.\n");
67 printf(" -h, --help Display this help info\n");
68 printf(" --lash-port=<port> Connect to server on port <port>\n");
70 (" -p, --pid Use the pid in the client string (default)\n");
72 (" -e, --name <string> Use the specified string in the client string\n");
74 (" -b, --basic-name Use just the program name in the client string\n");
77 (" -m, --modulation <float> Set the synth modulation parameter [%g]\n",
80 (" -n, --harmonic <int> Set the synth harmonic parameter [%d]\n",
83 (" -u, --subharmonic <int> Set the synth subharmonic parameter [%d]\n",
86 (" -t, --transpose <int> Set the synth transpose parameter [%d]\n",
89 (" -a, --attack <float> Set the synth attack parameter [%g]\n",
92 (" -d, --decay <float> Set the synth decay parameter [%g]\n",
95 (" -s, --sustain <float> Set the synth sustain parameter [%g]\n",
98 (" -r, --release <float> Set the synth release parameter [%g]\n",
101 (" -g, --gain <float> Set the synth gain [%g]\n",
107 main(int argc
, char **argv
)
110 const char *options
= "hm:n:u:t:a:d:s:r:g:pe:";
111 struct option long_options
[] = {
112 {"help", 0, NULL
, 'h'},
113 {"pid", 0, NULL
, 'p'},
114 {"name", 1, NULL
, 'e'},
115 {"basic-name", 0, NULL
, 'b'},
116 {"modulation", 1, NULL
, 'm'},
117 {"harmonic", 1, NULL
, 'n'},
118 {"subharmonic", 1, NULL
, 'u'},
119 {"transpose", 1, NULL
, 'y'},
120 {"attack", 1, NULL
, 'a'},
121 {"decay", 1, NULL
, 'd'},
122 {"sustain", 1, NULL
, 's'},
123 {"release", 1, NULL
, 'r'},
124 {"gain", 1, NULL
, 'g'},
128 lash_args_t
*lash_args
;
131 pthread_t interface_thread
;
133 pthread_t lash_thread
;
137 modulation
= MODULATION_DEFAULT
;
138 harmonic
= HARMONIC_DEFAULT
;
139 subharmonic
= SUBHARMONIC_DEFAULT
;
140 transpose
= TRANSPOSE_DEFAULT
;
141 attack
= ATTACK_DEFAULT
;
142 decay
= DECAY_DEFAULT
;
143 sustain
= SUSTAIN_DEFAULT
;
144 release
= RELEASE_DEFAULT
;
147 lash_args
= lash_extract_args(&argc
, &argv
);
150 gtk_init(&argc
, &argv
);
153 sprintf(alsa_client_name
, "%s_%d", CLIENT_NAME_BASE
, getpid());
154 sprintf(jack_client_name
, "%s_%d", CLIENT_NAME_BASE
, getpid());
156 while ((opt
= getopt_long(argc
, argv
, options
, long_options
, NULL
)) != -1) {
159 modulation
= atof(optarg
);
162 harmonic
= atoi(optarg
);
165 subharmonic
= atoi(optarg
);
168 transpose
= atoi(optarg
);
171 attack
= atof(optarg
);
174 decay
= atof(optarg
);
177 sustain
= atof(optarg
);
180 release
= atof(optarg
);
190 sprintf(alsa_client_name
, "%s_%d", CLIENT_NAME_BASE
, pid
);
191 sprintf(jack_client_name
, "%s_%d", CLIENT_NAME_BASE
, pid
);
195 sprintf(alsa_client_name
, "%s_%s", CLIENT_NAME_BASE
, optarg
);
196 sprintf(jack_client_name
, "%s_%s", CLIENT_NAME_BASE
, optarg
);
199 sprintf(alsa_client_name
, "%s", CLIENT_NAME_BASE
);
200 sprintf(jack_client_name
, "%s", CLIENT_NAME_BASE
);
214 flags
= LASH_Config_Data_Set
;
216 flags
|= LASH_Terminal
;
220 lash_init(lash_args
, "LASH Synth", flags
, LASH_PROTOCOL(2, 0));
223 fprintf(stderr
, "%s: could not initialise lash\n", __FUNCTION__
);
227 if (lash_enabled(lash_client
)) {
228 event
= lash_event_new_with_type(LASH_Client_Name
);
229 lash_event_set_string(event
, alsa_client_name
);
230 lash_send_event(lash_client
, event
);
233 pthread_create(&interface_thread
, NULL
, interface_main
, NULL
);
235 pthread_create(&lash_thread
, NULL
, lash_thread_main
, NULL
);