Beispiel #1
0
/**
 * ags_output_find_last_input_recycling:
 * @output: an #AgsOutput
 *
 * Retrieve last input recycling.
 *
 * Returns: the last #AgsRecycling of #AgsAudio
 *
 * Since: 0.4
 */
AgsRecycling*
ags_output_find_last_input_recycling(AgsOutput *output)
{
  AgsAudio *audio;
  AgsChannel *input;

  if(output == NULL)
    return(NULL);

  audio = AGS_AUDIO(AGS_CHANNEL(output)->audio);

  if((AGS_AUDIO_ASYNC & (audio->flags)) != 0){
    input = ags_channel_nth(audio->input, AGS_CHANNEL(output)->audio_channel);

    input = ags_channel_last_with_recycling(input);
  }else{
    input = ags_channel_nth(audio->input, AGS_CHANNEL(output)->line);
  }

  if(input != NULL){
    return(input->last_recycling);
  }else{
    return(NULL);
  }
}
Beispiel #2
0
void
ags_matrix_draw_matrix(AgsMatrix *matrix)
{
  AgsChannel *channel;
  guint gutter;
  int i, j;

  channel = ags_channel_nth(AGS_MACHINE(matrix)->audio->input, (guint) matrix->adjustment->value);

  if(channel == NULL){
    return;
  }

  if(AGS_MACHINE(matrix)->audio->input_pads > AGS_MATRIX_OCTAVE){
    gutter = AGS_MATRIX_OCTAVE;
  }else{
    gutter = AGS_MACHINE(matrix)->audio->input_pads;
  }

  for (i = 0; i < gutter; i++){
    for (j = 0; j < 32; j++)
      ags_matrix_redraw_gutter_point (matrix, channel, j, i);

    channel = channel->next;
  }
}
Beispiel #3
0
void
ags_matrix_draw_gutter(AgsMatrix *matrix)
{
  AgsChannel *channel;
  guint gutter;
  int i, j;

  gdk_draw_rectangle (GTK_WIDGET (matrix->drawing_area)->window,
                      GTK_WIDGET (matrix->drawing_area)->style->bg_gc[0],
                      TRUE,
                      0, 0,
                      288, 80);

  channel = ags_channel_nth(AGS_MACHINE(matrix)->audio->input, (guint) matrix->adjustment->value);

  if(AGS_MACHINE(matrix)->audio->input_pads > AGS_MATRIX_OCTAVE){
    gutter = AGS_MATRIX_OCTAVE;
  }else{
    gutter = AGS_MACHINE(matrix)->audio->input_pads;
  }

  for (i = 0; i < gutter; i++){
    for (j = 0; j < 32; j++){
      gdk_draw_rectangle (GTK_WIDGET (matrix->drawing_area)->window,
                          GTK_WIDGET (matrix->drawing_area)->style->fg_gc[0],
                          FALSE,
                          j * 12, i * 10,
                          12, 10);

      ags_matrix_redraw_gutter_point (matrix, channel, j, i);
    }

    channel = channel->next;
  }
}
Beispiel #4
0
void
ags_matrix_output_map_recall(AgsMatrix *matrix, guint output_pad_start)
{
  AgsAudio *audio;
  AgsChannel *source;

  AgsDelayAudio *recall_delay_audio;
  AgsCountBeatsAudioRun *recall_count_beats_audio_run;

  GList *list;

  audio = AGS_MACHINE(matrix)->audio;

  if(matrix->mapped_output_pad > output_pad_start){
    return;
  }

  source = ags_channel_nth(audio->output,
			   output_pad_start * audio->audio_channels);

  if(source == NULL){
    return;
  }
  
  /* get some recalls */
  list = ags_recall_find_type(audio->play, AGS_TYPE_DELAY_AUDIO);

  if(list != NULL){
    recall_delay_audio = AGS_DELAY_AUDIO(list->data);
  }else{
    recall_delay_audio = NULL;
  }

  list = ags_recall_find_type(audio->play, AGS_TYPE_COUNT_BEATS_AUDIO_RUN);

  if(list != NULL){
    recall_count_beats_audio_run = AGS_COUNT_BEATS_AUDIO_RUN(list->data);
  }else{
    recall_count_beats_audio_run = NULL;
  }

  /* ags-stream */
  ags_recall_factory_create(audio,
  			    NULL, NULL,
			    "ags-stream\0",
			    source->audio_channel, source->audio_channel + 1,
			    output_pad_start, audio->output_pads,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_PLAY |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  matrix->mapped_output_pad = output_pad_start;
}
Beispiel #5
0
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;
      }
    }
  }
}
Beispiel #6
0
void
ags_drum_input_line_map_recall(AgsDrumInputLine *drum_input_line,
			       guint output_pad_start)
{
  AgsDrum *drum;
  AgsLine *line;
  AgsLineMember *line_member;

  AgsAudio *audio;
  AgsChannel *source;
  AgsChannel *current, *destination;
  AgsCopyChannel *copy_channel;
  AgsCopyChannelRun *copy_channel_run;

  GList *list;
  guint i;

  line = AGS_LINE(drum_input_line);
  line->flags |= AGS_LINE_MAPPED_RECALL;

  audio = AGS_AUDIO(line->channel->audio);

  drum = AGS_DRUM(audio->machine);

  source = line->channel;

  /* ags-play */
  //  ags_recall_factory_create(audio,
  //			    "ags-play\0",
  //			    0, audio->audio_channels,
  //			    source->pad, source->pad + 1,
  //			    FALSE,
  //			    FALSE);

  /* ags-volume */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-volume\0",
			    source->audio_channel, source->audio_channel + 1, 
			    source->pad, source->pad + 1,
			    (AGS_RECALL_FACTORY_INPUT |
			     AGS_RECALL_FACTORY_RECALL |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  /* ags-copy */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-copy\0",
			    source->audio_channel, source->audio_channel + 1, 
			    source->pad, source->pad + 1,
			    (AGS_RECALL_FACTORY_INPUT |
			     AGS_RECALL_FACTORY_RECALL |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  current = source;
  destination = ags_channel_nth(audio->output,
				current->audio_channel);

  while(destination != NULL){
    /* recall */
    list = current->recall;

    while((list = ags_recall_find_type(list, AGS_TYPE_COPY_CHANNEL)) != NULL){
      copy_channel = AGS_COPY_CHANNEL(list->data);

      g_object_set(G_OBJECT(copy_channel),
		   "destination\0", destination,
		   NULL);

      list = list->next;
    }

    list = current->recall;
    
    while((list = ags_recall_find_type(list, AGS_TYPE_COPY_CHANNEL_RUN)) != NULL){
      copy_channel_run = AGS_COPY_CHANNEL_RUN(list->data);

      g_object_set(G_OBJECT(copy_channel_run),
		   "destination\0", destination,
		   NULL);

      list = list->next;
    }

    destination = destination->next_pad;
  }

  /* ags-stream */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-stream\0",
			    source->audio_channel, source->audio_channel + 1, 
			    source->pad, source->pad + 1,
			    (AGS_RECALL_FACTORY_INPUT |
			     AGS_RECALL_FACTORY_PLAY |
			     AGS_RECALL_FACTORY_RECALL | 
			     AGS_RECALL_FACTORY_ADD),
			    0);
}
Beispiel #7
0
void
ags_audio_test_set_audio_channels()
{
  AgsAudio *audio;
  AgsChannel *channel, *current;

  guint i, j;
  
  /* instantiate */
  audio = ags_audio_new(devout);

  CU_ASSERT(audio != NULL);

  /* set pads */
  audio->output_pads = AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_OUTPUT_PADS;
  audio->input_pads = AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_INPUT_PADS;

  /* set audio channels */
  ags_audio_set_audio_channels(audio,
			       AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS, 0);

  CU_ASSERT(audio->audio_channels == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS);

  /* verify pad count */
  channel = audio->input;
  
  for(i = 0; channel != ags_channel_nth(audio->input,
					AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS); i++){
    current = channel;
    
    for(j = 0; current != NULL; j++){
      current = current->next_pad;
    }

    CU_ASSERT(j == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_INPUT_PADS);
    channel = channel->next;
  }

  CU_ASSERT(i == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS);

  /* verify line count */
  channel = audio->input;
  
  for(i = 0; channel != NULL; i++){
    channel = channel->next;
  }

  CU_ASSERT(i == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_INPUT_PADS * AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS);

  /* verify pad count */
  channel = audio->output;
  
  for(i = 0; channel != ags_channel_nth(audio->output,
					AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS); i++){
    current = channel;
    
    for(j = 0; current != NULL; j++){
      current = current->next_pad;
    }
    
    CU_ASSERT(j == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_OUTPUT_PADS);
    channel = channel->next;
  }

  CU_ASSERT(i == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS);

  /* verify line count */
  channel = audio->output;
  
  for(i = 0; channel != NULL; i++){
    channel = channel->next;
  }

  CU_ASSERT(i == AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_OUTPUT_PADS * AGS_AUDIO_TEST_SET_AUDIO_CHANNELS_AUDIO_CHANNELS);
}
void
ags_link_editor_apply(AgsApplicable *applicable)
{
  AgsLinkEditor *link_editor;
  GtkTreeIter iter;

  link_editor = AGS_LINK_EDITOR(applicable);

  if(gtk_combo_box_get_active_iter(link_editor->combo,
				   &iter)){
    AgsWindow *window;
    AgsMachine *link_machine;
    AgsMachineEditor *machine_editor;
    AgsLineEditor *line_editor;
    GtkTreeModel *model;

    AgsChannel *channel, *link;
    AgsLinkChannel *link_channel;

    AgsThread *main_loop, *current;
    AgsTaskThread *task_thread;

    AgsApplicationContext *application_context;
    
    line_editor = AGS_LINE_EDITOR(gtk_widget_get_ancestor(GTK_WIDGET(link_editor),
							  AGS_TYPE_LINE_EDITOR));

    machine_editor = gtk_widget_get_ancestor(line_editor,
					     AGS_TYPE_MACHINE_EDITOR);

    window = machine_editor->parent;
      
    application_context = window->application_context;

    channel = line_editor->channel;

    main_loop = application_context->main_loop;
    task_thread = ags_thread_find_type(main_loop,
				       AGS_TYPE_TASK_THREAD);

    model = gtk_combo_box_get_model(link_editor->combo);
    gtk_tree_model_get(model,
		       &iter,
		       1, &link_machine,
		       -1);
    
    if(link_machine == NULL){
      /* create task */
      link_channel = ags_link_channel_new(channel, NULL);
      
      /* append AgsLinkChannel */
      ags_task_thread_append_task(task_thread,
				  AGS_TASK(link_channel));
    }else{
      guint link_line;

      link_line = (guint) gtk_spin_button_get_value_as_int(link_editor->spin_button);

      if(AGS_IS_INPUT(channel))
	link = ags_channel_nth(link_machine->audio->output,
			       link_line);
      else
	link = ags_channel_nth(link_machine->audio->input,
			       link_line);

      /* create task */
      link_channel = ags_link_channel_new(channel, link);
      
      /* append AgsLinkChannel */
      ags_task_thread_append_task(task_thread,
				  AGS_TASK(link_channel));
    }
  }
}
Beispiel #9
0
void
ags_matrix_input_map_recall(AgsMatrix *matrix, guint input_pad_start)
{
  AgsAudio *audio;
  AgsPattern *pattern;
  AgsChannel *source, *current, *destination;

  AgsBufferChannel *buffer_channel;
  AgsBufferChannelRun *buffer_channel_run;

  GList *list;

  audio = AGS_MACHINE(matrix)->audio;

  if(matrix->mapped_input_pad > input_pad_start){
    return;
  }

  source = ags_channel_nth(audio->input,
			   input_pad_start * audio->audio_channels);

  if(source == NULL){
    return;
  }
  
  current = source;

  while(current != NULL){
    /* ags-buffer */
    ags_recall_factory_create(audio,
			      NULL, NULL,
			      "ags-buffer\0",
			      current->audio_channel, current->audio_channel + 1, 
			      current->pad, current->pad + 1,
			      (AGS_RECALL_FACTORY_INPUT |
			       AGS_RECALL_FACTORY_RECALL |
			       AGS_RECALL_FACTORY_ADD),
			      0);

    destination = ags_channel_nth(audio->output,
				  current->audio_channel);

    while(destination != NULL){
      /* recall */
      list = current->recall;

      while((list = ags_recall_find_type(list, AGS_TYPE_BUFFER_CHANNEL)) != NULL){
	buffer_channel = AGS_BUFFER_CHANNEL(list->data);

	g_object_set(G_OBJECT(buffer_channel),
		     "destination\0", destination,
		     NULL);

	list = list->next;
      }

      list = current->recall;
    
      while((list = ags_recall_find_type(list, AGS_TYPE_BUFFER_CHANNEL_RUN)) != NULL){
	buffer_channel_run = AGS_BUFFER_CHANNEL_RUN(list->data);

	g_object_set(G_OBJECT(buffer_channel_run),
		     "destination\0", destination,
		     NULL);

	list = list->next;
      }

      destination = destination->next_pad;
    }

    /* ags-stream */
    ags_recall_factory_create(audio,
			      NULL, NULL,
			      "ags-stream\0",
			      current->audio_channel, current->audio_channel + 1, 
			      current->pad, current->pad + 1,
			      (AGS_RECALL_FACTORY_INPUT |
			       AGS_RECALL_FACTORY_RECALL | 
			       AGS_RECALL_FACTORY_ADD),
			      0);

    current = current->next_pad;
  }

  matrix->mapped_input_pad = input_pad_start;
}
Beispiel #10
0
void
ags_matrix_set_pads(AgsAudio *audio, GType type,
		    guint pads, guint pads_old,
		    gpointer data)
{
  AgsMachine *machine;
  AgsMatrix *matrix;
  AgsChannel *channel, *source;
  AgsAudioSignal *audio_signal;
  guint i, j;
  gboolean grow;

  GValue value = {0,};

  if(pads == pads_old){
    return;
  }
  
  matrix = (AgsMatrix *) audio->machine_widget;
  machine = AGS_MACHINE(matrix);

  if(type == AGS_TYPE_INPUT){
    if(pads < AGS_MATRIX_OCTAVE){
      gtk_widget_set_size_request((GtkWidget *) matrix->drawing_area,
				  32 * AGS_MATRIX_CELL_WIDTH +1,
				  pads * AGS_MATRIX_CELL_HEIGHT +1);
    }else if(pads_old < AGS_MATRIX_OCTAVE){
      gtk_widget_set_size_request((GtkWidget *) matrix->drawing_area,
				  32 * AGS_MATRIX_CELL_WIDTH +1,
				  AGS_MATRIX_OCTAVE * AGS_MATRIX_CELL_HEIGHT +1);
    }
  }

  if(pads_old == pads)
    return;
  if(pads_old < pads)
    grow = TRUE;
  else
    grow = FALSE;

  if(type == AGS_TYPE_INPUT){
    AgsPattern *pattern;
    GList *list, *notation;

    if(grow){
      /* create pattern */
      source = ags_channel_nth(audio->input, pads_old);

      while(source != NULL){
	if(source->pattern == NULL){
	  source->pattern = g_list_alloc();
	  source->pattern->data = (gpointer) ags_pattern_new();
	  ags_pattern_set_dim((AgsPattern *) source->pattern->data, 1, 9, 32);
	}
	
	source = source->next;
      }

      if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0){
	ags_matrix_input_map_recall(matrix,
				    pads_old);
      }
    }else{
    }
  }else{
    if(grow){
      AgsChannel *current, *output;
      GList *recall;
      GList *list;
      guint stop;

      source = ags_channel_nth(audio->output, pads_old);

      if(source != NULL){
	AgsAudioSignal *audio_signal;
	
	AgsSoundcard *soundcard;

	gdouble delay;
	guint stop;
	
	soundcard = AGS_SOUNDCARD(AGS_AUDIO(source->audio)->soundcard);

	delay = ags_soundcard_get_delay(soundcard);

	stop = (guint) ceil(16.0 * delay * exp2(8.0 - 4.0) + 1.0);

	audio_signal = ags_audio_signal_new(soundcard,
					    source->first_recycling,
					    NULL);
	audio_signal->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;
	//	ags_audio_signal_stream_resize(audio_signal,
	//			       stop);
	ags_recycling_add_audio_signal(source->first_recycling,
				       audio_signal);

	if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0){
	  ags_matrix_output_map_recall(matrix,
				       pads_old);
	}
      }
    }else{
    }
  }
}
void
ags_link_collection_editor_apply(AgsApplicable *applicable)
{
  AgsLinkCollectionEditor *link_collection_editor;
  GtkTreeIter iter;

  link_collection_editor = AGS_LINK_COLLECTION_EDITOR(applicable);

  if(gtk_combo_box_get_active_iter(link_collection_editor->link,
				   &iter)){
    AgsWindow *window;
    AgsMachine *machine, *link_machine;
    AgsMachineEditor *machine_editor;
    GtkTreeModel *model;

    AgsChannel *channel, *link;
    AgsLinkChannel *link_channel;

    AgsThread *main_loop;
    AgsTaskThread *task_thread;

    AgsApplicationContext *application_context;
    
    GList *task;
    guint first_line, count;
    guint i;
    
    GError *error;

    machine_editor = AGS_MACHINE_EDITOR(gtk_widget_get_ancestor(GTK_WIDGET(link_collection_editor),
								AGS_TYPE_MACHINE_EDITOR));

    window = machine_editor->parent;
    
    application_context = window->application_context;
    
    machine = machine_editor->machine;

    first_line = (guint) gtk_spin_button_get_value_as_int(link_collection_editor->first_line);

    if(link_collection_editor->channel_type == AGS_TYPE_INPUT){
      channel = ags_channel_nth(machine_editor->machine->audio->input, first_line);
    }else{
      channel = ags_channel_nth(machine_editor->machine->audio->output, first_line);
    }

    main_loop = application_context->main_loop;
    task_thread = ags_thread_find_type(main_loop,
				       AGS_TYPE_TASK_THREAD);
    
    model = gtk_combo_box_get_model(link_collection_editor->link);
    gtk_tree_model_get(model,
		       &iter,
		       1, &link_machine,
		       -1);
    
    task = NULL;

    count = (guint) gtk_spin_button_get_value_as_int(link_collection_editor->count);

    error = NULL;

    if(link_machine == NULL){
      for(i = 0; i < count; i++){
	/* create task */
	link_channel = ags_link_channel_new(channel, NULL);
	task = g_list_prepend(task, link_channel);

	channel = channel->next;
      }
      
      /* append AgsLinkChannel */
      task = g_list_reverse(task);
      ags_task_thread_append_tasks(task_thread,
				   task);
    }else{
      guint first_link;

      first_link = (guint) gtk_spin_button_get_value_as_int(link_collection_editor->first_link);


      if(link_collection_editor->channel_type == AGS_TYPE_INPUT)
	link = ags_channel_nth(link_machine->audio->output, first_link);
      else
	link = ags_channel_nth(link_machine->audio->input, first_link);

      for(i = 0; i < count; i++){
	/* create task */
	link_channel = ags_link_channel_new(channel, link);
	task = g_list_prepend(task, link_channel);

	channel = channel->next;
	link = link->next;
      }


      task = g_list_reverse(task);
      ags_task_thread_append_tasks(task_thread,
				   task);
    }
  }
}