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/>.
24 extern gboolean
cbox_scene_insert_aux_bus(struct cbox_scene
*scene
, struct cbox_aux_bus
*aux_bus
);
25 extern void cbox_scene_remove_aux_bus(struct cbox_scene
*scene
, struct cbox_aux_bus
*bus
);
27 CBOX_CLASS_DEFINITION_ROOT(cbox_aux_bus
)
29 static gboolean
cbox_aux_bus_process_cmd(struct cbox_command_target
*ct
, struct cbox_command_target
*fb
, struct cbox_osc_command
*cmd
, GError
**error
)
31 struct cbox_aux_bus
*aux_bus
= ct
->user_data
;
32 struct cbox_rt
*rt
= (struct cbox_rt
*)cbox_document_get_service(CBOX_GET_DOCUMENT(aux_bus
), "rt");
33 if (!strcmp(cmd
->command
, "/status") && !strcmp(cmd
->arg_types
, ""))
35 if (!cbox_check_fb_channel(fb
, cmd
->command
, error
))
38 return cbox_execute_on(fb
, NULL
, "/name", "s", error
, aux_bus
->name
) &&
39 CBOX_OBJECT_DEFAULT_STATUS(aux_bus
, fb
, error
);
42 if (!strncmp(cmd
->command
, "/slot/", 6))
44 return cbox_module_slot_process_cmd(&aux_bus
->module
, fb
, cmd
, cmd
->command
+ 5, CBOX_GET_DOCUMENT(aux_bus
), rt
, aux_bus
->owner
->engine
, error
);
47 return cbox_object_default_process_cmd(ct
, fb
, cmd
, error
);
50 struct cbox_aux_bus
*cbox_aux_bus_load(struct cbox_scene
*scene
, const char *name
, struct cbox_rt
*rt
, GError
**error
)
52 struct cbox_module
*module
= cbox_module_new_from_fx_preset(name
, CBOX_GET_DOCUMENT(scene
), rt
, scene
->engine
, error
);
56 struct cbox_aux_bus
*p
= malloc(sizeof(struct cbox_aux_bus
));
57 CBOX_OBJECT_HEADER_INIT(p
, cbox_aux_bus
, CBOX_GET_DOCUMENT(scene
));
58 cbox_command_target_init(&p
->cmd_target
, cbox_aux_bus_process_cmd
, p
);
59 p
->name
= g_strdup(name
);
63 // XXXKF this work up to buffer size of 8192 floats, this should be determined from JACK settings and updated when
64 // JACK buffer size changes
65 p
->input_bufs
[0] = malloc(8192 * sizeof(float));
66 p
->input_bufs
[1] = malloc(8192 * sizeof(float));
67 p
->output_bufs
[0] = malloc(8192 * sizeof(float));
68 p
->output_bufs
[1] = malloc(8192 * sizeof(float));
69 CBOX_OBJECT_REGISTER(p
);
70 cbox_scene_insert_aux_bus(scene
, p
);
75 void cbox_aux_bus_ref(struct cbox_aux_bus
*bus
)
80 void cbox_aux_bus_unref(struct cbox_aux_bus
*bus
)
82 assert(bus
->refcount
> 0);
86 void cbox_aux_bus_destroyfunc(struct cbox_objhdr
*objhdr
)
88 struct cbox_aux_bus
*bus
= CBOX_H2O(objhdr
);
91 cbox_scene_remove_aux_bus(bus
->owner
, bus
);
94 CBOX_DELETE(bus
->module
);
96 assert(!bus
->refcount
);
98 free(bus
->input_bufs
[0]);
99 free(bus
->input_bufs
[1]);