1 /* GSequencer - Advanced GTK Sequencer 2 * Copyright (C) 2005-2020 Joël Krähemann 3 * 4 * This file is part of GSequencer. 5 * 6 * GSequencer is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * GSequencer is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with GSequencer. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __AGS_MACHINE_H__ 21 #define __AGS_MACHINE_H__ 22 23 #include <glib.h> 24 #include <glib-object.h> 25 26 #include <gtk/gtk.h> 27 28 #include <ags/libags.h> 29 #include <ags/libags-audio.h> 30 31 #include <ags/libags-gui.h> 32 33 G_BEGIN_DECLS 34 35 #define AGS_TYPE_MACHINE (ags_machine_get_type()) 36 #define AGS_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), AGS_TYPE_MACHINE, AgsMachine)) 37 #define AGS_MACHINE_CLASS(class) (G_TYPE_CHECK_CLASS_CAST((class), AGS_TYPE_MACHINE, AgsMachineClass)) 38 #define AGS_IS_MACHINE(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), AGS_TYPE_MACHINE)) 39 #define AGS_IS_MACHINE_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE((class), AGS_TYPE_MACHINE)) 40 #define AGS_MACHINE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), AGS_TYPE_MACHINE, AgsMachineClass)) 41 42 #define AGS_MACHINE_AUTOMATION_PORT(ptr) ((AgsMachineAutomationPort *)(ptr)) 43 44 #define AGS_MACHINE_DEFAULT_VERSION "2.1.60" 45 #define AGS_MACHINE_DEFAULT_BUILD_ID "Wed Feb 20 18:38:17 UTC 2019" 46 47 typedef struct _AgsMachine AgsMachine; 48 typedef struct _AgsMachineClass AgsMachineClass; 49 typedef struct _AgsMachineAutomationPort AgsMachineAutomationPort; 50 51 typedef enum{ 52 AGS_MACHINE_SOLO = 1, 53 AGS_MACHINE_IS_EFFECT = 1 << 1, 54 AGS_MACHINE_IS_SEQUENCER = 1 << 2, 55 AGS_MACHINE_IS_SYNTHESIZER = 1 << 3, 56 AGS_MACHINE_IS_WAVE_PLAYER = 1 << 4, 57 AGS_MACHINE_TAKES_FILE_INPUT = 1 << 5, 58 AGS_MACHINE_MAPPED_RECALL = 1 << 6, 59 AGS_MACHINE_PREMAPPED_RECALL = 1 << 7, 60 AGS_MACHINE_BLOCK_PLAY = 1 << 8, 61 AGS_MACHINE_BLOCK_STOP = 1 << 9, 62 AGS_MACHINE_BLOCK_STOP_CALLBACK = 1 << 10, 63 AGS_MACHINE_CONNECTED = 1 << 11, 64 AGS_MACHINE_REVERSE_NOTATION = 1 << 12, 65 AGS_MACHINE_STICKY_CONTROLS = 1 << 13, 66 }AgsMachineFlags; 67 68 typedef enum{ 69 AGS_MACHINE_ACCEPT_WAV = 1, 70 AGS_MACHINE_ACCEPT_OGG = 1 << 1, 71 AGS_MACHINE_ACCEPT_SOUNDFONT2 = 1 << 2, 72 AGS_MACHINE_ACCEPT_SFZ = 1 << 3, 73 }AgsMachineFileInputFlags; 74 75 typedef enum{ 76 AGS_MACHINE_MONO = 1, 77 AGS_MACHINE_DISABLE_LINE_MEMBER = 1 << 1, 78 AGS_MACHINE_DISABLE_BULK_MEMBER = 1 << 2, 79 }AgsMachineMappingFlags; 80 81 typedef enum{ 82 AGS_MACHINE_POPUP_COPY_PATTERN = 1, 83 AGS_MACHINE_POPUP_PASTE_PATTERN = 1 << 1, 84 AGS_MACHINE_POPUP_ENVELOPE = 1 << 2, 85 }AgsMachineEditOptions; 86 87 typedef enum{ 88 AGS_MACHINE_POPUP_CONNECTION_EDITOR = 1, 89 AGS_MACHINE_SHOW_AUDIO_OUTPUT_CONNECTION = 1 << 1, 90 AGS_MACHINE_SHOW_AUDIO_INPUT_CONNECTION = 1 << 2, 91 AGS_MACHINE_POPUP_MIDI_DIALOG = 1 << 3, 92 AGS_MACHINE_SHOW_MIDI_INPUT = 1 << 4, 93 AGS_MACHINE_SHOW_MIDI_OUTPUT = 1 << 5, 94 }AgsMachineConnectionOptions; 95 96 typedef enum{ 97 AGS_MACHINE_POPUP_MIDI_EXPORT = 1, 98 AGS_MACHINE_POPUP_WAVE_EXPORT = 1 << 1, 99 }AgsMachineExportOptions; 100 101 typedef enum{ 102 AGS_MACHINE_POPUP_MIDI_IMPORT = 1, 103 AGS_MACHINE_POPUP_WAVE_IMPORT = 1 << 1, 104 }AgsMachineImportOptions; 105 106 struct _AgsMachine 107 { 108 GtkBin bin; 109 110 guint flags; 111 guint file_input_flags; 112 guint mapping_flags; 113 guint connection_flags; 114 guint export_flags; 115 guint import_flags; 116 117 char *machine_name; 118 119 gchar *version; 120 gchar *build_id; 121 122 guint samplerate; 123 guint buffer_size; 124 guint format; 125 126 guint bank_0; 127 guint bank_1; 128 129 guint audio_channels; 130 131 guint output_pads; 132 guint input_pads; 133 134 AgsAudio *audio; 135 136 GList *active_playback; 137 138 GtkToggleButton *play; 139 140 GType output_pad_type; 141 GType output_line_type; 142 GtkContainer *output; 143 144 GtkWidget *selected_output_pad; 145 146 GType input_pad_type; 147 GType input_line_type; 148 GtkContainer *input; 149 150 GtkWidget *selected_input_pad; 151 152 GtkContainer *bridge; 153 154 GList *port; 155 GList *enabled_automation_port; 156 157 GtkMenuToolButton *menu_tool_button; 158 GtkMenu *popup; 159 160 GtkDialog *properties; 161 GtkDialog *rename; 162 GtkDialog *rename_audio; 163 GtkDialog *reposition_audio; 164 GtkDialog *connection_editor; 165 GtkDialog *midi_dialog; 166 GtkDialog *envelope_dialog; 167 GtkDialog *envelope_info; 168 GtkDialog *midi_export_dialog; 169 GtkDialog *wave_export_dialog; 170 GtkDialog *midi_import_dialog; 171 GtkDialog *wave_import_dialog; 172 }; 173 174 struct _AgsMachineClass 175 { 176 GtkBinClass bin; 177 178 void (*samplerate_changed)(AgsMachine *machine, 179 guint samplerate, guint old_samplerate); 180 void (*buffer_size_changed)(AgsMachine *machine, 181 guint buffer_size, guint old_buffer_size); 182 void (*format_changed)(AgsMachine *machine, 183 guint format, guint old_format); 184 185 void (*resize_audio_channels)(AgsMachine *machine, 186 guint new_size, guint old_size); 187 void (*resize_pads)(AgsMachine *machine, 188 GType channel_type, 189 guint new_size, guint old_size); 190 191 void (*map_recall)(AgsMachine *machine); 192 GList* (*find_port)(AgsMachine *machine); 193 194 void (*stop)(AgsMachine *machine, 195 GList *recall_id, gint sound_scope); 196 }; 197 198 struct _AgsMachineAutomationPort 199 { 200 GType channel_type; 201 gchar *control_name; 202 }; 203 204 GType ags_machine_get_type(void); 205 206 void ags_machine_reset_pattern_envelope(AgsMachine *machine); 207 208 AgsMachineAutomationPort* ags_machine_automation_port_alloc(GType channel_type, gchar *control_name); 209 void ags_machine_automation_port_free(AgsMachineAutomationPort *automation_port); 210 211 GList* ags_machine_automation_port_find_channel_type_with_control_name(GList *list, 212 GType channel_type, gchar *control_name); 213 214 void ags_machine_samplerate_changed(AgsMachine *machine, 215 guint samplerate, guint old_samplerate); 216 void ags_machine_buffer_size_changed(AgsMachine *machine, 217 guint buffer_size, guint old_buffer_size); 218 void ags_machine_format_changed(AgsMachine *machine, 219 guint format, guint old_format); 220 221 void ags_machine_resize_audio_channels(AgsMachine *machine, 222 guint new_size, guint old_size); 223 void ags_machine_resize_pads(AgsMachine *machine, 224 GType channel_type, 225 guint new_size, guint old_size); 226 227 void ags_machine_map_recall(AgsMachine *machine); 228 GList* ags_machine_find_port(AgsMachine *machine); 229 230 void ags_machine_stop(AgsMachine *machine, 231 GList *recall_id, gint sound_scope); 232 233 void ags_machine_add_default_recalls(AgsMachine *machine) G_DEPRECATED_FOR(ags_machine_map_recall); 234 235 AgsMachine* ags_machine_find_by_name(GList *list, char *name); 236 237 void ags_machine_playback_set_active(AgsMachine *machine, 238 AgsPlayback *playback, 239 gboolean is_active); 240 241 void ags_machine_set_run(AgsMachine *machine, 242 gboolean run); 243 void ags_machine_set_run_extended(AgsMachine *machine, 244 gboolean run, 245 gboolean sequencer, gboolean notation, gboolean wave, gboolean midi); 246 247 GtkListStore* ags_machine_get_possible_links(AgsMachine *machine); 248 GtkListStore* ags_machine_get_possible_audio_output_connections(AgsMachine *machine); 249 GtkListStore* ags_machine_get_possible_audio_input_connections(AgsMachine *machine); 250 251 GtkFileChooserDialog* ags_machine_file_chooser_dialog_new(AgsMachine *machine); 252 253 void ags_machine_open_files(AgsMachine *machine, 254 GSList *filenames, 255 gboolean overwrite_channels, 256 gboolean create_channels); 257 258 void ags_machine_copy_pattern(AgsMachine *machine); 259 260 void ags_machine_popup_add_edit_options(AgsMachine *machine, guint edit_options); 261 void ags_machine_popup_add_connection_options(AgsMachine *machine, guint connection_options); 262 void ags_machine_popup_add_export_options(AgsMachine *machine, guint export_options); 263 void ags_machine_popup_add_import_options(AgsMachine *machine, guint import_options); 264 265 void ags_machine_check_message(AgsMachine *machine); 266 267 AgsMachine* ags_machine_new(GObject *soundcard); 268 269 G_END_DECLS 270 271 #endif /*__AGS_MACHINE_H__*/ 272