## AgsAudioFile

AgsAudioFile — Audio file input/output

## Stability Level

Stable, unless otherwise indicated

## Functions

#define | AGS_AUDIO_FILE_GET_OBJ_MUTEX()
gboolean | ags_audio_file_test_flags ()
void | ags_audio_file_set_flags ()
void | ags_audio_file_unset_flags ()
gboolean | ags_audio_file_check_suffix ()
GObject * | ags_audio_file_get_soundcard ()
void | ags_audio_file_set_soundcard ()
gchar * | ags_audio_file_get_filename ()
void | ags_audio_file_set_filename ()
guint | ags_audio_file_get_file_audio_channels ()
void | ags_audio_file_set_file_audio_channels ()
guint | ags_audio_file_get_file_samplerate ()
void | ags_audio_file_set_file_samplerate ()
guint | ags_audio_file_get_file_frame_count ()
void | ags_audio_file_set_file_frame_count ()
guint | ags_audio_file_get_samplerate ()
void | ags_audio_file_set_samplerate ()
guint | ags_audio_file_get_frame_count ()
void | ags_audio_file_set_frame_count ()
AgsSoundcardFormat | ags_audio_file_get_format ()
void | ags_audio_file_set_format ()
guint | ags_audio_file_get_audio_channel ()
void | ags_audio_file_set_audio_channel ()
GObject * | ags_audio_file_get_sound_resource ()
void | ags_audio_file_set_sound_resource ()
void | ags_audio_file_add_audio_signal ()
void | ags_audio_file_remove_audio_signal ()
void | ags_audio_file_add_wave ()
void | ags_audio_file_remove_wave ()
gboolean | ags_audio_file_open ()
gboolean | ags_audio_file_open_from_data ()
gboolean | ags_audio_file_rw_open ()
void | ags_audio_file_close ()
void * | ags_audio_file_read ()
void | ags_audio_file_read_audio_signal ()
void | ags_audio_file_read_wave ()
void | ags_audio_file_seek ()
void | ags_audio_file_write ()
void | ags_audio_file_flush ()
AgsAudioFile * | ags_audio_file_new ()

## Properties

int | audio-channel | Read / Write
gpointer | audio-signal | Read / Write
guint | buffer-size | Read / Write
guint | file-audio-channels | Read / Write
guint | file-frame-count | Read / Write
guint | file-samplerate | Read / Write
char * | filename | Read / Write
guint | format | Read / Write
guint | samplerate | Read / Write
GObject * | sound-resource | Read / Write
GObject * | soundcard | Read / Write
gpointer | wave | Read / Write

## Types and Values

enum | AgsAudioFileFlags

## Object Hierarchy

        GObject
        ╰── AgsAudioFile

## Includes

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

## Description

AgsAudioFile is the base object to read/write audio data.

## Functions

### AGS_AUDIO_FILE_GET_OBJ_MUTEX()

    #define AGS_AUDIO_FILE_GET_OBJ_MUTEX(obj) (&(((AgsAudioFile *) obj)->obj_mutex))

### ags_audio_file_test_flags ()

    gboolean
    ags_audio_file_test_flags (AgsAudioFile *audio_file,
                               guint flags);

