make midimap obey channels
[galan.git] / plugins / libvca.c
blob88806078a6e2a6cb4e965d37e236823f53ae989d
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 GENERATOR_CLASS_NAME "vca"
33 #define GENERATOR_CLASS_PATH "Levels/Envelope Gain"
35 #define SIG_ENVELOPE 0
36 #define SIG_INPUT 1
38 #define SIG_OUTPUT 0
40 PRIVATE gboolean output_generator(Generator *g, SAMPLE *buf, int buflen) {
41 SAMPLE tmpbuf[MAXIMUM_REALTIME_STEP];
42 int i;
44 if (!gen_read_realtime_input(g, SIG_ENVELOPE, -1, tmpbuf, buflen) ||
45 !gen_read_realtime_input(g, SIG_INPUT, -1, buf, buflen))
46 return FALSE;
48 for (i = 0; i < buflen; i++)
49 buf[i] *= tmpbuf[i];
50 return TRUE;
53 PRIVATE InputSignalDescriptor input_sigs[] = {
54 { "Envelope", SIG_FLAG_REALTIME },
55 { "Input", SIG_FLAG_REALTIME },
56 { NULL, }
59 PRIVATE OutputSignalDescriptor output_sigs[] = {
60 { "Output", SIG_FLAG_REALTIME, { output_generator, } },
61 { NULL, }
64 PRIVATE void setup_class(void) {
65 GeneratorClass *k = gen_new_generatorclass(GENERATOR_CLASS_NAME, FALSE, 0, 0,
66 input_sigs, output_sigs, NULL,
67 NULL, NULL, NULL, NULL);
69 gencomp_register_generatorclass(k, FALSE, GENERATOR_CLASS_PATH, NULL, NULL);
72 PUBLIC void init_plugin(void) {
73 setup_class();