AgsDevout

AgsDevout — Outputting to soundcard

Synopsis

#include <ags/audio/ags_devout.h>

#define             AGS_DEVOUT_DEFAULT_BPM
#define             AGS_DEVOUT_DEFAULT_BUFFER_SIZE
#define             AGS_DEVOUT_DEFAULT_DELAY
#define             AGS_DEVOUT_DEFAULT_FORMAT
#define             AGS_DEVOUT_DEFAULT_JIFFIE
#define             AGS_DEVOUT_DEFAULT_PERIOD
#define             AGS_DEVOUT_DEFAULT_SAMPLERATE
#define             AGS_DEVOUT_DEFAULT_SCALE
#define             AGS_DEVOUT_DEFAULT_TACT
#define             AGS_DEVOUT_DEFAULT_TACTRATE
#define             AGS_DEVOUT_DEFAULT_TACT_JIFFIE
#define             AGS_DEVOUT_ERROR
#define             AGS_DEVOUT_PLAY                     (ptr)
#define             AGS_DEVOUT_PLAY_DOMAIN              (ptr)
struct              AgsDevout;
struct              AgsDevoutClass;
enum                AgsDevoutError;
enum                AgsDevoutFlags;
struct              AgsDevoutPlay;
struct              AgsDevoutPlayDomain;
enum                AgsDevoutPlayFlags;
enum                AgsDevoutResolutionMode;
GQuark              ags_devout_error_quark              ();
void                ags_devout_list_cards               (GList **card_id,
                                                         GList **card_name);
AgsDevout *         ags_devout_new                      (GObject *ags_main);
void                ags_devout_note_offset_changed      (AgsDevout *devout,
                                                         guint note_offset);
void                ags_devout_pcm_info                 (char *card_id,
                                                         guint *channels_min,
                                                         guint *channels_max,
                                                         guint *rate_min,
                                                         guint *rate_max,
                                                         guint *buffer_size_min,
                                                         guint *buffer_size_max,
                                                         GError **error);
AgsDevoutPlay *     ags_devout_play_alloc               ();
AgsDevoutPlayDomain * ags_devout_play_domain_alloc      ();
void                ags_devout_play_domain_free         (AgsDevoutPlayDomain *devout_play_domain);
AgsDevoutPlay *     ags_devout_play_find_source         (GList *devout_play,
                                                         GObject *source);
void                ags_devout_play_free                (AgsDevoutPlay *devout_play);
void                ags_devout_tic                      (AgsDevout *devout);

Description

AgsDevout represents a soundcard and supports output.

Details

AGS_DEVOUT_DEFAULT_BPM

#define AGS_DEVOUT_DEFAULT_BPM (120.0)

AGS_DEVOUT_DEFAULT_BUFFER_SIZE

#define AGS_DEVOUT_DEFAULT_BUFFER_SIZE (944)

AGS_DEVOUT_DEFAULT_DELAY

#define AGS_DEVOUT_DEFAULT_DELAY (AGS_DEVOUT_DEFAULT_JIFFIE * (60.0 / AGS_DEVOUT_DEFAULT_BPM))

AGS_DEVOUT_DEFAULT_FORMAT

#define AGS_DEVOUT_DEFAULT_FORMAT (AGS_DEVOUT_RESOLUTION_16_BIT)

AGS_DEVOUT_DEFAULT_JIFFIE

#define AGS_DEVOUT_DEFAULT_JIFFIE ((double) AGS_DEVOUT_DEFAULT_SAMPLERATE / (double) AGS_DEVOUT_DEFAULT_BUFFER_SIZE)

AGS_DEVOUT_DEFAULT_PERIOD

#define AGS_DEVOUT_DEFAULT_PERIOD (64.0)

AGS_DEVOUT_DEFAULT_SAMPLERATE

#define AGS_DEVOUT_DEFAULT_SAMPLERATE (44100.0)

AGS_DEVOUT_DEFAULT_SCALE

#define AGS_DEVOUT_DEFAULT_SCALE (1.0)

AGS_DEVOUT_DEFAULT_TACT

#define AGS_DEVOUT_DEFAULT_TACT (1.0 / 1.0)

AGS_DEVOUT_DEFAULT_TACTRATE