Test `flags` to be set on `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
flags | the flags |

#### Returns

`TRUE` if flags are set, else `FALSE`

Since: 3.0.0

### ags_audio_file_set_flags ()

    void
    ags_audio_file_set_flags (AgsAudioFile *audio_file,
                              guint flags);

Enable a feature of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
flags | see AgsAudioFileFlags |

Since: 3.0.0

### ags_audio_file_unset_flags ()

    void
    ags_audio_file_unset_flags (AgsAudioFile *audio_file,
                                guint flags);

Disable a feature of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
flags | see AgsAudioFileFlags |

Since: 3.0.0

### ags_audio_file_check_suffix ()

    gboolean
    ags_audio_file_check_suffix (gchar *filename);

Check suffix.

#### Parameters

filename | the filename |

#### Returns

`TRUE` if suffix supported, else `FALSE`

Since: 3.0.0

### ags_audio_file_get_soundcard ()

    GObject *
    ags_audio_file_get_soundcard (AgsAudioFile *audio_file);

Get soundcard of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the GObject implementing AgsSoundcard.

[transfer full]

Since: 4.2.0

### ags_audio_file_set_soundcard ()

    void
    ags_audio_file_set_soundcard (AgsAudioFile *audio_file,
                                  GObject *soundcard);

Set soundcard of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
soundcard | the GObject implementing AgsSoundcard |

Since: 4.2.0

### ags_audio_file_get_filename ()

    gchar *
    ags_audio_file_get_filename (AgsAudioFile *audio_file);

Get filename of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the filename

Since: 4.2.0

### ags_audio_file_set_filename ()

    void
    ags_audio_file_set_filename (AgsAudioFile *audio_file,
                                 gchar *filename);

Set filename of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
filename | the filename |

Since: 4.2.0

### ags_audio_file_get_file_audio_channels ()

    guint
    ags_audio_file_get_file_audio_channels
                                   (AgsAudioFile *audio_file);

Get file audio channels of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the file audio channels

Since: 4.2.0

### ags_audio_file_set_file_audio_channels ()

    void
    ags_audio_file_set_file_audio_channels
                                   (AgsAudioFile *audio_file,
                                    guint file_audio_channels);

Get file audio channels of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
file_audio_channels | the file audio channels |

Since: 4.2.0

### ags_audio_file_get_file_samplerate ()

    guint
    ags_audio_file_get_file_samplerate (AgsAudioFile *audio_file);

Get file samplerate of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the file samplerate

Since: 4.2.0

### ags_audio_file_set_file_samplerate ()

    void
    ags_audio_file_set_file_samplerate (AgsAudioFile *audio_file,
                                        guint file_samplerate);

Get file samplerate of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
file_samplerate | the file samplerate |

Since: 4.2.0

### ags_audio_file_get_file_frame_count ()

    guint
    ags_audio_file_get_file_frame_count (AgsAudioFile *audio_file);

Get file frame count of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the file frame count

Since: 4.2.0

### ags_audio_file_set_file_frame_count ()

    void
    ags_audio_file_set_file_frame_count (AgsAudioFile *audio_file,
                                         guint file_frame_count);

Get file frame count of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
file_frame_count | the file frame count |

Since: 4.2.0

### ags_audio_file_get_samplerate ()

    guint
    ags_audio_file_get_samplerate (AgsAudioFile *audio_file);

Get samplerate of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the samplerate

Since: 4.2.0

### ags_audio_file_set_samplerate ()

    void
    ags_audio_file_set_samplerate (AgsAudioFile *audio_file,
                                   guint samplerate);

Get samplerate of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
samplerate | the samplerate |

Since: 4.2.0

### ags_audio_file_get_frame_count ()

    guint
    ags_audio_file_get_frame_count (AgsAudioFile *audio_file);

Get frame_count of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the frame_count

Since: 4.2.0

### ags_audio_file_set_frame_count ()

    void
    ags_audio_file_set_frame_count (AgsAudioFile *audio_file,
                                    guint frame_count);

Get frame_count of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
frame_count | the frame_count |

Since: 4.2.0

### ags_audio_file_get_format ()

    AgsSoundcardFormat
    ags_audio_file_get_format (AgsAudioFile *audio_file);

Get format of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the format

Since: 4.2.0

### ags_audio_file_set_format ()

    void
    ags_audio_file_set_format (AgsAudioFile *audio_file,
                               AgsSoundcardFormat format);

Get format of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
format | the format |

Since: 4.2.0

### ags_audio_file_get_audio_channel ()

    guint
    ags_audio_file_get_audio_channel (AgsAudioFile *audio_file);

Get audio channel of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the audio channel

Since: 4.2.0

### ags_audio_file_set_audio_channel ()

    void
    ags_audio_file_set_audio_channel (AgsAudioFile *audio_file,
                                      gint audio_channel);

Get audio channel of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
audio_channel | the audio channel |

Since: 4.2.0

### ags_audio_file_get_sound_resource ()

    GObject *
    ags_audio_file_get_sound_resource (AgsAudioFile *audio_file);

Get sound resource of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

the GObject implementing AgsSoundResource.

[transfer full]

Since: 4.2.0

### ags_audio_file_set_sound_resource ()

    void
    ags_audio_file_set_sound_resource (AgsAudioFile *audio_file,
                                       GObject *sound_resource);

Set sound resource of `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
sound_resource | the GObject implementing AgsSoundResource |

Since: 4.2.0

### ags_audio_file_add_audio_signal ()

    void
    ags_audio_file_add_audio_signal (AgsAudioFile *audio_file,
                                     GObject *audio_signal);

Add `audio_signal` to `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
audio_signal | the AgsAudioSignal |

Since: 3.0.0

### ags_audio_file_remove_audio_signal ()

    void
    ags_audio_file_remove_audio_signal (AgsAudioFile *audio_file,
                                        GObject *audio_signal);

Remove `audio_signal` from `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
audio_signal | the AgsAudioSignal |

Since: 3.0.0

### ags_audio_file_add_wave ()

    void
    ags_audio_file_add_wave (AgsAudioFile *audio_file,
                             GObject *wave);

