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/>.
23 #include <jack/jack.h>
24 #include <jack/ringbuffer.h>
31 struct cbox_io_callbacks
;
32 struct cbox_recording_source
;
34 struct cbox_midi_buffer
;
37 struct cbox_open_params
45 int (*getsampleratefunc
)(struct cbox_io_impl
*ioi
);
46 gboolean (*startfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
47 gboolean (*stopfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
48 gboolean (*cyclefunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
49 gboolean (*getstatusfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
50 void (*pollfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
);
51 int (*getmidifunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_buffer
*destination
);
52 struct cbox_midi_output
*(*createmidioutfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
53 void (*destroymidioutfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_output
*midiout
);
54 struct cbox_midi_input
*(*createmidiinfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
55 void (*destroymidiinfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_input
*midiout
);
56 void (*updatemidiinroutingfunc
)(struct cbox_io_impl
*ioi
);
57 void (*destroyfunc
)(struct cbox_io_impl
*ioi
);
62 struct cbox_io_impl
*impl
;
63 struct cbox_command_target cmd_target
;
65 float **input_buffers
; // only valid inside jack_rt_process
66 float **output_buffers
; // only valid inside jack_rt_process
67 struct cbox_io_env io_env
;
69 struct cbox_io_callbacks
*cb
;
74 struct cbox_io_callbacks
78 void (*process
)(void *user_data
, struct cbox_io
*io
, uint32_t nframes
);
79 void (*on_started
)(void *user_data
);
80 void (*on_stopped
)(void *user_data
);
81 void (*on_disconnected
)(void *user_data
);
82 void (*on_reconnected
)(void *user_data
);
83 void (*on_midi_inputs_changed
)(void *user_data
);
84 void (*on_midi_outputs_changed
)(void *user_data
);
87 struct cbox_midi_input
90 struct cbox_uuid uuid
;
91 struct cbox_midi_buffer buffer
;
94 struct cbox_uuid output
;
95 gboolean enable_appsink
;
96 struct cbox_midi_appsink appsink
;
99 struct cbox_midi_output
102 struct cbox_uuid uuid
;
103 struct cbox_midi_buffer buffer
;
104 struct cbox_midi_merger merger
;
105 // This is set if the output is in process of being removed and should not
106 // be used for output.
110 extern gboolean
cbox_io_init(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
111 extern gboolean
cbox_io_init_jack(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
112 extern gboolean
cbox_io_init_usb(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
114 extern int cbox_io_start(struct cbox_io
*io
, struct cbox_io_callbacks
*cb
, struct cbox_command_target
*fb
);
115 extern int cbox_io_stop(struct cbox_io
*io
);
116 extern int cbox_io_get_sample_rate(struct cbox_io
*io
);
117 extern int cbox_io_get_midi_data(struct cbox_io
*io
, struct cbox_midi_buffer
*destination
);
118 extern gboolean
cbox_io_get_disconnect_status(struct cbox_io
*io
, GError
**error
);
119 extern gboolean
cbox_io_cycle(struct cbox_io
*io
, struct cbox_command_target
*fb
, GError
**error
);
120 extern void cbox_io_poll_ports(struct cbox_io
*io
, struct cbox_command_target
*fb
);
121 extern struct cbox_midi_input
*cbox_io_get_midi_input(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
122 extern struct cbox_midi_output
*cbox_io_get_midi_output(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
123 extern struct cbox_midi_output
*cbox_io_create_midi_output(struct cbox_io
*io
, const char *name
, GError
**error
);
124 extern void cbox_io_destroy_midi_output(struct cbox_io
*io
, struct cbox_midi_output
*midiout
);
125 extern struct cbox_midi_input
*cbox_io_create_midi_input(struct cbox_io
*io
, const char *name
, GError
**error
);
126 extern void cbox_io_destroy_midi_input(struct cbox_io
*io
, struct cbox_midi_input
*midiin
);
127 extern void cbox_io_destroy_all_midi_ports(struct cbox_io
*io
);
128 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
);
129 extern void cbox_io_close(struct cbox_io
*io
);
131 extern const char *cbox_io_section
;