void ags_panel_input_pad_show(GtkWidget *pad) { GTK_WIDGET_CLASS(ags_panel_input_pad_parent_class)->show(pad); gtk_widget_hide(GTK_WIDGET(AGS_PAD(pad)->group)); gtk_widget_hide(GTK_WIDGET(AGS_PAD(pad)->mute)); gtk_widget_hide(GTK_WIDGET(AGS_PAD(pad)->solo)); }
int ags_pad_mute_clicked_callback(GtkWidget *widget, AgsPad *pad) { AgsMachine *machine; GtkContainer *container; AgsTaskThread *task_thread; AgsChannel *current; AgsSetMuted *set_muted; GList *list, *tasks; task_thread = AGS_TASK_THREAD(AGS_AUDIO_LOOP(AGS_MAIN(AGS_DEVOUT(AGS_AUDIO(pad->channel->audio)->devout)->ags_main)->main_loop)->task_thread); current = pad->channel; tasks = NULL; if(gtk_toggle_button_get_active(pad->mute)){ if(gtk_toggle_button_get_active(pad->solo)) gtk_toggle_button_set_active(pad->solo, FALSE); /* mute */ while(current != pad->channel->next_pad){ set_muted = ags_set_muted_new(G_OBJECT(current), TRUE); tasks = g_list_prepend(tasks, set_muted); current = current->next; } }else{ machine = (AgsMachine *) gtk_widget_get_ancestor((GtkWidget *) pad, AGS_TYPE_MACHINE); if((AGS_MACHINE_SOLO & (machine->flags)) != 0){ container = (GtkContainer *) (AGS_IS_OUTPUT(pad->channel) ? machine->output: machine->input); list = gtk_container_get_children(container); while(!gtk_toggle_button_get_active(AGS_PAD(list->data)->solo)) list = list->next; gtk_toggle_button_set_active(AGS_PAD(list->data)->solo, FALSE); machine->flags &= ~(AGS_MACHINE_SOLO); } /* unmute */ while(current != pad->channel->next_pad){ set_muted = ags_set_muted_new(G_OBJECT(current), FALSE); tasks = g_list_prepend(tasks, set_muted); current = current->next; } } ags_task_thread_append_tasks(task_thread, tasks); return(0); }
void ags_machine_resize_audio_channels_callback(AgsMachine *machine, guint audio_channels, guint audio_channels_old, gpointer data) { GList *pad_list; GList *line_list; guint i; /* resize */ if((AGS_MACHINE_CONNECTED & (machine->flags)) != 0){ if(audio_channels > audio_channels_old){ if(machine->input != NULL){ pad_list = gtk_container_get_children(GTK_CONTAINER(machine->input)); while(pad_list != NULL){ line_list = gtk_container_get_children((GtkContainer *) AGS_PAD(pad_list->data)->expander_set); line_list = g_list_nth(line_list, audio_channels_old); for(i = 0; i < audio_channels - audio_channels_old; i++){ ags_connectable_connect(AGS_CONNECTABLE(line_list->data)); line_list = line_list->next; } pad_list = pad_list->next; } } if(machine->output != NULL){ pad_list = gtk_container_get_children(GTK_CONTAINER(machine->output)); while(pad_list != NULL){ line_list = gtk_container_get_children((GtkContainer *) AGS_PAD(pad_list->data)->expander_set); line_list = g_list_nth(line_list, audio_channels_old); for(i = 0; i < audio_channels - audio_channels_old; i++){ ags_connectable_connect(AGS_CONNECTABLE(line_list->data)); line_list = line_list->next; } pad_list = pad_list->next; } } } } }
void ags_drum_read_resolve_audio(AgsFileLookup *file_lookup, AgsMachine *machine) { AgsDrum *drum; GList *pad, *pad_start, *line, *line_start; drum = AGS_DRUM(machine); g_signal_connect_after(G_OBJECT(machine->audio), "set_audio_channels\0", G_CALLBACK(ags_drum_set_audio_channels), drum); g_signal_connect_after(G_OBJECT(machine->audio), "set_pads\0", G_CALLBACK(ags_drum_set_pads), drum); pad_start = pad = gtk_container_get_children(machine->input); while(pad != NULL){ line_start = line = gtk_container_get_children(AGS_PAD(pad->data)->expander_set); while(line != NULL){ /* AgsAudio */ g_signal_connect_after(G_OBJECT(machine->audio), "set_pads\0", G_CALLBACK(ags_drum_input_line_audio_set_pads_callback), AGS_DRUM_INPUT_LINE(line->data)); line = line->next; } g_list_free(line_start); pad = pad->next; } }
int ags_pad_solo_clicked_callback(GtkWidget *widget, AgsPad *pad) { AgsMachine *machine; GtkContainer *container; GList *list; machine = (AgsMachine *) gtk_widget_get_ancestor((GtkWidget *) pad, AGS_TYPE_MACHINE); if(gtk_toggle_button_get_active(pad->solo)){ container = (GtkContainer *) (AGS_IS_OUTPUT(pad->channel) ? machine->output: machine->input); if(gtk_toggle_button_get_active(pad->mute)) gtk_toggle_button_set_active(pad->mute, FALSE); list = gtk_container_get_children(container); while(list != NULL){ if(list->data == pad){ list = list->next; continue; } gtk_toggle_button_set_active(AGS_PAD(list->data)->mute, TRUE); list = list->next; } machine->flags |= (AGS_MACHINE_SOLO); }else machine->flags &= ~(AGS_MACHINE_SOLO); return(0); }
void ags_drum_set_pattern(AgsDrum *drum) { AgsLine *selected_line; GList *list, *line; guint index0, index1, offset; gboolean set_active; guint i; if(drum->selected_pad == NULL){ g_message("no selected pad\n\0"); return; } for(i = 0; i < 4 && drum->selected0 != drum->index0[i]; i++); index0 = i; for(i = 0; i < 12 && drum->selected1 != drum->index1[i]; i++); index1 = i; list = gtk_container_get_children((GtkContainer *) drum->offset); for(i = 0; i < 4 && ! GTK_TOGGLE_BUTTON(list->data)->active; i++) list = list->next; offset = i * 16; list = gtk_container_get_children((GtkContainer *) drum->pattern); drum->flags |= AGS_DRUM_BLOCK_PATTERN; for(i = 0; i < 16; i++){ set_active = TRUE; line = gtk_container_get_children(GTK_CONTAINER(AGS_PAD(drum->selected_pad)->expander_set)); while((line = ags_line_find_next_grouped(line)) != NULL){ selected_line = AGS_LINE(line->data); if(!ags_pattern_get_bit((AgsPattern *) selected_line->channel->pattern->data, index0, index1, offset + i)){ set_active = FALSE; break; } line = line->next; } gtk_toggle_button_set_active((GtkToggleButton *) list->data, set_active); list = list->next; } drum->flags &= (~AGS_DRUM_BLOCK_PATTERN); }
void ags_synth_input_pad_connect(AgsConnectable *connectable) { AgsSynthInputPad *synth_input_pad; /* AgsSynthInputPad */ synth_input_pad = AGS_SYNTH_INPUT_PAD(connectable); if((AGS_PAD_CONNECTED & (AGS_PAD(synth_input_pad)->flags)) != 0){ return; } ags_synth_input_pad_parent_connectable_interface->connect(connectable); }
void ags_mixer_set_pads(AgsAudio *audio, GType type, guint pads, guint pads_old, gpointer data) { AgsMixer *mixer; AgsChannel *channel; GList *list, *list_next; guint i, j; mixer = (AgsMixer *) audio->machine; if(type == AGS_TYPE_INPUT){ AgsMixerInputPad *mixer_input_pad; if(pads_old < pads){ channel = ags_channel_nth(audio->input, pads_old * audio->audio_channels); for(i = pads_old; i < pads; i++){ mixer_input_pad = ags_mixer_input_pad_new(channel); gtk_box_pack_start((GtkBox *) mixer->input_pad, (GtkWidget *) mixer_input_pad, FALSE, FALSE, 0); ags_pad_resize_lines((AgsPad *) mixer_input_pad, AGS_TYPE_MIXER_INPUT_LINE, AGS_AUDIO(channel->audio)->audio_channels, 0); if(GTK_WIDGET_VISIBLE((GtkWidget *) mixer)){ ags_connectable_connect(AGS_CONNECTABLE(mixer_input_pad)); ags_pad_find_port(AGS_PAD(mixer_input_pad)); gtk_widget_show_all((GtkWidget *) mixer_input_pad); } channel = channel->next_pad; } }else{ /* destroy AgsPad's */ list = gtk_container_get_children((GtkContainer *) mixer->input_pad); list = g_list_nth(list, pads); while(list != NULL){ list_next = list->next; gtk_widget_destroy((GtkWidget *) list->data); list = list_next; } } } }
void ags_panel_input_pad_connect(AgsConnectable *connectable) { AgsPanelInputPad *panel_input_pad; panel_input_pad = AGS_PANEL_INPUT_PAD(connectable); if((AGS_PAD_CONNECTED & (AGS_PAD(panel_input_pad)->flags)) != 0){ return; } ags_panel_input_pad_parent_connectable_interface->connect(connectable); /* empty */ }
void ags_drum_input_pad_init(AgsDrumInputPad *drum_input_pad) { AgsPad *pad; GtkHBox *hbox; drum_input_pad->flags = 0; drum_input_pad->name = NULL; drum_input_pad->xml_type = "ags-drum-input-pad"; pad = (AgsPad *) drum_input_pad; /* toplevel functions */ hbox = (GtkHBox *) gtk_hbox_new(FALSE, 0); gtk_box_pack_start((GtkBox *) pad, (GtkWidget *) hbox, FALSE, TRUE, 0); gtk_box_reorder_child((GtkBox *) pad, (GtkWidget *) hbox, 0); /* open */ drum_input_pad->open = (GtkButton *) gtk_button_new(); gtk_container_add((GtkContainer *) drum_input_pad->open, (GtkWidget *) gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON)); gtk_box_pack_start((GtkBox *) hbox, (GtkWidget *) drum_input_pad->open, TRUE, TRUE, 0); /* play */ AGS_PAD(drum_input_pad)->play = drum_input_pad->play = (GtkToggleButton *) gtk_toggle_button_new(); gtk_container_add((GtkContainer *) drum_input_pad->play, (GtkWidget *) gtk_image_new_from_stock(GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_BUTTON)); gtk_box_pack_start((GtkBox *) hbox, (GtkWidget *) drum_input_pad->play, TRUE, TRUE, 0); /* bottom functions - edit */ drum_input_pad->edit = (GtkToggleButton *) gtk_toggle_button_new_with_label(i18n("edit")); gtk_box_pack_start((GtkBox *) pad, (GtkWidget *) drum_input_pad->edit, FALSE, FALSE, 0); /* recall specific */ drum_input_pad->pad_open_play_ref = 0; drum_input_pad->pad_open_recalls = NULL; drum_input_pad->file_chooser = NULL; drum_input_pad->pad_play_ref = 0; }
void ags_drum_input_pad_connect(AgsConnectable *connectable) { AgsDrumInputPad *drum_input_pad; drum_input_pad = AGS_DRUM_INPUT_PAD(connectable); if((AGS_PAD_CONNECTED & (AGS_PAD(drum_input_pad)->flags)) != 0){ return; } ags_drum_input_pad_parent_connectable_interface->connect(connectable); /* AgsDrumInputPad */ g_signal_connect(G_OBJECT(drum_input_pad->open), "clicked", G_CALLBACK(ags_drum_input_pad_open_callback), (gpointer) drum_input_pad); g_signal_connect_after(G_OBJECT(drum_input_pad->play), "toggled", G_CALLBACK(ags_drum_input_pad_play_callback), (gpointer) drum_input_pad); g_signal_connect(G_OBJECT(drum_input_pad->edit), "clicked", G_CALLBACK(ags_drum_input_pad_edit_callback), (gpointer) drum_input_pad); }
void ags_drum_pad_callback(GtkWidget *toggle_button, AgsDrum *drum) { AgsLine *selected_line; AgsPattern *pattern; AgsTogglePatternBit *toggle_pattern_bit; GList *list, *line; GList *tasks; guint i, index0, index1, offset; if(drum->selected_pad == NULL){ return; } if((AGS_DRUM_BLOCK_PATTERN & (drum->flags)) != 0){ #ifdef AGS_DEBUG g_message("AgsDrum pattern is blocked\n\0"); #endif return; } list = gtk_container_get_children((GtkContainer *) drum->pattern); for(i = 0; i < 16 && toggle_button != list->data; i++) list = list->next; offset = i; for(i = 0; i < 4 && drum->selected0 != drum->index0[i]; i++); index0 = i; for(i = 0; i < 12 && drum->selected1 != drum->index1[i]; i++); index1 = i; list = gtk_container_get_children((GtkContainer *) drum->offset); for(i = 0; i < 4 && ! GTK_TOGGLE_BUTTON(list->data)->active; i++) list = list->next; offset += (i * 16); line = gtk_container_get_children(GTK_CONTAINER(AGS_PAD(drum->selected_pad)->expander_set)); tasks = NULL; while((line = ags_line_find_next_grouped(line)) != NULL){ selected_line = AGS_LINE(line->data); toggle_pattern_bit = ags_toggle_pattern_bit_new(selected_line->channel->pattern->data, selected_line->channel->line, index0, index1, offset); tasks = g_list_prepend(tasks, toggle_pattern_bit); line = line->next; } /* append AgsTogglePatternBit */ ags_task_thread_append_tasks(AGS_TASK_THREAD(AGS_AUDIO_LOOP(AGS_MAIN(AGS_DEVOUT(AGS_MACHINE(drum)->audio->devout)->ags_main)->main_loop)->task_thread), tasks); }
/** * ags_port_selection_load_ports: * @selection: * * */ void ags_port_selection_load_ports(AgsPortSelection *selection) { AgsAutomationEditor *automation_editor; AgsMachine *machine; AgsAudio *audio; GtkMenu *menu; GtkMenuItem *item; AgsChannel *channel; GList *port; auto GList* ags_port_selection_list_ports(GType type); GList* ags_port_selection_list_ports(GType type){ GList *pad, *pad_start; GList *line, *line_start; GList *line_member, *line_member_start; GList *port; pad_start = pad = gtk_container_get_children(((type == AGS_TYPE_OUTPUT) ? machine->output: machine->input)); port = NULL; while(pad != NULL){ line_start = line = gtk_container_get_children(AGS_PAD(pad->data)->expander_set); while(line != NULL){ channel = AGS_LINE(line->data)->channel; line_member_start = line_member = gtk_container_get_children(AGS_LINE(line->data)->expander->table); while(line_member != NULL){ if(AGS_IS_LINE_MEMBER(line_member->data)){ /* fill list */ port = g_list_prepend(port, AGS_LINE_MEMBER(line_member->data)->port); /* add menu item */ item = gtk_check_menu_item_new_with_label(g_strdup_printf("[%d] %s: %s\0", channel->line, AGS_PORT(port->data)->plugin_name, AGS_PORT(port->data)->specifier)); g_object_set_data(G_OBJECT(item), AGS_PORT_SELECTION_DATA_CHANNEL, channel); g_object_set_data(G_OBJECT(item), AGS_PORT_SELECTION_DATA_PORT, port->data); gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(item)); g_signal_connect(item, "toggled\0", G_CALLBACK(ags_port_selection_ports_toggled_callback), selection); } line_member = line_member->next; } g_list_free(line_member_start); line = line->next; } g_list_free(line_start); pad = pad->next; } g_list_free(pad_start); port = g_list_reverse(port); return(port); }
void ags_mixer_set_audio_channels(AgsAudio *audio, guint audio_channels, guint audio_channels_old, gpointer data) { AgsMixer *mixer; GtkVScale *scale; GList *list_input_pad; guint i; mixer = AGS_MIXER(audio->machine); if(audio_channels_old < audio_channels){ AgsMixerInputPad *mixer_input_pad; AgsChannel *channel; /* AgsInput */ channel = audio->input; list_input_pad = gtk_container_get_children((GtkContainer *) mixer->input_pad); for(i = 0; i < audio->input_pads; i++){ if(audio_channels_old == 0){ /* create AgsPad's if necessary */ mixer_input_pad = g_object_new(AGS_TYPE_MIXER_INPUT_PAD, "channel\0", channel, NULL); gtk_box_pack_start((GtkBox *) mixer->input_pad, (GtkWidget *) mixer_input_pad, FALSE, FALSE, 0); ags_pad_resize_lines((AgsPad *) mixer_input_pad, AGS_TYPE_MIXER_INPUT_LINE, AGS_AUDIO(channel->audio)->audio_channels, 0); if(GTK_WIDGET_VISIBLE((GtkWidget *) mixer)){ ags_connectable_connect(AGS_CONNECTABLE(mixer_input_pad)); ags_pad_find_port(AGS_PAD(mixer_input_pad)); gtk_widget_show_all((GtkWidget *) mixer_input_pad); } }else{ mixer_input_pad = AGS_MIXER_INPUT_PAD(list_input_pad->data); ags_pad_resize_lines((AgsPad *) mixer_input_pad, AGS_TYPE_MIXER_INPUT_LINE, audio_channels, audio_channels_old); } channel = channel->next_pad; if(audio_channels_old != 0) list_input_pad = list_input_pad->next; } }else{ GList *list_input_pad_next; list_input_pad = gtk_container_get_children((GtkContainer *) mixer->input_pad); if(audio_channels == 0){ /* AgsInput */ while(list_input_pad != NULL){ list_input_pad_next = list_input_pad->next; gtk_widget_destroy(GTK_WIDGET(list_input_pad->data)); list_input_pad->next = list_input_pad_next; } }else{ /* AgsInput */ for(i = 0; list_input_pad != NULL; i++){ ags_pad_resize_lines(AGS_PAD(list_input_pad->data), AGS_TYPE_MIXER_INPUT_PAD, audio_channels, audio_channels_old); list_input_pad = list_input_pad->next; } } } }
void ags_drum_input_pad_open_response_callback(GtkWidget *widget, gint response, AgsDrumInputPad *drum_input_pad) { AgsWindow *window; GtkFileChooserDialog *file_chooser; GtkSpinButton *spin_button; AgsAudioFile *audio_file; AgsOpenSingleFile *open_single_file; AgsThread *gui_thread; AgsApplicationContext *application_context; GList *task; char *name0, *name1; pthread_mutex_t *application_mutex; window = (AgsWindow *) gtk_widget_get_ancestor((GtkWidget *) drum_input_pad, AGS_TYPE_WINDOW); file_chooser = drum_input_pad->file_chooser; application_context = (AgsApplicationContext *) window->application_context; gui_thread = ags_ui_provider_get_gui_thread(AGS_UI_PROVIDER(application_context)); if(response == GTK_RESPONSE_ACCEPT){ name0 = gtk_file_chooser_get_filename((GtkFileChooser *) file_chooser); name1 = (char *) g_object_get_data((GObject *) file_chooser, AGS_DRUM_INPUT_PAD_OPEN_AUDIO_FILE_NAME); spin_button = (GtkSpinButton *) g_object_get_data((GObject *) file_chooser, AGS_DRUM_INPUT_PAD_OPEN_SPIN_BUTTON); /* open audio file and read audio signal */ if(g_strcmp0(name0, name1)){ if(name1 != NULL){ audio_file = (AgsAudioFile *) g_object_get_data((GObject *) file_chooser, g_type_name(AGS_TYPE_AUDIO_FILE)); g_object_unref(G_OBJECT(audio_file)); } } /* task */ task = NULL; if(AGS_PAD(drum_input_pad)->group->active){ AgsChannel *current, *next_pad, *next_current; guint i; current = AGS_PAD(drum_input_pad)->channel; if(current != NULL) { g_object_ref(current); } next_pad = ags_channel_next_pad(current); next_current = NULL; for(i = 0; current != next_pad; i++){ open_single_file = ags_open_single_file_new(current, name0, i); task = g_list_prepend(task, open_single_file); /* iterate */ next_current = ags_channel_next(current); g_object_unref(current); current = next_current; } if(next_pad != NULL){ g_object_unref(next_pad); } if(next_current != NULL){ g_object_unref(next_current); } }else{ AgsLine *line; GList *list; list = gtk_container_get_children(GTK_CONTAINER(AGS_PAD(drum_input_pad)->expander_set)); line = AGS_LINE(ags_line_find_next_grouped(list)->data); open_single_file = ags_open_single_file_new(line->channel, name0, (guint) spin_button->adjustment->value); task = g_list_prepend(task, open_single_file); g_list_free(list); } ags_gui_thread_schedule_task_list((AgsGuiThread *) gui_thread, task); gtk_widget_destroy((GtkWidget *) file_chooser); }else if(response == GTK_RESPONSE_CANCEL){ audio_file = (AgsAudioFile *) g_object_get_data((GObject *) file_chooser, g_type_name(AGS_TYPE_AUDIO_FILE)); if(audio_file != NULL){ g_object_unref(G_OBJECT(audio_file)); } gtk_widget_destroy((GtkWidget *) file_chooser); } drum_input_pad->file_chooser = NULL; }
void ags_drum_input_pad_open_callback(GtkWidget *widget, AgsDrumInputPad *drum_input_pad) { GtkFileChooserDialog *file_chooser; GtkHBox *hbox; GtkLabel *label; GtkSpinButton *spin_button; GtkToggleButton *play; if(drum_input_pad->file_chooser != NULL) return; drum_input_pad->file_chooser = file_chooser = (GtkFileChooserDialog *) gtk_file_chooser_dialog_new(i18n("Open File"), (GtkWindow *) gtk_widget_get_toplevel((GtkWidget *) drum_input_pad), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_add_shortcut_folder_uri(GTK_FILE_CHOOSER(file_chooser), "file:///usr/share/hydrogen/data/drumkits", NULL); gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(file_chooser), FALSE); g_object_set_data((GObject *) file_chooser, (char *) g_type_name(AGS_TYPE_AUDIO_FILE), NULL); g_object_set_data((GObject *) file_chooser, AGS_DRUM_INPUT_PAD_OPEN_AUDIO_FILE_NAME, NULL); hbox = (GtkHBox *) gtk_hbox_new(FALSE, 0); gtk_file_chooser_set_extra_widget((GtkFileChooser *) file_chooser, (GtkWidget *) hbox); label = (GtkLabel *) gtk_label_new(i18n("channel: ")); gtk_box_pack_start((GtkBox *) hbox, (GtkWidget *) label, FALSE, FALSE, 0); spin_button = (GtkSpinButton *) gtk_spin_button_new_with_range(0.0, AGS_AUDIO(AGS_PAD(drum_input_pad)->channel->audio)->audio_channels - 1, 1.0); g_object_set_data((GObject *) file_chooser, AGS_DRUM_INPUT_PAD_OPEN_SPIN_BUTTON, spin_button); gtk_box_pack_start((GtkBox *) hbox, (GtkWidget *) spin_button, FALSE, FALSE, 0); if(drum_input_pad->pad.group->active){ gtk_widget_set_sensitive((GtkWidget *) spin_button, FALSE); } #if 0 play = (GtkToggleButton *) g_object_new(GTK_TYPE_TOGGLE_BUTTON, "label", GTK_STOCK_MEDIA_PLAY, "use-stock", TRUE, "use-underline", TRUE, NULL); gtk_box_pack_start((GtkBox *) GTK_DIALOG(file_chooser)->action_area, (GtkWidget *) play, FALSE, FALSE, 0); gtk_box_reorder_child((GtkBox *) GTK_DIALOG(file_chooser)->action_area, (GtkWidget *) play, 0); #endif gtk_widget_show_all((GtkWidget *) file_chooser); g_signal_connect((GObject *) file_chooser, "response", G_CALLBACK(ags_drum_input_pad_open_response_callback), (gpointer) drum_input_pad); }
void ags_drum_input_pad_play_callback(GtkToggleButton *toggle_button, AgsDrumInputPad *drum_input_pad) { ags_pad_play(AGS_PAD(drum_input_pad)); }