Hands-On instantiating an effect

After you got an overview of the basic lifecycle of an effect it's time to create an effect. In this guide we will cover instatiating an effect by using the echo effect. In the following chapter we'll take a look inside the echo effect.

AgsRecallContainer

AgsRecallContainer isn't a recall itself but you can use it to retrieve a different context.

Example 9.1. Creating AgsRecallContainer

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

AgsAudio *audio;
AgsChannel *channel;
AgsRecallContainer *echo_container;

GObject *soundcard;

soundcard = ags_devout_new(NULL);
audio = ags_audio_new(devout);

/* create the container */
recall_container = (AgsRecallContainer *) g_object_new(AGS_TYPE_RECALL_CONTAINER,
                                                       NULL);
ags_audio_add_recall_container(audio,
			       (GObject *) recall_container);

	  

AgsRecallAudio context

This is a context you want to use for fields applicable to the entire AgsAudio object.

Example 9.2. Creating AgsEchoAudio

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

AgsEchoAudio *echo_audio;

echo_audio = (AgsEchoAudio *) g_object_new(AGS_TYPE_ECHO_AUDIO,
					   "soundcard\0", soundcard,
                                           "audio\0", audio,
                                           "recall-container\0", echo_container,
                                           NULL);

AGS_RECALL(echo_audio)->flags = AGS_RECALL_TEMPLATE;

	  

AgsRecallChannel context

This context you can use for fields applicable to the AgsChannel you want to modify.

Example 9.3. Creating AgsEchoChannel

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

AgsEchoChannel *echo_channel;

echo_channel = (AgsEchoChannel *) g_object_new(AGS_TYPE_ECHO_CHANNEL,
					       "soundcard\0", soundcard,
                                               "channel\0", channel,
                                               "recall-container\0", echo_container,
                                               "delay\0", (devout->frequency * (60 / devout->bpm) / 4),
                                               "repeat\0", 3,
                                               "fade\0", -0.25,
                                               "dry\0", 0.5,
                                               NULL);

AGS_RECALL(echo_channel)->flags = AGS_RECALL_TEMPLATE;

	  

AgsRecallAudioRun context

The AgsRecallAudioRun class will be duplicated for a parental running AgsChannel. There may be several AgsChannel objects as parental owning a run.

Example 9.4. Creating AgsEchoAudioRun

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

echo_audio_run = (AgsEchoAudioRun *) g_object_new(AGS_TYPE_ECHO_AUDIO_RUN,
						  "soundcard\0", soundcard,
                                                  "audio\0", audio,
                                                  "recall-audio\0", echo_audio,
                                                  "recall-container\0", echo_container,
                                                  NULL);

AGS_RECALL(echo_audio_run)->flags = AGS_RECALL_TEMPLATE;

	  

AgsRecallChannelRun context

The AgsRecallChannelRun behaves like an AgsRecallAudioRun but is designated to an AgsChannel object.

Example 9.5. Creating AgsEchoChannelRun

#include <glib.h>
#include <glib-object.h>

#include <ags/libags.h>
#include <ags/libags-audio.h>

AgsEchoChannelRun *echo_channel_run;

echo_channel_run = (AgsEchoChannelRun *) g_object_new(AGS_TYPE_ECHO_CHANNEL_RUN,
						      "soundcard\0", soundcard,
                                                      "channel\0", channel
                                                      "recall-channel\0", echo_channel,
                                                      "recall-container\0", echo_container,
                                                      NULL);

AGS_RECALL(echo_channel_run)->flags = AGS_RECALL_TEMPLATE;