Chapter 4. The soundcard and sequencer interface

Table of Contents

Gathering PCM information of soundcard
Obtain audio buffer
Read from MIDI device

With AgsSoundcard and AgsSequencer interface you can obtain information about output or input devices. Getting the next buffer for playback something can be achieved, too. As well reading MIDI data from current buffer is supported. Note these operations are performed all delayed in order to avoid concurrent memory access.

Latency is at most one buffer time. Operations on buffers might be performed non-blocking so the thread returns earlier than expected. This has the advantage of controlling timings and let the thread continue to do more synchronization runs. Real-time behaviour is indicated as all pending sync operations were fulfilled as the next buffer is needed.

The Advanced Gtk+ Sequencer framework implements following soundcard objects. Note to register soundcards by a sound server make use of AgsSoundServer interface. This applies to JACK, Pulseaudio and CoreAudio backend.

The Advanced Gtk+ Sequencer framework implements following sequencer objects.

Gathering PCM information of soundcard

In this short example we just get some information out of AgsSoundcard by using void ags_soundcard_pcm_info(AgsSoundcard*, gchar*, guint*, guint*, guint*, guint*, guint*, guint*, GError*). It tells us the card identifier, minimum and maximum supported audio channels, samplerate and buffer size.

Example 4.1. PCM information from AgsSoundcard

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

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

AgsApplicationContext *application_context;

GObject *soundcard;

GList *start_list;

guint channels_min, channels_max;
guint rate_min, rate_max;
guint buffer_size_min, buffer_size_max;

GError *error;

application_context = ags_application_context_get_instance();

start_list = ags_sound_provider_get_soundcard(AGS_SOUND_PROVIDER(application_context));

if(start_list != NULL){
  soundcard = G_OBJECT(start_list->data);

  error = NULL;
                         &channels_min, &channels_max,
                         &rate_min, &rate_max,
                         &buffer_size_min, &buffer_size_max,
  if(error != NULL){
    g_warning("%s", error->msg);


		 (GDestroyNotify) g_object_unref);