## AgsSoundResource

AgsSoundResource — read/write audio

## Stability Level

Stable, unless otherwise indicated

## Functions

gboolean | ags_sound_resource_open ()
gboolean | ags_sound_resource_rw_open ()
void | ags_sound_resource_load ()
void | ags_sound_resource_info ()
void | ags_sound_resource_set_presets ()
void | ags_sound_resource_get_presets ()
guint | ags_sound_resource_read ()
void | ags_sound_resource_write ()
void | ags_sound_resource_flush ()
void | ags_sound_resource_seek ()
GList * | ags_sound_resource_read_audio_signal ()
GList * | ags_sound_resource_read_audio_signal_at_once ()
GList * | ags_sound_resource_read_wave ()
void | ags_sound_resource_close ()

## Object Hierarchy

        GInterface
        ╰── AgsSoundResource

## Includes

    #include <ags/audio/file/ags_sound_resource.h>

## Description

The AgsSoundResource interface gives you a unique access to file related IO operations.

## Functions

### ags_sound_resource_open ()

    gboolean
    ags_sound_resource_open (AgsSoundResource *sound_resource,
                             gchar *filename);

Open `sound_resource` for reading and assign filename.

#### Parameters

sound_resource | the AgsSoundResource |
filename | the filename as string |

#### Returns

`TRUE` if operation was successful, otherwise `FALSE`.

Since: 3.0.0

### ags_sound_resource_rw_open ()

    gboolean
    ags_sound_resource_rw_open (AgsSoundResource *sound_resource,
                                gchar *filename,
                                guint audio_channels,
                                guint samplerate,
                                gboolean create);

Open `sound_resource` for reading/writing and assign filename. Setting `create` to `TRUE` causes to create the file if it doesn't exist.

#### Parameters

sound_resource | the AgsSoundResource |
filename | the filename as string |
audio_channels | the audio channels count |
samplerate | the samplerate |
create | if `TRUE` create file, otherwise don't |

#### Returns

`TRUE` if operation was successful, otherwise `FALSE`.

Since: 3.0.0

### ags_sound_resource_load ()

    void
    ags_sound_resource_load (AgsSoundResource *sound_resource);

Load audio data of `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |

Since: 3.0.0

### ags_sound_resource_info ()

    void
    ags_sound_resource_info (AgsSoundResource *sound_resource,
                             guint *frame_count,
                             guint *loop_start,
                             guint *loop_end);

Get information about `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
frame_count | return location of frame count |
loop_start | return location of loop-start |
loop_end | return location of loop-end |

Since: 3.0.0

### ags_sound_resource_set_presets ()

    void
    ags_sound_resource_set_presets (AgsSoundResource *sound_resource,
                                    guint channels,
                                    guint samplerate,
                                    guint buffer_size,
                                    AgsSoundcardFormat format);

Set presets of `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
channels | channels to set |
samplerate | samplerate to set |
buffer_size | buffer-size to set |
format | format to set |

Since: 3.0.0

### ags_sound_resource_get_presets ()

    void
    ags_sound_resource_get_presets (AgsSoundResource *sound_resource,
                                    guint *channels,
                                    guint *samplerate,
                                    guint *buffer_size,
                                    AgsSoundcardFormat *format);

Get presets of `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
channels | return location of channels |
samplerate | return location of samplerate |
buffer_size | return location of buffer-size |
format | return location of format |

Since: 3.0.0

### ags_sound_resource_read ()

    guint
    ags_sound_resource_read (AgsSoundResource *sound_resource,
                             void *dbuffer,
                             guint daudio_channels,
                             guint audio_channel,
                             guint frame_count,
                             AgsSoundcardFormat format);

Read `frame_count` number of frames from `sound_resource` and copy the data to `dbuffer` using `format` by skipping `daudio_channels` .

#### Parameters

sound_resource | the AgsSoundResource |
dbuffer | the destination buffer |
daudio_channels | destination buffer audio channel count |
audio_channel | the audio channel to read |
frame_count | the frame count to read |
format | the format to read |

#### Returns

the count of frames actually read

Since: 3.0.0

### ags_sound_resource_write ()

    void
    ags_sound_resource_write (AgsSoundResource *sound_resource,
                              void *sbuffer,
                              guint saudio_channels,
                              guint audio_channel,
                              guint frame_count,
                              AgsSoundcardFormat format);

Write `sbuffer` to `sound_resource` `frame_count` number of frames having `format` by skipping `saudio_channels` .

#### Parameters

sound_resource | the AgsSoundResource |
sbuffer | the source buffer |
saudio_channels | source buffer audio channel count |
audio_channel | the audio channel |
frame_count | the frame count to write |
format | the format to write |

Since: 3.0.0

### ags_sound_resource_flush ()

    void
    ags_sound_resource_flush (AgsSoundResource *sound_resource);

Flush `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |

Since: 3.0.0

### ags_sound_resource_seek ()

    void
    ags_sound_resource_seek (AgsSoundResource *sound_resource,
                             gint64 frame_count,
                             gint whence);

Seek the `sound_resource` `frame_count` from `whence` .

#### Parameters

sound_resource | the AgsSoundResource |
frame_count | the frame count |
whence | SEEK_SET, SEEK_CUR or SEEK_END |

Since: 3.0.0

### ags_sound_resource_read_audio_signal ()

    GList *
    ags_sound_resource_read_audio_signal (AgsSoundResource *sound_resource,
                                          GObject *soundcard,
                                          gint audio_channel);

Read audio signal from `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
soundcard | the AgsSoundcard |
audio_channel | the audio channel or -1 for all |

#### Returns

a GList containing AgsAudioSignal.

[element-type AgsAudio.AudioSignal][transfer full]

Since: 3.0.0

### ags_sound_resource_read_audio_signal_at_once ()

    GList *
    ags_sound_resource_read_audio_signal_at_once
                                   (AgsSoundResource *sound_resource,
                                    GObject *soundcard,
                                    gint audio_channel);

Read audio signal from `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
soundcard | the AgsSoundcard |
audio_channel | the audio channel or -1 for all |

#### Returns

a GList containing AgsAudioSignal.

[element-type AgsAudio.AudioSignal][transfer full]

Since: 4.4.0

### ags_sound_resource_read_wave ()

    GList *
    ags_sound_resource_read_wave (AgsSoundResource *sound_resource,
                                  GObject *soundcard,
                                  gint audio_channel,
                                  guint64 x_offset,
                                  gdouble delay,
                                  guint attack);

Read wave from `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |
soundcard | the AgsSoundcard |
audio_channel | the audio channel or -1 for all |
x_offset | the x offset |
delay | the delay |
attack | the attack |

#### Returns

a GList containing AgsWave.

[element-type AgsAudio.Wave][transfer full]

Since: 3.0.0

### ags_sound_resource_close ()

    void
    ags_sound_resource_close (AgsSoundResource *sound_resource);

Close `sound_resource` .

#### Parameters

sound_resource | the AgsSoundResource |

Since: 3.0.0