Fix crash bug in sampler_api_example.py
[calfbox.git] / master.h
blobb577a57629330450bd58888720c3b152245eb8b5
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 #ifndef CBOX_MASTER_H
20 #define CBOX_MASTER_H
22 #include <stdint.h>
23 #include "cmd.h"
25 #define PPQN 48
27 struct cbox_song;
28 struct cbox_rt;
30 enum cbox_master_transport_state
32 CMTS_STOP,
33 CMTS_ROLLING,
34 CMTS_STOPPING,
37 struct cbox_master
39 int srate;
40 float tempo, new_tempo;
41 int timesig_nom;
42 int timesig_denom; // must be 4 for now
43 enum cbox_master_transport_state state;
44 struct cbox_rt *rt;
45 struct cbox_song *song;
46 struct cbox_song_playback *spb;
47 struct cbox_command_target cmd_target;
50 struct cbox_bbt
52 int bar;
53 int beat;
54 int tick;
57 extern struct cbox_master *cbox_master_new(struct cbox_rt *rt);
58 extern void cbox_master_set_sample_rate(struct cbox_master *master, int srate);
59 extern void cbox_master_set_tempo(struct cbox_master *master, float tempo);
60 extern void cbox_master_set_timesig(struct cbox_master *master, int beats, int unit);
61 //extern void cbox_master_to_bbt(const struct cbox_master *master, struct cbox_bbt *bbt, int time_samples);
62 //extern uint32_t cbox_master_song_pos_from_bbt(struct cbox_master *master, const struct cbox_bbt *bbt);
63 extern void cbox_master_play(struct cbox_master *master);
64 extern void cbox_master_stop(struct cbox_master *master);
65 extern void cbox_master_panic(struct cbox_master *master);
66 extern void cbox_master_seek_ppqn(struct cbox_master *master, uint32_t pos_ppqn);
67 extern void cbox_master_seek_samples(struct cbox_master *master, uint32_t pos_samples);
68 extern void cbox_master_destroy(struct cbox_master *master);
70 int cbox_master_ppqn_to_samples(struct cbox_master *master, int time_ppqn);
71 int cbox_master_samples_to_ppqn(struct cbox_master *master, int time_samples);
73 #endif