2 Calf Box, an open source musical instrument.
3 Copyright (C) 2010 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/>.
25 #include <jack/jack.h>
33 struct cbox_io_callbacks
;
34 struct cbox_recording_source
;
36 struct cbox_midi_buffer
;
39 struct cbox_open_params
47 int (*getsampleratefunc
)(struct cbox_io_impl
*ioi
);
48 gboolean (*startfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
49 gboolean (*stopfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
50 gboolean (*cyclefunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
51 gboolean (*getstatusfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
52 void (*pollfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
);
53 int (*getmidifunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_buffer
*destination
);
54 struct cbox_midi_output
*(*createmidioutfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
55 void (*destroymidioutfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_output
*midiout
);
56 struct cbox_midi_input
*(*createmidiinfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
57 void (*destroymidiinfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_input
*midiout
);
58 void (*updatemidiinroutingfunc
)(struct cbox_io_impl
*ioi
);
59 void (*controltransportfunc
)(struct cbox_io_impl
*ioi
, gboolean roll
, uint32_t pos
); // (uint32_t)-1 if no change
60 gboolean (*getsynccompletedfunc
)(struct cbox_io_impl
*ioi
);
61 void (*destroyfunc
)(struct cbox_io_impl
*ioi
);
66 struct cbox_io_impl
*impl
;
67 struct cbox_command_target cmd_target
;
69 float **input_buffers
; // only valid inside jack_rt_process
70 float **output_buffers
; // only valid inside jack_rt_process
71 struct cbox_io_env io_env
;
73 struct cbox_io_callbacks
*cb
;
78 enum cbox_transport_state
86 struct cbox_io_callbacks
90 void (*process
)(void *user_data
, struct cbox_io
*io
, uint32_t nframes
);
91 void (*on_started
)(void *user_data
);
92 void (*on_stopped
)(void *user_data
);
93 void (*on_disconnected
)(void *user_data
);
94 void (*on_reconnected
)(void *user_data
);
95 void (*on_midi_inputs_changed
)(void *user_data
);
96 void (*on_midi_outputs_changed
)(void *user_data
);
97 gboolean (*on_transport_sync
)(void *user_data
, enum cbox_transport_state state
, uint32_t frame
);
100 struct cbox_midi_input
103 struct cbox_uuid uuid
;
104 struct cbox_midi_buffer buffer
;
107 struct cbox_uuid output
;
108 gboolean enable_appsink
;
109 struct cbox_midi_appsink appsink
;
112 struct cbox_midi_output
115 struct cbox_uuid uuid
;
116 struct cbox_midi_buffer buffer
;
117 struct cbox_midi_merger merger
;
118 // This is set if the output is in process of being removed and should not
119 // be used for output.
123 extern gboolean
cbox_io_init(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
125 extern gboolean
cbox_io_init_jack(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
127 extern gboolean
cbox_io_init_usb(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
129 extern int cbox_io_start(struct cbox_io
*io
, struct cbox_io_callbacks
*cb
, struct cbox_command_target
*fb
);
130 extern int cbox_io_stop(struct cbox_io
*io
);
131 extern int cbox_io_get_sample_rate(struct cbox_io
*io
);
132 extern int cbox_io_get_midi_data(struct cbox_io
*io
, struct cbox_midi_buffer
*destination
);
133 extern gboolean
cbox_io_get_disconnect_status(struct cbox_io
*io
, GError
**error
);
134 extern gboolean
cbox_io_cycle(struct cbox_io
*io
, struct cbox_command_target
*fb
, GError
**error
);
135 extern void cbox_io_poll_ports(struct cbox_io
*io
, struct cbox_command_target
*fb
);
136 extern struct cbox_midi_input
*cbox_io_get_midi_input(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
137 extern struct cbox_midi_output
*cbox_io_get_midi_output(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
138 extern struct cbox_midi_output
*cbox_io_create_midi_output(struct cbox_io
*io
, const char *name
, GError
**error
);
139 extern void cbox_io_destroy_midi_output(struct cbox_io
*io
, struct cbox_midi_output
*midiout
);
140 extern struct cbox_midi_input
*cbox_io_create_midi_input(struct cbox_io
*io
, const char *name
, GError
**error
);
141 extern void cbox_io_destroy_midi_input(struct cbox_io
*io
, struct cbox_midi_input
*midiin
);
142 extern void cbox_io_destroy_all_midi_ports(struct cbox_io
*io
);
143 extern gboolean
cbox_io_process_cmd(struct cbox_io
*io
, struct cbox_command_target
*fb
, struct cbox_osc_command
*cmd
, GError
**error
, gboolean
*cmd_handled
);
144 extern void cbox_io_close(struct cbox_io
*io
);
146 extern const char *cbox_io_section
;