Use linked list for storing sources in MIDI merger.
[calfbox.git] / skel.c
blob23b7a3a71e43873bd9ec7018519525c1f3574448
1 /*
2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2011 Krzysztof Foltman
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #include "config.h"
20 #include "config-api.h"
21 #include "dspmath.h"
22 #include "module.h"
23 #include <glib.h>
24 #include <malloc.h>
25 #include <math.h>
26 #include <memory.h>
27 #include <sndfile.h>
28 #include <stdio.h>
29 #include <stdlib.h>
31 #define MODULE_PARAMS {name}_params
33 struct {name}_params
37 struct {name}_module
39 struct cbox_module module;
41 struct {name}_params *params, *old_params;
44 gboolean {name}_process_cmd(struct cbox_command_target *ct, struct cbox_command_target *fb, struct cbox_osc_command *cmd, GError **error)
46 struct {name}_module *m = (struct {name}_module *)ct->user_data;
48 // EFFECT_PARAM("/wet_dry", "f", wet_dry, double, , 0, 1) else
49 if (!strcmp(cmd->command, "/status") && !strcmp(cmd->arg_types, ""))
51 if (!cbox_check_fb_channel(fb, cmd->command, error))
52 return FALSE;
53 // return cbox_execute_on(fb, NULL, "/wet_dry", "f", error, m->params->wet_dry);
54 return CBOX_OBJECT_DEFAULT_STATUS(&m->module, fb, error);
56 else
57 return cbox_object_default_process_cmd(ct, fb, cmd, error);
58 return TRUE;
61 void {name}_process_event(struct cbox_module *module, const uint8_t *data, uint32_t len)
63 struct {name}_module *m = module->user_data;
66 void {name}_process_block(struct cbox_module *module, cbox_sample_t **inputs, cbox_sample_t **outputs)
68 struct {name}_module *m = module->user_data;
70 if (m->params != m->old_params)
72 // update calculated values
76 MODULE_SIMPLE_DESTROY_FUNCTION({name})
78 MODULE_CREATE_FUNCTION({name})
80 static int inited = 0;
81 if (!inited)
83 inited = 1;
86 struct {name}_module *m = malloc(sizeof(struct {name}_module));
87 CALL_MODULE_INIT(&m->module, m, 0, 2, {name}_process_cmd);
88 m->module.process_event = {name}_process_event;
89 m->module.process_block = {name}_process_block;
90 struct {name}_params *p = malloc(sizeof(struct {name}_params));
91 m->params = p;
92 m->old_params = NULL;
94 return &m->module;
98 struct cbox_module_keyrange_metadata {name}_keyranges[] = {
101 struct cbox_module_livecontroller_metadata {name}_controllers[] = {
104 DEFINE_MODULE({name}, 0, 2)