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>
30 struct cbox_io_callbacks
;
31 struct cbox_recording_source
;
33 struct cbox_midi_buffer
;
36 struct cbox_open_params
44 int (*getsampleratefunc
)(struct cbox_io_impl
*ioi
);
45 gboolean (*startfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
46 gboolean (*stopfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
47 gboolean (*cyclefunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
, GError
**error
);
48 gboolean (*getstatusfunc
)(struct cbox_io_impl
*ioi
, GError
**error
);
49 void (*pollfunc
)(struct cbox_io_impl
*ioi
, struct cbox_command_target
*fb
);
50 int (*getmidifunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_buffer
*destination
);
51 struct cbox_midi_output
*(*createmidioutfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
52 void (*destroymidioutfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_output
*midiout
);
53 struct cbox_midi_input
*(*createmidiinfunc
)(struct cbox_io_impl
*ioi
, const char *name
, GError
**error
);
54 void (*destroymidiinfunc
)(struct cbox_io_impl
*ioi
, struct cbox_midi_input
*midiout
);
55 void (*destroyfunc
)(struct cbox_io_impl
*ioi
);
60 struct cbox_io_impl
*impl
;
61 struct cbox_command_target cmd_target
;
64 float **input_buffers
; // only valid inside jack_rt_process
66 float **output_buffers
; // only valid inside jack_rt_process
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_disconnected
)(void *user_data
);
80 void (*on_reconnected
)(void *user_data
);
81 void (*on_midi_inputs_changed
)(void *user_data
);
82 void (*on_midi_outputs_changed
)(void *user_data
);
85 struct cbox_midi_input
88 struct cbox_uuid uuid
;
89 struct cbox_midi_buffer buffer
;
93 struct cbox_midi_output
96 struct cbox_uuid uuid
;
97 struct cbox_midi_buffer buffer
;
98 struct cbox_midi_merger merger
;
99 // This is set if the output is in process of being removed and should not
100 // be used for output.
104 extern gboolean
cbox_io_init(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
105 extern gboolean
cbox_io_init_jack(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
106 extern gboolean
cbox_io_init_usb(struct cbox_io
*io
, struct cbox_open_params
*const params
, struct cbox_command_target
*fb
, GError
**error
);
108 extern int cbox_io_start(struct cbox_io
*io
, struct cbox_io_callbacks
*cb
, struct cbox_command_target
*fb
);
109 extern int cbox_io_stop(struct cbox_io
*io
);
110 extern int cbox_io_get_sample_rate(struct cbox_io
*io
);
111 static inline int cbox_io_get_buffer_size(struct cbox_io
*io
)
113 return io
->buffer_size
;
115 extern int cbox_io_get_midi_data(struct cbox_io
*io
, struct cbox_midi_buffer
*destination
);
116 extern gboolean
cbox_io_get_disconnect_status(struct cbox_io
*io
, GError
**error
);
117 extern gboolean
cbox_io_cycle(struct cbox_io
*io
, struct cbox_command_target
*fb
, GError
**error
);
118 extern void cbox_io_poll_ports(struct cbox_io
*io
, struct cbox_command_target
*fb
);
119 extern struct cbox_midi_input
*cbox_io_get_midi_input(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
120 extern struct cbox_midi_output
*cbox_io_get_midi_output(struct cbox_io
*io
, const char *name
, const struct cbox_uuid
*uuid
);
121 extern struct cbox_midi_output
*cbox_io_create_midi_output(struct cbox_io
*io
, const char *name
, GError
**error
);
122 extern void cbox_io_destroy_midi_output(struct cbox_io
*io
, struct cbox_midi_output
*midiout
);
123 extern struct cbox_midi_input
*cbox_io_create_midi_input(struct cbox_io
*io
, const char *name
, GError
**error
);
124 extern void cbox_io_destroy_midi_input(struct cbox_io
*io
, struct cbox_midi_input
*midiin
);
125 extern void cbox_io_destroy_all_midi_ports(struct cbox_io
*io
);
126 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
);
127 extern void cbox_io_close(struct cbox_io
*io
);
129 extern const char *cbox_io_section
;