#define AGS_DEVOUT_DEFAULT_TACTRATE (1.0 / AGS_DEVOUT_DEFAULT_TACT_JIFFIE)

AGS_DEVOUT_DEFAULT_TACT_JIFFIE

#define AGS_DEVOUT_DEFAULT_TACT_JIFFIE (60.0 / AGS_DEVOUT_DEFAULT_BPM * AGS_DEVOUT_DEFAULT_TACT)

AGS_DEVOUT_ERROR

#define AGS_DEVOUT_ERROR (ags_devout_error_quark())

AGS_DEVOUT_PLAY()

#define AGS_DEVOUT_PLAY(ptr)           ((AgsDevoutPlay *)(ptr))

AGS_DEVOUT_PLAY_DOMAIN()

#define AGS_DEVOUT_PLAY_DOMAIN(ptr)    ((AgsDevoutPlayDomain *)(ptr))

struct AgsDevout

struct AgsDevout {
  GObject object;

  guint flags;

  guint dsp_channels;
  guint pcm_channels;
  guint bits;
  guint buffer_size;
  guint frequency; // sample_rate

  signed short** buffer;

  double bpm; // beats per minute

  gdouble *delay; // count of tics within buffer size
  guint *attack; // where currently tic resides in the stream's offset, measured in 1/64 of bpm

  gdouble delay_counter; // next time attack changeing when delay_counter == delay
  guint tic_counter; // in the range of default period

  union{
    struct _AgsOss{
      int device_fd;
      char *device;
    }oss;
    struct _AgsAlsa{
      char *device;
      int rc;
      snd_pcm_t *handle;
      snd_async_handler_t *ahandler;
      snd_pcm_hw_params_t *params;
    }alsa;
  }out;

  GObject *ags_main;
  
  GList *audio;
};

struct AgsDevoutClass

struct AgsDevoutClass {
  GObjectClass object;

  void (*play_init)(AgsDevout *devout,
		    GError **error);
  void (*play)(AgsDevout *devout,
	       GError **error);
  void (*stop)(AgsDevout *devout);

  void (*tic)(AgsDevout *devout);

  void (*note_offset_changed)(AgsDevout *devout, guint note_offset);
};

enum AgsDevoutError

typedef enum {
  AGS_DEVOUT_ERROR_LOCKED_SOUNDCARD,
} AgsDevoutError;

enum AgsDevoutFlags

typedef enum {
  AGS_DEVOUT_BUFFER0                        = 1,
  AGS_DEVOUT_BUFFER1                        = 1 << 1,
  AGS_DEVOUT_BUFFER2                        = 1 << 2,
  AGS_DEVOUT_BUFFER3                        = 1 << 3,

  AGS_DEVOUT_ATTACK_FIRST                   = 1 << 4,

  AGS_DEVOUT_PLAY                           = 1 << 5,

  AGS_DEVOUT_LIBAO                          = 1 << 6,
  AGS_DEVOUT_OSS                            = 1 << 7,
  AGS_DEVOUT_ALSA                           = 1 << 8,

  AGS_DEVOUT_SHUTDOWN                       = 1 << 9,
  AGS_DEVOUT_START_PLAY                     = 1 << 10,

  AGS_DEVOUT_NONBLOCKING                    = 1 << 11,

  AGS_DEVOUT_TIMING_SET_0                   = 1 << 12,
  AGS_DEVOUT_TIMING_SET_1                   = 1 << 13,
} AgsDevoutFlags;

struct AgsDevoutPlay

struct AgsDevoutPlay {
  guint flags;

  AgsIteratorThread **iterator_thread;

  GObject *source;
  guint audio_channel;

  AgsRecallID **recall_id;
};

A AgsDevoutPlay represents the play/recall in AgsChannel or AgsRecall scope to do output to device.

guint flags;

the internal state

AgsIteratorThread **iterator_thread;

Super-threaded related AgsThread. Index 0 playback, 1 sequencer and 2 notation.

GObject *source;

either AgsChannel or AgsRecall

guint audio_channel;

destination audio channel

AgsRecallID **recall_id;

array pointing to appropriate AgsRecallID. Index 0 playback, 1 sequencer and 2 notation.

struct AgsDevoutPlayDomain

struct AgsDevoutPlayDomain {
  GObject *domain;
  
  gboolean playback;
  gboolean sequencer;
  gboolean notation;

