missing commit in generator.h
[galan.git] / plugins / libTEMPLATE.c
blob4ddfcdbec660fef9764f00735a281a6de134ec4a
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 /* Template gAlan plugin file. Please distribute your plugins according to
20 the GNU General Public License! (You don't have to, but I'd prefer it.) */
22 #include <stdlib.h>
23 #include <string.h>
24 #include <stdio.h>
25 #include <stddef.h>
27 #include <gdk/gdk.h>
28 #include <gtk/gtk.h>
29 #include <gmodule.h>
31 #include "global.h"
32 #include "generator.h"
33 #include "comp.h"
34 #include "control.h"
35 #include "gencomp.h"
37 #define GENERATOR_CLASS_NAME "template"
38 #define GENERATOR_CLASS_PATH "Misc/Template Plugin"
39 #define GENERATOR_CLASS_PIXMAP "template.xpm"
41 #define SIG_INPUT 0
42 #define SIG_OUTPUT 0
44 #define EVT_INPUT 0
45 #define NUM_EVENT_INPUTS 1
47 #define EVT_OUTPUT 0
48 #define NUM_EVENT_OUTPUTS 1
50 typedef struct Data {
51 int dummy;
52 } Data;
54 PRIVATE void setup_tables(void) {
55 /* Put any plugin-wide initialisation here. */
58 PRIVATE gboolean init_instance(Generator *g) {
59 Data *data = safe_malloc(sizeof(Data));
60 g->data = data;
62 data->dummy = 0;
64 return TRUE;
67 PRIVATE void destroy_instance(Generator *g) {
68 free(g->data);
71 PRIVATE void unpickle_instance(Generator *g, ObjectStoreItem *item, ObjectStore *db) {
72 Data *data = safe_malloc(sizeof(Data));
73 g->data = data;
75 data->dummy = objectstore_item_get_integer(item, "TEMPLATE_dummy", 123456);
78 PRIVATE void pickle_instance(Generator *g, ObjectStoreItem *item, ObjectStore *db) {
79 Data *data = g->data;
80 objectstore_item_set_integer(item, "TEMPLATE_dummy", data->dummy);
83 PRIVATE gboolean output_generator(Generator *g, SAMPLE *buf, int buflen) {
84 Data *data = g->data;
86 memset(buf, 0, buflen * sizeof(SAMPLE));
87 return FALSE;
90 PRIVATE void evt_input_handler(Generator *g, AEvent *event) {
91 /* handle incoming events on queue EVT_INPUT */
94 PRIVATE InputSignalDescriptor input_sigs[] = {
95 { "Input", SIG_FLAG_REALTIME },
96 { NULL, }
99 PRIVATE OutputSignalDescriptor output_sigs[] = {
100 { "Output", SIG_FLAG_REALTIME, { output_generator, } },
101 { NULL, }
104 PRIVATE ControlDescriptor controls[] = {
105 /* { kind, name, min,max,step,page, size,editable, is_dst,queue_number,
106 init,destroy,refresh,refresh_data }, */
107 { CONTROL_KIND_NONE, }
110 PRIVATE void setup_class(void) {
111 GeneratorClass *k = gen_new_generatorclass(GENERATOR_CLASS_NAME, FALSE,
112 NUM_EVENT_INPUTS, NUM_EVENT_OUTPUTS,
113 input_sigs, output_sigs, controls,
114 init_instance, destroy_instance,
115 unpickle_instance, pickle_instance);
117 gen_configure_event_input(k, EVT_INPUT, "Input", evt_input_handler);
118 gen_configure_event_output(k, EVT_OUTPUT, "Output");
120 gencomp_register_generatorclass(k, FALSE, GENERATOR_CLASS_PATH,
121 PIXMAPDIRIFY(GENERATOR_CLASS_PIXMAP),
122 NULL);
125 PUBLIC void init_plugin(void) {
126 setup_tables();
127 setup_class();