## AgsBuffer

AgsBuffer — Buffer class

## Stability Level

Stable, unless otherwise indicated

## Functions

#define | AGS_BUFFER_GET_OBJ_MUTEX()
GRecMutex * | ags_buffer_get_obj_mutex ()
void | ags_buffer_lock ()
void | ags_buffer_unlock ()
gboolean | ags_buffer_test_flags ()
void | ags_buffer_set_flags ()
void | ags_buffer_unset_flags ()
gint | ags_buffer_sort_func ()
guint64 | ags_buffer_get_x ()
void | ags_buffer_set_x ()
guint | ags_buffer_get_samplerate ()
void | ags_buffer_set_samplerate ()
guint | ags_buffer_get_buffer_size ()
void | ags_buffer_set_buffer_size ()
AgsSoundcardFormat | ags_buffer_get_format ()
void | ags_buffer_set_format ()
gpointer | ags_buffer_get_data ()
GList * | ags_buffer_find_range_x ()
AgsBuffer * | ags_buffer_duplicate ()
AgsBuffer * | ags_buffer_new ()

## Properties

guint | buffer-size | Read / Write
gpointer | data | Read / Write
guint | format | Read / Write
guint | samplerate | Read / Write
guint64 | selection-x0 | Read / Write
guint64 | selection-x1 | Read / Write
guint64 | x | Read / Write

## Types and Values

enum | AgsBufferFlags

## Object Hierarchy

        GFlags
        ╰── AgsBufferFlags
        GObject
        ╰── AgsBuffer

## Includes

    #include <ags/audio/ags_buffer.h>

## Description

AgsBuffer represents audio data. If you want to modify `data` property you have to lock the buffer using `ags_buffer_lock()` and when you are done release it using `ags_buffer_unlock()`.

The `x` property is the offset in frames matching samplerate.

## Functions

### AGS_BUFFER_GET_OBJ_MUTEX()

    #define AGS_BUFFER_GET_OBJ_MUTEX(obj) (&(((AgsBuffer *) obj)->obj_mutex))

### ags_buffer_get_obj_mutex ()

    GRecMutex *
    ags_buffer_get_obj_mutex (AgsBuffer *buffer);

Get object mutex.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the GRecMutex to lock `buffer`

Since: 3.1.0

### ags_buffer_lock ()

    void
    ags_buffer_lock (AgsBuffer *buffer);

Lock object mutex.

#### Parameters

buffer | the AgsBuffer |

Since: 3.1.0

### ags_buffer_unlock ()

    void
    ags_buffer_unlock (AgsBuffer *buffer);

Unlock object mutex.

#### Parameters

buffer | the AgsBuffer |

Since: 3.1.0

### ags_buffer_test_flags ()

    gboolean
    ags_buffer_test_flags (AgsBuffer *buffer,
                           AgsBufferFlags flags);

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

#### Parameters

buffer | the AgsBuffer |
flags | the flags |

#### Returns

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

Since: 3.0.0

### ags_buffer_set_flags ()

    void
    ags_buffer_set_flags (AgsBuffer *buffer,
                          AgsBufferFlags flags);

Set `flags` on `buffer` .

#### Parameters

buffer | the AgsBuffer |
flags | the flags |

Since: 3.0.0

### ags_buffer_unset_flags ()

    void
    ags_buffer_unset_flags (AgsBuffer *buffer,
                            AgsBufferFlags flags);

Unset `flags` on `buffer` .

#### Parameters

buffer | the AgsBuffer |
flags | the flags |

Since: 3.0.0

### ags_buffer_sort_func ()

    gint
    ags_buffer_sort_func (gconstpointer a,
                          gconstpointer b);

Sort buffers.

#### Parameters

a | an AgsBuffer |
b | an other AgsBuffer |

#### Returns

0 if equal, -1 if smaller and 1 if bigger offset

Since: 3.0.0

### ags_buffer_get_x ()

    guint64
    ags_buffer_get_x (AgsBuffer *buffer);

Gets x.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the x

Since: 3.1.0