  GList *devout_play;
};

A AgsDevoutPlayDomain represents the entire possible play/recall context.

GObject *domain;

the source

gboolean playback;

if TRUE playback is on

gboolean sequencer;

if TRUE sequencer is on

gboolean notation;

if TRUE notation is on

GList *devout_play;

a GList of AgsDevoutPlay

enum AgsDevoutPlayFlags

typedef enum {
  AGS_DEVOUT_PLAY_DONE              = 1,
  AGS_DEVOUT_PLAY_REMOVE            = 1 <<  1,
  AGS_DEVOUT_PLAY_CHANNEL           = 1 <<  2,
  AGS_DEVOUT_PLAY_PAD               = 1 <<  3,
  AGS_DEVOUT_PLAY_AUDIO             = 1 <<  4,
  AGS_DEVOUT_PLAY_PLAYBACK          = 1 <<  5,
  AGS_DEVOUT_PLAY_SEQUENCER         = 1 <<  6,
  AGS_DEVOUT_PLAY_NOTATION          = 1 <<  7,
  AGS_DEVOUT_PLAY_SUPER_THREADED    = 1 <<  8,
} AgsDevoutPlayFlags;

enum AgsDevoutResolutionMode

typedef enum {
  AGS_DEVOUT_RESOLUTION_8_BIT    = 8,
  AGS_DEVOUT_RESOLUTION_16_BIT   = 16,
  AGS_DEVOUT_RESOLUTION_24_BIT   = 24,
  AGS_DEVOUT_RESOLUTION_32_BIT   = 32,
  AGS_DEVOUT_RESOLUTION_64_BIT   = 64,
} AgsDevoutResolutionMode;

ags_devout_error_quark ()

GQuark              ags_devout_error_quark              ();

ags_devout_list_cards ()

void                ags_devout_list_cards               (GList **card_id,
                                                         GList **card_name);

List available soundcards.

card_id :

alsa identifier

card_name :

card name

Since 0.4


ags_devout_new ()

AgsDevout *         ags_devout_new                      (GObject *ags_main);

Creates an AgsDevout, refering to ags_main.

ags_main :

the AgsMain

Returns :

a new AgsDevout

Since 0.3


ags_devout_note_offset_changed ()

void                ags_devout_note_offset_changed      (AgsDevout *devout,
                                                         guint note_offset);

ags_devout_pcm_info ()

void                ags_devout_pcm_info                 (char *card_id,
                                                         guint *channels_min,
                                                         guint *channels_max,
                                                         guint *rate_min,
                                                         guint *rate_max,
                                                         guint *buffer_size_min,
                                                         guint *buffer_size_max,
                                                         GError **error);

List soundcard settings.

card_id :

alsa identifier

channels_min :

minimum channels supported

channels_max :

maximum channels supported

rate_min :

minimum samplerate supported

rate_max :

maximum samplerate supported

buffer_size_min :

minimum buffer size supported buffer_size_max maximum buffer size supported

error :

on success NULL

Since 0.4


ags_devout_play_alloc ()

AgsDevoutPlay *     ags_devout_play_alloc               ();

Allocs an AgsDevoutPlay.

Returns :

the devout play

Since 0.4


ags_devout_play_domain_alloc ()

AgsDevoutPlayDomain * ags_devout_play_domain_alloc      ();

Allocs an AgsDevoutPlayDomain.

Returns :

the devout play domain

Since 0.4


ags_devout_play_domain_free ()

void                ags_devout_play_domain_free         (AgsDevoutPlayDomain *devout_play_domain);

Frees an AgsDevoutPlayDomain.

devout_play_domain :

the devout play domain

Since 0.4


ags_devout_play_find_source ()

AgsDevoutPlay *     ags_devout_play_find_source         (GList *devout_play,
                                                         GObject *source);

Find source

devout_play :

a GList containing AgsDevoutPlay

Returns :

the matching devout play

Since 0.4


ags_devout_play_free ()

void                ags_devout_play_free                (AgsDevoutPlay *devout_play);

Frees an AgsDevoutPlay.

devout_play :

the devout play

Since 0.4


ags_devout_tic ()

void                ags_devout_tic                      (AgsDevout *devout);

The tic of devout.

devout :

an AgsDevout

Since 0.4