Chapter 7. The recycling tree

Table of Contents

Add and remove audio signal

AgsRecycling has a strong relation to AgsChannel although not every channel might have its very own recycling. Rather having a reference to a start and end region of an inter-connnected AgsRecycling. It may create or destroy audio signals event based.

Inter-connected gets its meaning as ags_channel_set_recycling() invoked by ags_channel_set_link() connects AgsRecycling:next and AgsRecycling:prev together from different channels. Providing you the AgsRecyclingContext. A recycling context has generally one parent and many children from different channels.

AgsRecallID points to one recycling context in order to make decisions of what level you are running in. Theoretically super-threaded tree can run upto the recycling context level.

Note, recyclings have they own recall base object AgsRecallRecycling. Usually, you do ags_recall_add_child() to instances inherit of AgsRecallChannelRun.

Add and remove audio signal

The two signals ::add_audio_signal and ::remove_audio_signal should be invoked as adding or removing AgsAudioSignal to an AgsRecycling. Recalls act as producer or consumer of AgsAudioSignal. They do basically play notation or process your effects. Its are located in AgsAudio or AgsChannel.

There is generally a need for providing a template audio signal within your recycling. As this does this example. This reduces the overhead of reading files for every playing during a button click, notation or pattern.

Example 7.1. AgsRecycling and AgsAudioSignal

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

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

AgsRecycling *recycling;
AgsAudioSignal *template;

AgsApplicationContext *application_context;

GList *soundcard;

guint stream_length;

application_context = ags_application_context_get_instance();
soundcard = ags_sound_provider_get_soundcard(AGS_SOUND_PROVIDER(application_context));

/* create recycling */
recycling = ags_recycling_new(soundcard->data);

/* create audio signal and add to recycling */
stream_length = 5;

audio_signal = ags_audio_signal_new(soundcard->data,
                                    recycling,
                                    NULL,
                                    stream_length);
audio_signal->flags |= AGS_AUDIO_SIGNAL_TEMPLATE;
ags_recycling_add_audio_signal(recyclig,
                               audio_signal);