### ags_buffer_set_x ()

    void
    ags_buffer_set_x (AgsBuffer *buffer,
                      guint64 x);

Sets x.

#### Parameters

buffer | the AgsBuffer |
x | the x |

Since: 3.1.0

### ags_buffer_get_samplerate ()

    guint
    ags_buffer_get_samplerate (AgsBuffer *buffer);

Gets samplerate.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the samplerate

Since: 3.1.0

### ags_buffer_set_samplerate ()

    void
    ags_buffer_set_samplerate (AgsBuffer *buffer,
                               guint samplerate);

Set samplerate.

#### Parameters

buffer | the AgsBuffer |
samplerate | the samplerate |

Since: 3.0.0

### ags_buffer_get_buffer_size ()

    guint
    ags_buffer_get_buffer_size (AgsBuffer *buffer);

Gets buffer size.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the buffer size

Since: 3.1.0

### ags_buffer_set_buffer_size ()

    void
    ags_buffer_set_buffer_size (AgsBuffer *buffer,
                                guint buffer_size);

Set buffer size.

#### Parameters

buffer | the AgsBuffer |
buffer_size | the buffer size |

Since: 3.0.0

### ags_buffer_get_format ()

    AgsSoundcardFormat
    ags_buffer_get_format (AgsBuffer *buffer);

Gets format.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the format

Since: 3.1.0

### ags_buffer_set_format ()

    void
    ags_buffer_set_format (AgsBuffer *buffer,
                           AgsSoundcardFormat format);

Set format.

#### Parameters

buffer | the AgsBuffer |
format | the format |

Since: 3.0.0

### ags_buffer_get_data ()

    gpointer
    ags_buffer_get_data (AgsBuffer *buffer);

Gets data.

#### Parameters

buffer | the AgsBuffer |

#### Returns

the data

Since: 3.1.0

### ags_buffer_find_range_x ()

    GList *
    ags_buffer_find_range_x (GList *buffer,
                             guint64 start_x,
                             guint64 end_x);

Find within range of `start_x` and `end_x` .

#### Parameters

buffer | the GList containing AgsBuffer. | [element-type AgsAudio.Buffer][transfer none]
start_x | start x offset |
end_x | end x offset |

#### Returns

the matching entry as GList, else `NULL`.

[element-type AgsAudio.Buffer][transfer none]

Since: 8.0.11

### ags_buffer_duplicate ()

    AgsBuffer *
    ags_buffer_duplicate (AgsBuffer *buffer);

Duplicate a buffer.

#### Parameters

buffer | an AgsBuffer |

#### Returns

the duplicated AgsBuffer.

[transfer full]

Since: 3.0.0

### ags_buffer_new ()

    AgsBuffer *
    ags_buffer_new ();

Creates a new instance of AgsBuffer

#### Returns

the new AgsBuffer

Since: 3.0.0

## Types and Values

### enum AgsBufferFlags

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

#### Members

AGS_BUFFER_IS_SELECTED | is selected |

## Property Details

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

      “buffer-size”              guint

Buffer's audio data buffer size.

Owner: AgsBuffer

Flags: Read / Write

Default value: 2048

Since: 3.0.0

### The `“data”` property

      “data”                     gpointer

Buffer's audio data.

Owner: AgsBuffer

Flags: Read / Write

Since: 3.0.0

### The `“format”` property

      “format”                   guint

Buffer's audio data format.

Owner: AgsBuffer

Flags: Read / Write

Default value: 16

Since: 3.0.0

### The `“samplerate”` property

      “samplerate”               guint

Buffer's audio data samplerate.

Owner: AgsBuffer

Flags: Read / Write

Default value: 44100

Since: 3.0.0

### The `“selection-x0”` property

      “selection-x0”             guint64

Buffer's selection x0 offset.

Owner: AgsBuffer

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“selection-x1”` property

      “selection-x1”             guint64

Buffer's selection x1 offset.

Owner: AgsBuffer

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“x”` property

      “x”                        guint64

Buffer's x offset.

Owner: AgsBuffer

Flags: Read / Write

Default value: 0

Since: 3.0.0