Merge pull request #1 from atsampson/master
[calfbox.git] / sampler_prg.h
blob076d55cf92ef8352a8074614a594f79f5d5b2223
1 /*
2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010-2013 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 #ifndef CBOX_SAMPLER_PRG_H
20 #define CBOX_SAMPLER_PRG_H
22 #include "cmd.h"
23 #include "dom.h"
25 struct cbox_tarfile;
26 struct sampler_channel;
28 CBOX_EXTERN_CLASS(sampler_program)
30 // Runtime layer lists; in future, I might something more clever, like a tree
31 struct sampler_rll
33 GSList *layers; // of sampler_layer
34 GSList *layers_release; // of sampler_layer
35 GSList *layers_oncc;
36 uint32_t cc_trigger_bitmask[4]; // one bit per CC
39 struct sampler_ctrlinit
41 uint8_t controller;
42 uint8_t value;
45 union sampler_ctrlinit_union {
46 gpointer ptr;
47 struct sampler_ctrlinit cinit;
51 struct sampler_program
53 CBOX_OBJECT_HEADER()
54 struct cbox_command_target cmd_target;
56 struct sampler_module *module;
57 gchar *name;
58 int prog_no;
59 struct sampler_layer *default_group;
60 GSList *groups;
61 GSList *all_layers;
62 GSList *ctrl_init_list;
63 struct sampler_rll *rll;
64 gchar *sample_dir; // can be empty, cannot be NULL
65 gchar *source_file; // can be empty, cannot be NULL
66 int in_use;
67 struct cbox_tarfile *tarfile;
68 gboolean deleting;
71 extern struct sampler_rll *sampler_rll_new_from_program(struct sampler_program *prg);
72 extern void sampler_rll_destroy(struct sampler_rll *rll);
74 extern GSList *sampler_program_get_next_layer(struct sampler_program *prg, struct sampler_channel *c, GSList *next_layer, int note, int vel, float random, gboolean is_first);
75 extern struct sampler_program *sampler_program_new(struct sampler_module *m, int prog_no, const char *name, struct cbox_tarfile *tarfile, const char *sample_dir, GError **error);
76 extern struct sampler_program *sampler_program_new_from_cfg(struct sampler_module *m, const char *cfg_section, const char *name, int pgm_id, GError **error);
77 extern void sampler_program_add_layer(struct sampler_program *prg, struct sampler_layer *l);
78 extern void sampler_program_delete_layer(struct sampler_program *prg, struct sampler_layer *l);
79 extern void sampler_program_add_group(struct sampler_program *prg, struct sampler_layer *l);
80 extern void sampler_program_add_controller_init(struct sampler_program *prg, uint8_t controller, uint8_t value);
81 extern void sampler_program_remove_controller_init(struct sampler_program *prg, uint8_t controller, int which);
82 extern void sampler_program_update_layers(struct sampler_program *prg);
83 extern struct sampler_program *sampler_program_clone(struct sampler_program *prg, struct sampler_module *m, int prog_no, GError **error);
85 #endif