In case of running out of prefetch pipes, truncate the sample to the preloaded part.
[calfbox.git] / master.h
bloba44ef8164a58479326f1c21d30ea182f1e6a74f8
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 extern uint64_t PPQN;
27 struct cbox_song;
28 struct cbox_rt;
30 #define GET_RT_FROM_cbox_master(ptr) ((ptr)->engine->rt)
32 enum cbox_master_transport_state
34 CMTS_STOP,
35 CMTS_ROLLING,
36 CMTS_STOPPING,
39 struct cbox_master
41 int srate;
42 float tempo, new_tempo;
43 int timesig_nom;
44 int timesig_denom; // must be 4 for now
45 uint64_t ppqn_factor;
46 enum cbox_master_transport_state state;
47 struct cbox_engine *engine;
48 struct cbox_song *song;
49 struct cbox_song_playback *spb;
50 struct cbox_command_target cmd_target;
53 struct cbox_bbt
55 int bar;
56 int beat;
57 int tick;
60 extern struct cbox_master *cbox_master_new(struct cbox_engine *engine);
61 extern void cbox_master_set_sample_rate(struct cbox_master *master, int srate);
62 extern void cbox_master_set_tempo(struct cbox_master *master, float tempo);
63 extern void cbox_master_set_timesig(struct cbox_master *master, int beats, int unit);
64 //extern void cbox_master_to_bbt(const struct cbox_master *master, struct cbox_bbt *bbt, int time_samples);
65 //extern uint32_t cbox_master_song_pos_from_bbt(struct cbox_master *master, const struct cbox_bbt *bbt);
66 extern void cbox_master_play(struct cbox_master *master);
67 extern void cbox_master_stop(struct cbox_master *master);
68 extern void cbox_master_panic(struct cbox_master *master);
69 extern void cbox_master_seek_ppqn(struct cbox_master *master, uint32_t pos_ppqn);
70 extern void cbox_master_seek_samples(struct cbox_master *master, uint32_t pos_samples);
71 extern void cbox_master_destroy(struct cbox_master *master);
73 int cbox_master_ppqn_to_samples(struct cbox_master *master, int time_ppqn);
74 int cbox_master_samples_to_ppqn(struct cbox_master *master, int time_samples);
76 #endif