fix rules for optional plugins.
[galan.git] / plugins / libsig2evt.c
blobbad8b6df75a421f85d3abaa1b6889fbea58571e5
1 /* gAlan - Graphical Audio Language
2 * Copyright (C) 1999 Tony Garnock-Jones
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #include <stdlib.h>
20 #include <string.h>
21 #include <stdio.h>
23 #include <gdk/gdk.h>
24 #include <gtk/gtk.h>
26 #include "global.h"
27 #include "generator.h"
28 #include "comp.h"
29 #include "control.h"
30 #include "gencomp.h"
32 #define SIG_INPUT 0
33 #define EVT_TRIGGER 0
34 #define EVT_OUTPUT 0
36 PRIVATE void evt_trigger_handler(Generator *g, AEvent *event) {
37 SAMPLE buffer;
38 SAMPLETIME now = event->time;
40 if (!gen_read_realtime_input(g, SIG_INPUT, 0, &buffer, 1))
41 buffer = 0;
43 gen_init_aevent(event, AE_NUMBER, NULL, 0, NULL, 0, now);
44 event->d.number = buffer;
45 gen_send_events(g, EVT_OUTPUT, -1, event);
48 PRIVATE void handle_time(Generator *g, AEvent *event) {
49 SAMPLE buf[MAXIMUM_REALTIME_STEP];
51 if (event->kind == AE_REALTIME)
52 gen_read_realtime_input(g, SIG_INPUT, 0, buf, event->d.integer);
55 PRIVATE gboolean init_instance(Generator *g) {
56 gen_register_realtime_fn(g, handle_time);
57 return TRUE;
60 PRIVATE void done_instance(Generator *g) {
61 gen_deregister_realtime_fn(g, handle_time);
64 PRIVATE InputSignalDescriptor input_sigs[] = {
65 { "Input", SIG_FLAG_REALTIME },
66 { NULL, }
69 PRIVATE void setup_class(void) {
70 GeneratorClass *k = gen_new_generatorclass("sig2evt", FALSE, 1, 1,
71 input_sigs, NULL, NULL,
72 init_instance, done_instance,
73 (AGenerator_pickle_t) init_instance, NULL);
75 gen_configure_event_input(k, EVT_TRIGGER, "Trigger", evt_trigger_handler);
76 gen_configure_event_output(k, EVT_OUTPUT, "Output");
78 gencomp_register_generatorclass(k, FALSE, "Misc/Signal-to-event Converter", NULL, NULL);
81 PUBLIC void init_plugin(void) {
82 setup_class();