Esempio n. 1
0
void
ags_audiorec_resize_pads(AgsMachine *machine, GType type,
			 guint pads, guint pads_old,
			 gpointer data)
{
  AgsAudiorec *audiorec;

  AgsAudio *audio;
  AgsChannel *start_output;
  AgsChannel *channel, *next_channel, *nth_channel;
  AgsRecycling *first_recycling;
  AgsAudioSignal *audio_signal;

  GObject *output_soundcard;
  
  guint audio_channels;

  audiorec = AGS_AUDIOREC(machine);

  audio = machine->audio;

  if(type == AGS_TYPE_INPUT){
    if(pads > pads_old){
      AgsHIndicator *hindicator;

      guint audio_channels;
      guint i;

      /* get some fields */
      g_object_get(audio,
		   "output", &start_output,
		   "audio-channels", &audio_channels,
		   NULL);

      /* AgsOutput */
      nth_channel = ags_channel_pad_nth(start_output,
					pads_old);

      channel = nth_channel;

      next_channel = NULL;
      
      while(channel != NULL){
	ags_channel_set_ability_flags(channel, (AGS_SOUND_ABILITY_WAVE));

	/* get some fields */
	g_object_get(channel,
		     "output-soundcard", &output_soundcard,
		     "first-recycling", &first_recycling,
		     NULL);

	/* audio signal */
	audio_signal = ags_audio_signal_new(output_soundcard,
					    (GObject *) first_recycling,
					    NULL);
	audio_signal->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;
	ags_audio_signal_stream_resize(audio_signal,
				       3);
	ags_recycling_add_audio_signal(first_recycling,
				       audio_signal);
	
	if(output_soundcard != NULL){
	  g_object_unref(output_soundcard);
	}

	if(first_recycling != NULL){
	  g_object_unref(first_recycling);
	}
	
	/* iterate */
	next_channel = ags_channel_next(channel);

	g_object_unref(channel);

	channel = next_channel;
      }

      if(next_channel != NULL){
	g_object_unref(next_channel);
      }

      if(start_output != NULL){
	g_object_unref(start_output);
      }
      
      for(i = 0; i < audio_channels; i++){
	hindicator = ags_hindicator_new();
	gtk_box_pack_start((GtkBox *) audiorec->hindicator_vbox,
			   (GtkWidget *) hindicator,
			   FALSE, FALSE,
			   8);
      }

      gtk_widget_show_all((GtkWidget *) audiorec->hindicator_vbox);

      /* depending on destination */
      ags_audiorec_input_map_recall(audiorec,
				    pads_old);
    }else{
      GList *list, *list_start;

      list_start = 
	list = gtk_container_get_children((GtkContainer *) audiorec->hindicator_vbox);

      while(list != NULL){
	gtk_widget_destroy((GtkWidget *) list->data);
      
	list = list->next;
      }

      g_list_free(list_start);

      audiorec->mapped_input_pad = pads;
    }
  }else{
    if(pads > pads_old){
      /* depending on destination */
      ags_audiorec_output_map_recall(audiorec,
				     pads_old);
    }else{
      audiorec->mapped_output_pad = pads;
    }
  }
}
Esempio n. 2
0
void
ags_open_file_launch(AgsTask *task)
{
  AgsOpenFile *open_file;
  AgsAudio *audio;
  AgsChannel *channel, *iter;
  AgsAudioFile *audio_file;
  AgsFileLink *file_link;
  GSList *current;
  GList *audio_signal;
  gchar *current_filename;
  guint i, i_stop;
  GError *error;

  open_file = AGS_OPEN_FILE(task);

  audio = open_file->audio;

  current = open_file->filenames;

  i_stop = 0;
  
  if(open_file->overwrite_channels){
    channel = audio->input;    

    i_stop = audio->input_pads;
  }

  /*  */
  if(open_file->create_channels){
    guint pads_old;

    i_stop = g_slist_length(open_file->filenames);
    pads_old = audio->input_pads;
    
    if(open_file->overwrite_channels){
      if(i_stop > audio->input_pads){
	ags_audio_set_pads(audio, AGS_TYPE_INPUT,
			   i_stop);
      }

      channel = audio->input;
    }else{
      ags_audio_set_pads(audio, AGS_TYPE_INPUT,
			 audio->input_pads + i_stop);

      channel = ags_channel_pad_nth(audio->input,
				    pads_old);
    }

    iter = ags_channel_pad_nth(audio->input,
			       pads_old);

    while(iter != NULL){
      ags_connectable_connect(AGS_CONNECTABLE(iter));

      iter = iter->next;
    }
  }

  for(i = 0; i < i_stop && current != NULL; i++){
    current_filename = (gchar *) current->data;

    audio_file = ags_audio_file_new((gchar *) current_filename,
				    audio->soundcard,
				    0, open_file->audio->audio_channels);

    ags_audio_file_open(audio_file);
    ags_audio_file_read_audio_signal(audio_file);

    iter = channel;
    audio_signal = audio_file->audio_signal;

    while(iter != channel->next_pad && audio_signal != NULL){
      file_link = g_object_new(AGS_TYPE_FILE_LINK,
			       "filename\0", current_filename,
			       NULL);
      g_object_set(G_OBJECT(iter),
		   "file-link", file_link,
		   NULL);

      AGS_AUDIO_SIGNAL(audio_signal->data)->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;

      if(iter->link != NULL){
	error = NULL;

	ags_channel_set_link(iter, NULL,
			     &error);

	if(error != NULL){
	  g_warning(error->message);
	}
      }

      //TODO:JK: add mutex
      ags_recycling_add_audio_signal(iter->first_recycling,
				     AGS_AUDIO_SIGNAL(audio_signal->data));

      audio_signal = audio_signal->next;
      iter = iter->next;
    }

    channel = channel->next_pad;
    current = current->next;
  }
}
Esempio n. 3
0
void
ags_audiorec_resize_audio_channels(AgsMachine *machine,
				   guint audio_channels, guint audio_channels_old,
				   gpointer data)
{
  AgsAudiorec *audiorec;

  AgsAudio *audio;
  AgsChannel *start_output;
  AgsChannel *channel, *next_pad, *next_channel, *nth_channel;
  AgsRecycling *first_recycling;
  AgsAudioSignal *audio_signal;  

  GObject *output_soundcard;
  
  guint output_pads, input_pads;
  
  audiorec = AGS_AUDIOREC(machine);

  audio = AGS_MACHINE(audiorec)->audio;

  g_object_get(audio,
	       "input-pads", &input_pads,
	       "output-pads", &output_pads,
	       "output", &start_output,
	       NULL);
  
  if(audio_channels > audio_channels_old){
    AgsHIndicator *hindicator;
	
    guint i;

    /* AgsOutput */
    channel = start_output;

    if(channel != NULL){
      g_object_ref(channel);
    }

    next_pad = NULL;
    
    while(channel != NULL){
      /* get some fields */
      next_pad = ags_channel_next_pad(channel),
      
      nth_channel = ags_channel_pad_nth(channel,
					audio_channels_old);

      g_object_unref(channel);

      channel = nth_channel;
      
      while(channel != next_pad){
	ags_channel_set_ability_flags(channel, (AGS_SOUND_ABILITY_WAVE));
	
	/* get some fields */
	g_object_get(channel,
		     "output-soundcard", &output_soundcard,
		     "first-recycling", &first_recycling,
		     NULL);

	/* audio signal */
	audio_signal = ags_audio_signal_new(output_soundcard,
					    (GObject *) first_recycling,
					    NULL);
	audio_signal->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;
	ags_audio_signal_stream_resize(audio_signal,
				       3);
	ags_recycling_add_audio_signal(first_recycling,
				       audio_signal);

	if(output_soundcard != NULL){
	  g_object_unref(output_soundcard);
	}

	if(first_recycling != NULL){
	  g_object_unref(first_recycling);
	}
	
	/* iterate */
	next_channel = ags_channel_next(channel);

	g_object_unref(channel);

	channel = next_channel;
      }
    }

    if(next_pad != NULL){
      g_object_unref(next_pad);
    }

    if(input_pads > 0){      
    }
    
    if(output_pads > 0){
      /* AgsOutput */
      /* ags-play-wave */
      ags_recall_factory_create(audio,
				NULL, NULL,
				"ags-play-wave",
				audio_channels_old, audio_channels, 
				0, output_pads,
				(AGS_RECALL_FACTORY_OUTPUT |
				 AGS_RECALL_FACTORY_PLAY |
				 AGS_RECALL_FACTORY_ADD),
				0);

      /* ags-capture-wave */
      ags_recall_factory_create(audio,
				NULL, NULL,
				"ags-capture-wave",
				audio_channels_old, audio_channels, 
				0, output_pads,
				(AGS_RECALL_FACTORY_OUTPUT |
				 AGS_RECALL_FACTORY_PLAY |
				 AGS_RECALL_FACTORY_ADD),
				0);
      
      /* ags-peak */
      ags_recall_factory_create(audio,
				NULL, NULL,
				"ags-peak",
				audio_channels, audio_channels_old, 
				0, output_pads,
				(AGS_RECALL_FACTORY_OUTPUT |
				 AGS_RECALL_FACTORY_PLAY |
				 AGS_RECALL_FACTORY_ADD),
				0);
    }
    
    /* widgets */
    for(i = audio_channels_old; i < audio_channels; i++){
      hindicator = ags_hindicator_new();
      gtk_box_pack_start((GtkBox *) audiorec->hindicator_vbox,
			 (GtkWidget *) hindicator,
			 FALSE, FALSE,
			 8);
    }

    gtk_widget_show_all((GtkWidget *) audiorec->hindicator_vbox);
  }else{
    GList *list, *list_start;

    list_start =
      list = gtk_container_get_children((GtkContainer *) audiorec->hindicator_vbox);

    list = g_list_nth(list_start,
		      audio_channels);
    
    while(list != NULL){
      gtk_widget_destroy((GtkWidget *) list->data);
      
      list = list->next;
    }

    g_list_free(list_start);
  }

  /* unref */
  if(start_output != NULL){
    g_object_unref(start_output);
  }
}
Esempio n. 4
0
void
ags_audiorec_output_map_recall(AgsAudiorec *audiorec, guint output_pad_start)
{
  AgsWindow *window;
  
  AgsAudio *audio;
  AgsChannel *start_output;
  AgsChannel *output, *next_output, *nth_output;
  
  guint output_pads;
  guint audio_channels;
  
  if(audiorec->mapped_output_pad > output_pad_start){
    return;
  }

  window = (AgsWindow *) gtk_widget_get_ancestor((GtkWidget *) audiorec,
						 AGS_TYPE_WINDOW);

  audio = AGS_MACHINE(audiorec)->audio;

  g_object_get(audio,
	       "output", &start_output,
	       "output-pads", &output_pads,
	       "audio-channels", &audio_channels,
	       NULL);
  
  /* ags-peak */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-peak",
			    0, audio_channels, 
			    output_pad_start, output_pads,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_PLAY |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  /* ags-play-wave */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-play-wave",
			    0, audio_channels,
			    output_pad_start, output_pads,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_PLAY |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  nth_output = ags_channel_pad_nth(start_output,
				   output_pad_start);

  output = nth_output;

  next_output = NULL;
  
  while(output != NULL){
    GList *start_play, *play;

    g_object_get(output,
		 "play", &start_play,
		 NULL);

    play = ags_recall_find_type(start_play,
				AGS_TYPE_PLAY_WAVE_CHANNEL_RUN);

    if(play != NULL){
      GValue value = {0,};
      
      ags_seekable_seek(AGS_SEEKABLE(play->data),
			(gint64) 16 * window->navigation->position_tact->adjustment->value,
			AGS_SEEK_SET);
    }

    g_list_free_full(start_play,
		     g_object_unref);

    /* iterate */
    next_output = ags_channel_next(output);

    g_object_unref(output);

    output = next_output;
  }

  if(next_output != NULL){
    g_object_unref(next_output);
  }
  
  /* ags-capture-wave */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-capture-wave",
			    0, audio_channels,
			    output_pad_start, output_pads,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_PLAY |
			     AGS_RECALL_FACTORY_ADD),
			    0);

  nth_output = ags_channel_pad_nth(start_output,
				   output_pad_start);

  output = nth_output;

  next_output = NULL;
  
  while(output != NULL){
    GList *start_play, *play;

    g_object_get(output,
		 "play", &start_play,
		 NULL);

    play = ags_recall_find_type(start_play,
				AGS_TYPE_CAPTURE_WAVE_CHANNEL_RUN);

    if(play != NULL){
      GValue value = {0,};
      
      ags_seekable_seek(AGS_SEEKABLE(play->data),
			(gint64) 16 * window->navigation->position_tact->adjustment->value,
			AGS_SEEK_SET);
    }

    g_list_free_full(start_play,
		     g_object_unref);

    /* iterate */
    next_output = ags_channel_next(output);

    g_object_unref(output);

    output = next_output;
  }  

  if(next_output != NULL){
    g_object_unref(next_output);
  }

  /* unref */
  if(start_output != NULL){
    g_object_unref(start_output);
  }

  audiorec->mapped_output_pad = output_pads;
}
Esempio n. 5
0
void
ags_audio_test_link_channel()
{
  AgsChannel *channel, *link;
  AgsChannel *output, *first_channel;

  guint i;

  GError *error;
  
  /* audio - master */
  test_link_channel.master = ags_audio_new(devout);
  test_link_channel.master->flags |= AGS_AUDIO_ASYNC;
  
  ags_audio_set_audio_channels(test_link_channel.master,
			       AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_link_channel.master,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_INPUT_PADS, 0);
  ags_audio_set_pads(test_link_channel.master,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_OUTPUT_PADS, 0);

  /* audio - slave 0 */
  test_link_channel.slave_0 = ags_audio_new(devout);
  test_link_channel.slave_0->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
				       AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_link_channel.slave_0,
			       AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_link_channel.slave_0,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_INPUT_PADS, 0);
  ags_audio_set_pads(test_link_channel.slave_0,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_OUTPUT_PADS, 0);

  /* audio - slave 1 */
  test_link_channel.slave_1 = ags_audio_new(devout);
  test_link_channel.slave_1->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
				       AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_link_channel.slave_1,
			       AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_link_channel.slave_1,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_INPUT_PADS, 0);
  ags_audio_set_pads(test_link_channel.slave_1,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_OUTPUT_PADS, 0);

  /* audio - slave 2 */
  test_link_channel.slave_2 = ags_audio_new(devout);
  test_link_channel.slave_2->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
				       AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_link_channel.slave_2,
			       AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_link_channel.slave_2,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_INPUT_PADS, 0);
  ags_audio_set_pads(test_link_channel.slave_2,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_OUTPUT_PADS, 0);

  /* setup link master to slave_0 */
  /* connect callback */
  channel = test_link_channel.master->input;
  link = test_link_channel.slave_0->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    //TODO:JK: implement me
    /*
    g_signal_connect(G_OBJECT(channel), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.master);

    g_signal_connect(G_OBJECT(link), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.slave_0);
    */
    
    channel = channel->next;
    link = link->next;
  }

  /* set link */
  channel = test_link_channel.master->input;
  link = test_link_channel.slave_0->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);

    /* assert link set */
    CU_ASSERT(error == NULL);
    CU_ASSERT(channel->link == link);
    CU_ASSERT(link->link == channel);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == link->first_recycling);
    CU_ASSERT(channel->last_recycling == link->last_recycling);

    /* iterate */
    channel = channel->next;
    link = link->next;
  }

  /* check output recycling */
  output = test_link_channel.master->output;
  first_channel = 
    link = test_link_channel.slave_0->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_0_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->first_recycling == link->first_recycling);
    CU_ASSERT(output->last_recycling == link->last_recycling);
  }  
  
  /* setup link master to slave_1 */
  /* connect callback */
  channel = ags_channel_pad_nth(test_link_channel.master->input,
				1);
  link = test_link_channel.slave_1->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    //TODO:JK: implement me
    /*
    g_signal_connect(G_OBJECT(channel), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.master);

    g_signal_connect(G_OBJECT(link), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.slave_1);
    */
    
    channel = channel->next;
    link = link->next;
  }

  /* set link */
  channel = ags_channel_pad_nth(test_link_channel.master->input,
				1);
  link = test_link_channel.slave_1->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);

    /* assert link set */
    CU_ASSERT(error == NULL);
    CU_ASSERT(channel->link == link);
    CU_ASSERT(link->link == channel);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == link->first_recycling);
    CU_ASSERT(channel->last_recycling == link->last_recycling);

    /* iterate */
    channel = channel->next;
    link = link->next;
  }

  /* check output recycling */
  output = test_link_channel.master->output;
  first_channel = test_link_channel.slave_0->output;
  link = test_link_channel.slave_1->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_1_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->first_recycling == first_channel->first_recycling);
    CU_ASSERT(output->last_recycling == link->last_recycling);

    output = output->next;
    first_channel = first_channel->next;
    link = link->next;
  }  
  
  /* setup link master to slave_2 */
  /* connect callback */
  channel = ags_channel_pad_nth(test_link_channel.master->input,
				2);
  link = test_link_channel.slave_2->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    //TODO:JK: implement me
    /*
    g_signal_connect(G_OBJECT(channel), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.master);

    g_signal_connect(G_OBJECT(link), "set-link",
		     G_CALLBACK(ags_audio_test_set_link_callback), test_link_channel.slave_2);
    */
    
    channel = channel->next;
    link = link->next;
  }

  /* set link */
  channel = ags_channel_pad_nth(test_link_channel.master->input,
				2);
  link = test_link_channel.slave_2->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);

    /* assert link set */
    CU_ASSERT(error == NULL);
    CU_ASSERT(channel->link == link);
    CU_ASSERT(link->link == channel);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == link->first_recycling);
    CU_ASSERT(channel->last_recycling == link->last_recycling);

    /* iterate */
    channel = channel->next;
    link = link->next;
  }

  /* check output recycling */
  output = test_link_channel.master->output;
  first_channel = test_link_channel.slave_0->output;
  link = test_link_channel.slave_2->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_LINK_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_LINK_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->first_recycling == first_channel->first_recycling);
    CU_ASSERT(output->last_recycling == link->last_recycling);

    output = output->next;
    first_channel = first_channel->next;
    link = link->next;
  }  
}
Esempio n. 6
0
void
ags_audio_test_finalize_linked_channel()
{
  AgsChannel *channel, *link;
  AgsChannel *output, *current, *last_channel;

  guint i;

  GError *error;
  
  /* audio - master */
  test_finalize_linked_channel.master = ags_audio_new(devout);
  test_finalize_linked_channel.master->flags |= AGS_AUDIO_ASYNC;
  
  ags_audio_set_audio_channels(test_finalize_linked_channel.master,
			       AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_finalize_linked_channel.master,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_INPUT_PADS, 0);
  ags_audio_set_pads(test_finalize_linked_channel.master,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_OUTPUT_PADS, 0);

  /* audio - slave 0 */
  test_finalize_linked_channel.slave_0 = ags_audio_new(devout);
  test_finalize_linked_channel.slave_0->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
						  AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_finalize_linked_channel.slave_0,
			       AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_0_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_finalize_linked_channel.slave_0,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_0_INPUT_PADS, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_0,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_0_OUTPUT_PADS, 0);

  /* audio - slave 1 */
  test_finalize_linked_channel.slave_1 = ags_audio_new(devout);
  test_finalize_linked_channel.slave_1->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
						  AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_finalize_linked_channel.slave_1,
			       AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_finalize_linked_channel.slave_1,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_INPUT_PADS, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_1,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_OUTPUT_PADS, 0);

  /* audio - slave 2 */
  test_finalize_linked_channel.slave_2 = ags_audio_new(devout);
  test_finalize_linked_channel.slave_2->flags |= (AGS_AUDIO_OUTPUT_HAS_RECYCLING |
						  AGS_AUDIO_ASYNC);
  
  ags_audio_set_audio_channels(test_finalize_linked_channel.slave_2,
			       AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_AUDIO_CHANNELS, 0);
  
  ags_audio_set_pads(test_finalize_linked_channel.slave_2,
		     AGS_TYPE_INPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_INPUT_PADS, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_2,
		     AGS_TYPE_OUTPUT,
		     AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_OUTPUT_PADS, 0);

  /* setup link master to slave_0 */
  /* set link */
  channel = test_finalize_linked_channel.master->input;
  link = test_finalize_linked_channel.slave_0->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_0_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);

    /* iterate */
    channel = channel->next;
    link = link->next;
  }

  /* setup link master to slave_1 */
  /* set link */
  channel = ags_channel_pad_nth(test_finalize_linked_channel.master->input,
				1);
  link = test_finalize_linked_channel.slave_1->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);

    /* iterate */
    channel = channel->next;
    link = link->next;
  }
  
  /* setup link master to slave_2 */
  /* set link */
  channel = ags_channel_pad_nth(test_finalize_linked_channel.master->input,
				2);
  link = test_finalize_linked_channel.slave_2->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    error = NULL;
    ags_channel_set_link(channel, link,
			 &error);
    
    /* iterate */
    channel = channel->next;
    link = link->next;
  }

  /* asserts */
  /* unset link */
  channel = test_finalize_linked_channel.master->input;

  ags_audio_set_pads(test_finalize_linked_channel.slave_0,
		     AGS_TYPE_INPUT,
		     0, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_0,
		     AGS_TYPE_OUTPUT,
		     0, 0);

  g_object_unref(test_finalize_linked_channel.slave_0);
  
  for(i = 0; i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS; i++){
    /* assert link set */
    CU_ASSERT(channel->link == NULL);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == NULL);
    CU_ASSERT(channel->last_recycling == NULL);

    /* iterate */
    channel = channel->next;
  }

  /* check output recycling */
  output = test_finalize_linked_channel.master->output;
  current = test_finalize_linked_channel.slave_1->output;
  
  for(i = 0; i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->first_recycling == current->first_recycling);

    output = output->next;
    current = current->next;
  }  

  output = test_finalize_linked_channel.master->output;
  last_channel = test_finalize_linked_channel.slave_2->output;
  
  for(i = 0; i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->last_recycling == last_channel->last_recycling);

    output = output->next;
    last_channel = last_channel->next;
  }  
  
  /* unset link */
  channel = ags_channel_pad_nth(test_finalize_linked_channel.master->input,
				1);
  
  ags_audio_set_pads(test_finalize_linked_channel.slave_1,
		     AGS_TYPE_INPUT,
		     0, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_1,
		     AGS_TYPE_OUTPUT,
		     0, 0);

  g_object_unref(test_finalize_linked_channel.slave_1);
  
  for(i = 0; i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS; i++){
    /* assert link set */
    CU_ASSERT(channel->link == NULL);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == NULL);
    CU_ASSERT(channel->last_recycling == NULL);

    /* iterate */
    channel = channel->next;
  }

  /* check output recycling */
  output = test_finalize_linked_channel.master->output;
  last_channel = test_finalize_linked_channel.slave_2->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_1_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    /* check recycling */
    CU_ASSERT(output->first_recycling == last_channel->first_recycling);
    CU_ASSERT(output->last_recycling == last_channel->last_recycling);

    output = output->next;
    last_channel = last_channel->next;
  }  

  /* unset link */
  channel = ags_channel_pad_nth(test_finalize_linked_channel.master->input,
				2);

  ags_audio_set_pads(test_finalize_linked_channel.slave_2,
		     AGS_TYPE_INPUT,
		     0, 0);
  ags_audio_set_pads(test_finalize_linked_channel.slave_2,
		     AGS_TYPE_OUTPUT,
		     0, 0);

  g_object_unref(test_finalize_linked_channel.slave_2);

  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    /* assert link unset */
    CU_ASSERT(channel->link == NULL);

    /* check recycling */
    CU_ASSERT(channel->first_recycling == NULL);
    CU_ASSERT(channel->last_recycling == NULL);

    /* iterate */
    channel = channel->next;
  }

  /* check output recycling */
  output = test_finalize_linked_channel.master->output;
  
  for(i = 0;
      i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_SLAVE_2_AUDIO_CHANNELS &&
	i < AGS_AUDIO_TEST_FINALIZE_LINKED_CHANNEL_MASTER_AUDIO_CHANNELS;
      i++){
    CU_ASSERT(output->first_recycling == NULL);
    CU_ASSERT(output->last_recycling == NULL);

    output = output->next;
  }  
}
Esempio n. 7
0
void
ags_matrix_map_recall(AgsMachine *machine)
{
  AgsMatrix *matrix;

  AgsAudio *audio;
  AgsChannel *channel;
  AgsPattern *pattern;

  AgsDelayAudio *play_delay_audio;
  AgsDelayAudioRun *play_delay_audio_run;
  AgsCountBeatsAudio *play_count_beats_audio;
  AgsCountBeatsAudioRun *play_count_beats_audio_run;
  AgsCopyPatternAudio *recall_copy_pattern_audio;
  AgsCopyPatternAudioRun *recall_copy_pattern_audio_run;
  AgsPlayNotationAudio  *play_notation;
  AgsCopyPatternChannel *copy_pattern_channel;

  GList *notation;
  GList *list;

  guint i, j;

  GValue value = {0,};

  if((AGS_MACHINE_MAPPED_RECALL & (machine->flags)) != 0 ||
     (AGS_MACHINE_PREMAPPED_RECALL & (machine->flags)) != 0){
    return;
  }

  audio = machine->audio;
  matrix = AGS_MATRIX(machine);

  /* ags-delay */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-delay\0",
			    0, 0,
			    0, 0,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_ADD |
			     AGS_RECALL_FACTORY_PLAY),
			    0);

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

  if(list != NULL){
    play_delay_audio_run = AGS_DELAY_AUDIO_RUN(list->data);
    //    AGS_RECALL(play_delay_audio_run)->flags |= AGS_RECALL_PERSISTENT;
  }
  
  /* ags-count-beats */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-count-beats\0",
			    0, 0,
			    0, 0,
			    (AGS_RECALL_FACTORY_OUTPUT |
			     AGS_RECALL_FACTORY_ADD |
			     AGS_RECALL_FACTORY_PLAY),
			    0);
  
  list = ags_recall_find_type(audio->play, AGS_TYPE_COUNT_BEATS_AUDIO_RUN);

  if(list != NULL){
    play_count_beats_audio_run = AGS_COUNT_BEATS_AUDIO_RUN(list->data);

    /* set dependency */  
    g_object_set(G_OBJECT(play_count_beats_audio_run),
		 "delay-audio-run\0", play_delay_audio_run,
		 NULL);
  }

  /* ags-copy-pattern */
  ags_recall_factory_create(audio,
			    NULL, NULL,
			    "ags-copy-pattern\0",
			    0, audio->audio_channels,
			    0, audio->input_lines,
			    (AGS_RECALL_FACTORY_INPUT |
			     AGS_RECALL_FACTORY_ADD |
			     AGS_RECALL_FACTORY_RECALL),
			    0);

  list = ags_recall_find_type(audio->recall, AGS_TYPE_COPY_PATTERN_AUDIO_RUN);

  if(list != NULL){
    recall_copy_pattern_audio_run = AGS_COPY_PATTERN_AUDIO_RUN(list->data);

    /* set dependency */
    g_object_set(G_OBJECT(recall_copy_pattern_audio_run),
		 "delay-audio-run\0", play_delay_audio_run,
		 "count-beats-audio-run\0", play_count_beats_audio_run,
		 NULL);

  }

  /* set pattern object on port */
  channel = ags_channel_pad_nth(audio->input, 0);
      
  for(i = 0; i < audio->input_pads; i++){
    for(j = 0; j < audio->audio_channels; j++){
      list = ags_recall_template_find_type(channel->recall, AGS_TYPE_COPY_PATTERN_CHANNEL);
      copy_pattern_channel = AGS_COPY_PATTERN_CHANNEL(list->data);

      list = channel->pattern;
      pattern = AGS_PATTERN(list->data);

      copy_pattern_channel->pattern->port_value.ags_port_object = (GObject *) pattern;
	  
      ags_portlet_set_port(AGS_PORTLET(pattern), copy_pattern_channel->pattern);
	  
      channel = channel->next;
    }
  }

  /*  */
  list = audio->recall;

  while((list = ags_recall_find_type(list,
				     AGS_TYPE_PLAY_NOTATION_AUDIO)) != NULL){
    play_notation = AGS_PLAY_NOTATION_AUDIO(list->data);

    ags_port_safe_read(play_notation->notation,
		       &value);

    if(g_value_get_object(&value) == NULL){
      notation = audio->notation;
	
      while(notation != NULL){
	g_object_set(G_OBJECT(play_notation),
		     "notation\0", notation->data,
		     NULL);
	
	notation = notation->next;
      }
    }
	
    list = list->next;
  }


  /* depending on destination */
  ags_matrix_input_map_recall(matrix, 0);

  /* depending on destination */
  ags_matrix_output_map_recall(matrix, 0);

  AGS_MACHINE_CLASS(ags_matrix_parent_class)->map_recall(machine);
}