Add `wave` to `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
wave | the AgsWave |

Since: 3.0.0

### ags_audio_file_remove_wave ()

    void
    ags_audio_file_remove_wave (AgsAudioFile *audio_file,
                                GObject *wave);

Remove `wave` from `audio_file` .

#### Parameters

audio_file | the AgsAudioFile |
wave | the AgsWave |

Since: 3.0.0

### ags_audio_file_open ()

    gboolean
    ags_audio_file_open (AgsAudioFile *audio_file);

Open the AgsAudioFile in read mode.

#### Parameters

audio_file | the AgsAudioFile |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_audio_file_open_from_data ()

    gboolean
    ags_audio_file_open_from_data (AgsAudioFile *audio_file,
                                   gchar *data);

Open AgsAudioFile using virtual functions.

#### Parameters

audio_file | the AgsAudioFile |
data | the audio data |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_audio_file_rw_open ()

    gboolean
    ags_audio_file_rw_open (AgsAudioFile *audio_file,
                            gboolean create);

Open the AgsAudioFile in read/write mode.

#### Parameters

audio_file | the AgsAudioFile |
create | create the file |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_audio_file_close ()

    void
    ags_audio_file_close (AgsAudioFile *audio_file);

Close the AgsAudioFile.

#### Parameters

audio_file | the AgsAudioFile |

Since: 3.0.0

### ags_audio_file_read ()

    void *
    ags_audio_file_read (AgsAudioFile *audio_file,
                         guint audio_channel,
                         guint format,
                         GError **error);

Read audio buffer.

#### Parameters

audio_file | the AgsAudioFile |
audio_channel | nth channel |
format | the format |
error | returned error |

Since: 3.0.0

### ags_audio_file_read_audio_signal ()

    void
    ags_audio_file_read_audio_signal (AgsAudioFile *audio_file);

Convert the AgsAudioFile to a GList of AgsAudioSignal.

#### Parameters

audio_file | the AgsAudioFile |

Since: 3.0.0

### ags_audio_file_read_wave ()

    void
    ags_audio_file_read_wave (AgsAudioFile *audio_file,
                              guint64 x_offset,
                              gdouble delay,
                              guint attack);

Convert the AgsAudioFile to a GList of buffers.

#### Parameters

audio_file | the AgsAudioFile |
x_offset | the x offset |
delay | the delay |
attack | the attack |

Since: 3.0.0

### ags_audio_file_seek ()

    void
    ags_audio_file_seek (AgsAudioFile *audio_file,
                         guint frames,
                         gint whence);

Position the AgsAudioFile's internal data address.

#### Parameters

audio_file | the AgsAudioFile |
frames | number of frames to seek |
whence | SEEK_SET, SEEK_CUR, or SEEK_END |

Since: 3.0.0

### ags_audio_file_write ()

    void
    ags_audio_file_write (AgsAudioFile *audio_file,
                          void *buffer,
                          guint buffer_size,
                          guint format);

Write the buffer to AgsAudioFile.

#### Parameters

audio_file | the AgsAudioFile |
buffer | the audio data |
buffer_size | the count of frames to write |
format | the format |

Since: 3.0.0

### ags_audio_file_flush ()

    void
    ags_audio_file_flush (AgsAudioFile *audio_file);

Flushes the AgsAudioFile's internal buffer.

#### Parameters

audio_file | the AgsAudioFile |

Since: 3.0.0

### ags_audio_file_new ()

    AgsAudioFile *
    ags_audio_file_new (gchar *filename,
                        GObject *soundcard,
                        gint audio_channel);

Create a new instance of AgsAudioFile.

#### Parameters

filename | the filename |
soundcard | defaults of AgsSoundcard |
audio_channel | the audio channel to read |

#### Returns

the new AgsAudioFile.

Since: 3.0.0

## Types and Values

### enum AgsAudioFileFlags

Enum values to control the behavior or indicate internal state of AgsAudioFile by enable/disable as flags.

#### Members

AGS_AUDIO_FILE_READ_SAMPLE_AT_ONCE | read all audio sample data at once |

## Property Details

### The `“audio-channel”` property

      “audio-channel”            int

The audio channel to be read.

Owner: AgsAudioFile

Flags: Read / Write

Allowed values: >= -1

Default value: 0

Since: 3.0.0

### The `“audio-signal”` property

      “audio-signal”             gpointer

The containing AgsAudioSignal.

[transfer full]

Owner: AgsAudioFile

Flags: Read / Write

Since: 3.0.0

### The `“buffer-size”` property

      “buffer-size”              guint

The buffer size to be used.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“file-audio-channels”` property

      “file-audio-channels”      guint

The audio channel count of this file.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“file-frame-count”` property

      “file-frame-count”         guint

The frame count of the file.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

### The `“file-samplerate”` property

      “file-samplerate”          guint

The samplerate of this file.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“filename”` property

      “filename”                 char *

The assigned filename.

Owner: AgsAudioFile

Flags: Read / Write

Default value: NULL

Since: 3.0.0

### The `“format”` property

      “format”                   guint

The format to be used.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“samplerate”` property

      “samplerate”               guint

The samplerate to be used.

Owner: AgsAudioFile

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“sound-resource”` property

      “sound-resource”           GObject *

The assigned sound resource.

Owner: AgsAudioFile

Flags: Read / Write

Since: 5.3.0

### The `“soundcard”` property

      “soundcard”                GObject *

The assigned soundcard.

Owner: AgsAudioFile

Flags: Read / Write

Since: 3.0.0

### The `“wave”` property

      “wave”                     gpointer

The containing AgsWave.

[transfer full]

Owner: AgsAudioFile

Flags: Read / Write

Since: 3.0.0