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 isn't a recall itself but you can use it to retrieve a different context.
Example 9.1. Creating AgsRecallContainer
AgsMachine *machine; AgsAudio *audio; AgsChannel *channel; AgsRecallContainer *echo_container; GObject *soundcard; /* some pseudo code */ machine = (AgsMachine *) gtk_widget_get_ancestor(widget, AGS_TYPE_MACHINE); /* retrieve some essencial objects */ audio = machine->audio; soundcard = audio->soundcard; /* create the container */ recall_container = (AgsRecallContainer *) g_object_new(AGS_TYPE_RECALL_CONTAINER, NULL); ags_audio_add_recall_container(audio, (GObject *) recall_container);
This is a context you want to use for fields applicable to the entire AgsAudio object.
Example 9.2. Creating AgsEchoAudio
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;
This context you can use for fields applicable to the AgsChannel you want to modify.
Example 9.3. Creating AgsEchoChannel
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;
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
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;
The AgsRecallChannelRun behaves like an AgsRecallAudioRun but is designated to an AgsChannel object.
Example 9.5. Creating AgsEchoChannelRun
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;