void ags_drum_index1_callback(GtkWidget *widget, AgsDrum *drum) { if(drum->selected1 != NULL){ GtkToggleButton *toggle_button; if(GTK_TOGGLE_BUTTON(widget) != drum->selected1){ AgsCopyPatternAudio *copy_pattern_audio; GList *list; toggle_button = drum->selected1; drum->selected1 = NULL; gtk_toggle_button_set_active(toggle_button, FALSE); drum->selected1 = (GtkToggleButton*) widget; list = ags_recall_find_type(AGS_MACHINE(drum)->audio->play, AGS_TYPE_COPY_PATTERN_AUDIO); if(list != NULL){ GValue value = {0,}; g_value_init(&value, G_TYPE_UINT); g_value_set_uint(&value, GPOINTER_TO_UINT(g_object_get_data((GObject *) widget, AGS_DRUM_INDEX))); copy_pattern_audio = AGS_COPY_PATTERN_AUDIO(list->data); ags_port_safe_write(copy_pattern_audio->bank_index_1, &value); g_value_unset(&value); } list = ags_recall_find_type(AGS_MACHINE(drum)->audio->recall, AGS_TYPE_COPY_PATTERN_AUDIO); if(list != NULL){ GValue value = {0,}; g_value_init(&value, G_TYPE_UINT); g_value_set_uint(&value, GPOINTER_TO_UINT(g_object_get_data((GObject *) widget, AGS_DRUM_INDEX))); copy_pattern_audio = AGS_COPY_PATTERN_AUDIO(list->data); ags_port_safe_write(copy_pattern_audio->bank_index_1, &value); g_value_unset(&value); } }else if(!gtk_toggle_button_get_active(drum->selected1)){ toggle_button = drum->selected1; drum->selected1 = NULL; gtk_toggle_button_set_active((GtkToggleButton *) widget, TRUE); drum->selected1 = (GtkToggleButton*) widget; } ags_drum_set_pattern(drum); } }
void ags_count_beats_audio_change_notation_duration(AgsTactable *tactable, gdouble duration) { AgsCountBeatsAudio *count_beats_audio; GValue value = {0,}; count_beats_audio = AGS_COUNT_BEATS_AUDIO(tactable); g_value_init(&value, G_TYPE_DOUBLE); g_value_set_double(&value, duration); ags_port_safe_write(count_beats_audio->notation_loop_end, &value); }
void ags_recall_dssi_run_run_pre(AgsRecall *recall) { AgsRecallDssi *recall_dssi; AgsRecallChannelRun *recall_channel_run; AgsRecallRecycling *recall_recycling; AgsRecallDssiRun *recall_dssi_run; AgsAudioSignal *audio_signal; AgsPort *current_port; AgsRecallID *recall_id; AgsRecyclingContext *parent_recycling_context, *recycling_context; AgsCountBeatsAudioRun *count_beats_audio_run; AgsRouteDssiAudioRun *route_dssi_audio_run; GList *list_start, *list; GList *port; GList *note_start, *note; snd_seq_event_t **event_buffer; unsigned long *event_count; gchar *specifier, *current_specifier; LADSPA_Data port_data; guint bank, program; guint output_lines, input_lines; guint notation_counter; guint x0, x1; guint port_count; guint copy_mode_in, copy_mode_out; guint buffer_size; guint i, i_stop; void (*parent_class_run_pre)(AgsRecall *recall); void (*select_program)(LADSPA_Handle Instance, unsigned long Bank, unsigned long Program); void (*run_synth)(LADSPA_Handle Instance, unsigned long SampleCount, snd_seq_event_t *Events, unsigned long EventCount); void (*run)(LADSPA_Handle Instance, unsigned long SampleCount); void (*deactivate)(LADSPA_Handle Instance); void (*cleanup)(LADSPA_Handle Instance); pthread_mutex_t *recall_dssi_mutex; pthread_mutex_t *port_mutex; /* get parent class */ pthread_mutex_lock(ags_recall_get_class_mutex()); parent_class_run_pre = AGS_RECALL_CLASS(ags_recall_dssi_run_parent_class)->run_pre; pthread_mutex_unlock(ags_recall_get_class_mutex()); /* call parent */ parent_class_run_pre(recall); g_object_get(recall, "recall-id", &recall_id, "source", &audio_signal, NULL); g_object_get(recall_id, "recycling-context", &recycling_context, NULL); g_object_get(recycling_context, "parent", &parent_recycling_context, NULL); g_object_get(audio_signal, "note", ¬e_start, NULL); if(ags_recall_global_get_rt_safe() && parent_recycling_context != NULL && note_start == NULL){ g_object_unref(recall_id); g_object_unref(audio_signal); g_object_unref(recycling_context); g_object_unref(parent_recycling_context); return; } g_list_free_full(note_start, g_object_unref); g_object_get(recall, "parent", &recall_recycling, NULL); g_object_get(recall_recycling, "parent", &recall_channel_run, NULL); g_object_get(recall_channel_run, "recall-channel", &recall_dssi, NULL); recall_dssi_run = AGS_RECALL_DSSI_RUN(recall); g_object_get(recall_dssi_run, "route-dssi-audio-run", &route_dssi_audio_run, NULL); if(route_dssi_audio_run == NULL){ g_object_unref(recall_id); g_object_unref(audio_signal); g_object_unref(recycling_context); g_object_unref(parent_recycling_context); g_object_unref(recall_recycling); g_object_unref(recall_channel_run); g_object_unref(recall_dssi); return; } /* get recall dssi mutex */ pthread_mutex_lock(ags_recall_get_class_mutex()); recall_dssi_mutex = AGS_RECALL(recall_dssi)->obj_mutex; pthread_mutex_unlock(ags_recall_get_class_mutex()); g_object_get(route_dssi_audio_run, "count-beats-audio-run", &count_beats_audio_run, NULL); g_object_get(audio_signal, "buffer-size", &buffer_size, NULL); /* get some fields */ pthread_mutex_lock(recall_dssi_mutex); output_lines = recall_dssi->output_lines; input_lines = recall_dssi->input_lines; pthread_mutex_unlock(recall_dssi_mutex); if(input_lines < output_lines){ i_stop = output_lines; }else{ i_stop = input_lines; } g_object_get(count_beats_audio_run, "notation-counter", ¬ation_counter, NULL); if(ags_recall_global_get_rt_safe()){ g_object_get(recall_dssi_run, "note", ¬e_start, NULL); note = note_start; while(note != NULL){ g_object_get(note->data, "x0", &x0, "x1", &x1, NULL); if((x1 + 1 <= notation_counter && !ags_note_test_flags(note->data, AGS_NOTE_FEED)) || x0 > notation_counter){ recall_dssi_run->note = g_list_remove(recall_dssi_run->note, note->data); g_object_unref(note->data); } note = note->next; } if(note_start == NULL){ memset(recall_dssi_run->event_buffer[0], 0, sizeof(snd_seq_event_t)); } g_list_free_full(note_start, g_object_unref); }else{ g_object_get(recall_dssi_run, "note", ¬e_start, NULL); g_object_get(note_start->data, "x0", &x0, "x1", &x1, NULL); if(audio_signal->stream_current == NULL || (x1 + 1 <= notation_counter && !ags_note_test_flags(note_start->data, AGS_NOTE_FEED)) || x0 > notation_counter){ // g_message("done"); pthread_mutex_lock(recall_dssi_mutex); deactivate = recall_dssi->plugin_descriptor->LADSPA_Plugin->deactivate; cleanup = recall_dssi->plugin_descriptor->LADSPA_Plugin->cleanup; pthread_mutex_unlock(recall_dssi_mutex); for(i = 0; i < i_stop; i++){ /* deactivate */ //TODO:JK: fix-me if(deactivate != NULL){ deactivate(recall_dssi_run->ladspa_handle[i]); } cleanup(recall_dssi_run->ladspa_handle[i]); } ags_recall_done(recall); g_list_free_full(note_start, g_object_unref); goto ags_recall_dssi_run_run_pre_END; } } /* get copy mode and clear buffer */ copy_mode_in = ags_audio_buffer_util_get_copy_mode(AGS_AUDIO_BUFFER_UTIL_FLOAT, ags_audio_buffer_util_format_from_soundcard(audio_signal->format)); copy_mode_out = ags_audio_buffer_util_get_copy_mode(ags_audio_buffer_util_format_from_soundcard(audio_signal->format), AGS_AUDIO_BUFFER_UTIL_FLOAT); if(recall_dssi_run->output != NULL){ ags_audio_buffer_util_clear_float(recall_dssi_run->output, output_lines, buffer_size); } if(recall_dssi_run->input != NULL){ ags_audio_buffer_util_clear_float(recall_dssi_run->input, input_lines, buffer_size); } /* copy data */ if(recall_dssi_run->input != NULL){ ags_audio_buffer_util_copy_buffer_to_buffer(recall_dssi_run->input, input_lines, 0, audio_signal->stream_current->data, 1, 0, buffer_size, copy_mode_in); } /* select program */ pthread_mutex_lock(recall_dssi_mutex); port_count = recall_dssi->plugin_descriptor->LADSPA_Plugin->PortCount; select_program = recall_dssi->plugin_descriptor->select_program; pthread_mutex_unlock(recall_dssi_mutex); /* cache port data */ g_object_get(recall_dssi, "port", &list_start, NULL); for(i = 0; i < port_count; i++){ pthread_mutex_lock(recall_dssi_mutex); specifier = g_strdup(recall_dssi->plugin_descriptor->LADSPA_Plugin->PortNames[i]); pthread_mutex_unlock(recall_dssi_mutex); list = list_start; while(list != NULL){ gboolean success; current_port = list->data; /* get port mutex */ pthread_mutex_lock(ags_port_get_class_mutex()); port_mutex = current_port->obj_mutex; pthread_mutex_unlock(ags_port_get_class_mutex()); /* check specifier */ pthread_mutex_lock(port_mutex); current_specifier = g_strdup(current_port->specifier); pthread_mutex_unlock(port_mutex); success = (!g_strcmp0(specifier, current_specifier)) ? TRUE: FALSE; g_free(current_specifier); if(success){ GValue value = {0,}; g_value_init(&value, G_TYPE_FLOAT); ags_port_safe_read(current_port, &value); recall_dssi_run->port_data[i] = g_value_get_float(&value); g_value_unset(&value); break; } list = list->next; } g_free(specifier); } g_object_get(recall_dssi, "bank", &bank, "program", &program, NULL); if(select_program != NULL){ for(i = 0; i < i_stop; i++){ select_program(recall_dssi_run->ladspa_handle[i], (unsigned long) bank, (unsigned long) program); // g_message("b p %u %u", bank, program); } } /* reset port data */ for(i = 0; i < port_count; i++){ pthread_mutex_lock(recall_dssi_mutex); specifier = g_strdup(recall_dssi->plugin_descriptor->LADSPA_Plugin->PortNames[i]); pthread_mutex_unlock(recall_dssi_mutex); list = list_start; current_port = NULL; while(list != NULL){ gboolean success; current_port = list->data; /* get port mutex */ pthread_mutex_lock(ags_port_get_class_mutex()); port_mutex = current_port->obj_mutex; pthread_mutex_unlock(ags_port_get_class_mutex()); /* check specifier */ pthread_mutex_lock(port_mutex); current_specifier = g_strdup(current_port->specifier); pthread_mutex_unlock(port_mutex); success = (!g_strcmp0(specifier, current_specifier)) ? TRUE: FALSE; g_free(current_specifier); if(success){ break; } list = list->next; } g_free(specifier); if(list != NULL){ GValue value = {0,}; g_value_init(&value, G_TYPE_FLOAT); port_data = recall_dssi_run->port_data[i]; g_value_set_float(&value, port_data); ags_port_safe_write(current_port, &value); g_value_unset(&value); } } g_list_free_full(list_start, g_object_unref); /* process data */ pthread_mutex_lock(recall_dssi_mutex); run_synth = recall_dssi->plugin_descriptor->run_synth; run = recall_dssi->plugin_descriptor->LADSPA_Plugin->run; pthread_mutex_unlock(recall_dssi_mutex); g_object_get(recall_dssi_run, "note", ¬e_start, NULL); note = note_start; while(note != NULL){ if(run_synth != NULL){ if(recall_dssi_run->event_buffer != NULL){ event_buffer = recall_dssi_run->event_buffer; event_count = recall_dssi_run->event_count; while(*event_buffer != NULL){ if(event_buffer[0]->type == SND_SEQ_EVENT_NOTEON){ run_synth(recall_dssi_run->ladspa_handle[0], (unsigned long) (output_lines * buffer_size), event_buffer[0], event_count[0]); } event_buffer++; event_count++; } } }else if(run != NULL){ run(recall_dssi_run->ladspa_handle[0], (unsigned long) buffer_size); } note = note->next; } g_list_free_full(note_start, g_object_unref); /* copy data */ if(recall_dssi_run->output != NULL){ ags_audio_buffer_util_clear_buffer(audio_signal->stream_current->data, 1, buffer_size, ags_audio_buffer_util_format_from_soundcard(audio_signal->format)); ags_audio_buffer_util_copy_buffer_to_buffer(audio_signal->stream_current->data, 1, 0, recall_dssi_run->output, output_lines, 0, buffer_size, copy_mode_out); } ags_recall_dssi_run_run_pre_END: g_object_unref(recall_id); g_object_unref(recycling_context); g_object_unref(parent_recycling_context); g_object_unref(recall_recycling); g_object_unref(recall_channel_run); g_object_unref(recall_dssi); g_object_unref(count_beats_audio_run); }
void ags_panel_input_line_map_recall(AgsLine *line, guint output_pad_start) { AgsPanel *panel; AgsPanelInputLine *panel_input_line; AgsAudio *audio; AgsChannel *source; AgsChannel *current; AgsPlayChannel *play_channel; AgsPlayChannelRunMaster *play_channel_run; GList *list; if((AGS_LINE_MAPPED_RECALL & (line->flags)) != 0 || (AGS_LINE_PREMAPPED_RECALL & (line->flags)) != 0){ return; } panel_input_line = AGS_PANEL_INPUT_LINE(line); audio = AGS_AUDIO(line->channel->audio); panel = AGS_PANEL(audio->machine_widget); source = line->channel; /* ags-play */ ags_recall_factory_create(audio, NULL, NULL, "ags-play-master\0", source->audio_channel, source->audio_channel + 1, source->pad, source->pad + 1, (AGS_RECALL_FACTORY_INPUT, AGS_RECALL_FACTORY_PLAY | AGS_RECALL_FACTORY_ADD), 0); /* set audio channel */ list = source->play; while((list = ags_recall_template_find_type(list, AGS_TYPE_PLAY_CHANNEL)) != NULL){ GValue audio_channel_value = {0,}; play_channel = AGS_PLAY_CHANNEL(list->data); g_value_init(&audio_channel_value, G_TYPE_UINT64); g_value_set_uint64(&audio_channel_value, source->audio_channel); ags_port_safe_write(play_channel->audio_channel, &audio_channel_value); list = list->next; } /* call parent */ AGS_LINE_CLASS(ags_panel_input_line_parent_class)->map_recall(line, output_pad_start); }
void ags_audiorec_map_recall(AgsMachine *machine) { AgsWindow *window; AgsAudiorec *audiorec; AgsAudio *audio; AgsPlayWaveAudioRun *play_wave_audio_run; AgsCaptureWaveAudioRun *capture_wave_audio_run; GList *start_play, *play; if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0 || (AGS_MACHINE_PREMAPPED_RECALL & (machine->flags)) != 0){ return; } audiorec = AGS_AUDIOREC(machine); window = (AgsWindow *) gtk_widget_get_ancestor((GtkWidget *) machine, AGS_TYPE_WINDOW); audio = machine->audio; /* ags-play-wave */ ags_recall_factory_create(audio, NULL, NULL, "ags-play-wave", 0, 0, 0, 0, (AGS_RECALL_FACTORY_OUTPUT | AGS_RECALL_FACTORY_ADD | AGS_RECALL_FACTORY_PLAY), 0); g_object_get(audio, "play", &start_play, NULL); play = ags_recall_find_type(start_play, AGS_TYPE_PLAY_WAVE_AUDIO_RUN); if(play != NULL){ GValue value = {0,}; play_wave_audio_run = play->data; /* wave loop */ g_value_init(&value, G_TYPE_BOOLEAN); g_value_set_boolean(&value, gtk_toggle_button_get_active((GtkToggleButton *) window->navigation->loop)); ags_port_safe_write(AGS_PLAY_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(play_wave_audio_run)->recall_audio)->wave_loop, &value); g_value_unset(&value); g_value_init(&value, G_TYPE_UINT64); g_value_set_uint64(&value, 16 * window->navigation->loop_left_tact->adjustment->value); ags_port_safe_write(AGS_PLAY_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(play_wave_audio_run)->recall_audio)->wave_loop_start, &value); g_value_reset(&value); g_value_set_uint64(&value, 16 * window->navigation->loop_right_tact->adjustment->value); ags_port_safe_write(AGS_PLAY_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(play_wave_audio_run)->recall_audio)->wave_loop_end, &value); } g_list_free_full(start_play, g_object_unref); /* ags-capture-wave */ ags_recall_factory_create(audio, NULL, NULL, "ags-capture-wave", 0, 0, 0, 0, (AGS_RECALL_FACTORY_OUTPUT | AGS_RECALL_FACTORY_ADD | AGS_RECALL_FACTORY_PLAY), 0); g_object_get(audio, "play", &start_play, NULL); play = ags_recall_find_type(start_play, AGS_TYPE_CAPTURE_WAVE_AUDIO_RUN); if(play != NULL){ GValue value = {0,}; capture_wave_audio_run = play->data; /* wave loop */ g_value_init(&value, G_TYPE_BOOLEAN); g_value_set_boolean(&value, gtk_toggle_button_get_active((GtkToggleButton *) window->navigation->loop)); ags_port_safe_write(AGS_CAPTURE_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(capture_wave_audio_run)->recall_audio)->wave_loop, &value); g_value_unset(&value); g_value_init(&value, G_TYPE_UINT64); g_value_set_uint64(&value, 16 * window->navigation->loop_left_tact->adjustment->value); ags_port_safe_write(AGS_CAPTURE_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(capture_wave_audio_run)->recall_audio)->wave_loop_start, &value); g_value_reset(&value); g_value_set_uint64(&value, 16 * window->navigation->loop_right_tact->adjustment->value); ags_port_safe_write(AGS_CAPTURE_WAVE_AUDIO(AGS_RECALL_AUDIO_RUN(capture_wave_audio_run)->recall_audio)->wave_loop_end, &value); } g_list_free_full(start_play, g_object_unref); /* depending on destination */ ags_audiorec_input_map_recall(audiorec, 0); /* depending on destination */ ags_audiorec_output_map_recall(audiorec, 0); /* call parent */ AGS_MACHINE_CLASS(ags_audiorec_parent_class)->map_recall(machine); }
void ags_delay_audio_change_tact(AgsTactable *tactable, gdouble new_tact) { AgsDevout *devout; AgsDelayAudio *delay_audio; gdouble old_tact; gdouble sequencer_delay, notation_delay; gdouble sequencer_duration, notation_duration; gdouble factor; GValue value = {0,}; delay_audio = AGS_DELAY_AUDIO(tactable); devout = AGS_DEVOUT(AGS_RECALL(delay_audio)->devout); /* retrieve old tact */ g_value_init(&value, G_TYPE_DOUBLE); ags_port_safe_read(delay_audio->tact, &value); old_tact = g_value_get_double(&value); /* retrieve sequencer_delay */ g_value_reset(&value); ags_port_safe_read(delay_audio->sequencer_delay, &value); sequencer_delay = g_value_get_double(&value); /* retrieve notation_delay */ g_value_reset(&value); ags_port_safe_read(delay_audio->notation_delay, &value); notation_delay = g_value_get_double(&value); /* retrieve sequencer_duration */ g_value_reset(&value); ags_port_safe_read(delay_audio->sequencer_duration, &value); sequencer_duration = g_value_get_double(&value); /* retrieve notation_duration */ g_value_reset(&value); ags_port_safe_read(delay_audio->notation_duration, &value); notation_duration = g_value_get_double(&value); /* -- start adjust -- */ factor = (new_tact / old_tact); /* notation-delay */ g_value_reset(&value); g_value_set_double(&value, notation_delay * factor); ags_port_safe_write(delay_audio->notation_delay, &value); /* sequencer-delay */ g_value_reset(&value); g_value_set_double(&value, sequencer_delay * factor); ags_port_safe_write(delay_audio->sequencer_delay, &value); /**/ g_value_reset(&value); g_value_set_double(&value, new_tact); ags_port_safe_write(delay_audio->tact, &value); /* notation-duration */ g_value_reset(&value); g_value_set_double(&value, notation_duration * factor); ags_port_safe_write(delay_audio->notation_duration, &value); /* sequencer-duration */ g_value_reset(&value); g_value_set_double(&value, sequencer_duration * factor); ags_port_safe_write(delay_audio->sequencer_duration, &value); /* -- finish adjust -- */ /* emit changed */ ags_delay_audio_sequencer_duration_changed(delay_audio); }