## AgsPattern

AgsPattern — Pattern representing tones

## Stability Level

Stable, unless otherwise indicated

## Functions

#define | AGS_PATTERN_GET_OBJ_MUTEX()
GRecMutex * | ags_pattern_get_obj_mutex ()
gboolean | ags_pattern_test_flags ()
void | ags_pattern_set_flags ()
void | ags_pattern_unset_flags ()
GList * | ags_pattern_find_near_timestamp ()
GObject * | ags_pattern_get_channel ()
void | ags_pattern_set_channel ()
AgsTimestamp * | ags_pattern_get_timestamp ()
void | ags_pattern_set_timestamp ()
void | ags_pattern_get_dim ()
void | ags_pattern_set_dim ()
GObject * | ags_pattern_get_port ()
void | ags_pattern_set_port ()
gboolean | ags_pattern_is_empty ()
gboolean | ags_pattern_get_bit ()
void | ags_pattern_toggle_bit ()
AgsNote * | ags_pattern_get_note ()
AgsPattern * | ags_pattern_new ()

## Properties

AgsChannel * | channel | Read / Write
gboolean | current-bit | Read
guint | first-index | Read / Write
guint | offset | Read / Write
AgsPort * | port | Read / Write
guint | second-index | Read / Write
AgsTimestamp * | timestamp | Read / Write

## Types and Values

#define | AGS_PATTERN_DEFAULT_BPM
#define | AGS_PATTERN_TICS_PER_BEAT
#define | AGS_PATTERN_MINIMUM_NOTE_LENGTH
#define | AGS_PATTERN_MAXIMUM_NOTE_LENGTH
#define | AGS_PATTERN_DEFAULT_LENGTH
#define | AGS_PATTERN_DEFAULT_JIFFIE
#define | AGS_PATTERN_DEFAULT_DURATION
#define | AGS_PATTERN_DEFAULT_OFFSET

## Object Hierarchy

        GObject
        ╰── AgsPattern

## Includes

    #include <ags/audio/ags_pattern.h>

## Description

AgsPattern represents an audio pattern of tones. The bitmask pattern is stored in has 2 level of banks.

You can check if a bit is set by calling `ags_pattern_get_bit()`.

To enable/disable a bit call `ags_pattern_toggle_bit()`.

## Functions

### AGS_PATTERN_GET_OBJ_MUTEX()

    #define AGS_PATTERN_GET_OBJ_MUTEX(obj) (&(((AgsPattern *) obj)->obj_mutex))

### ags_pattern_get_obj_mutex ()

    GRecMutex *
    ags_pattern_get_obj_mutex (AgsPattern *pattern);

Get object mutex.

#### Parameters

pattern | the AgsPattern |

#### Returns

the GRecMutex to lock `pattern`

Since: 3.1.0

### ags_pattern_test_flags ()

    gboolean
    ags_pattern_test_flags (AgsPattern *pattern,
                            guint flags);

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

#### Parameters

pattern | the AgsPattern |
flags | the flags |

#### Returns

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

Since: 3.0.0

### ags_pattern_set_flags ()

    void
    ags_pattern_set_flags (AgsPattern *pattern,
                           guint flags);

Set flags.

#### Parameters

pattern | the AgsPattern |
flags | the flags |

Since: 3.0.0

### ags_pattern_unset_flags ()

    void
    ags_pattern_unset_flags (AgsPattern *pattern,
                             guint flags);

Unset flags.

#### Parameters

pattern | the AgsPattern |
flags | the flags |

Since: 3.0.0

### ags_pattern_find_near_timestamp ()

    GList *
    ags_pattern_find_near_timestamp (GList *pattern,
                                     AgsTimestamp *timestamp);

Retrieve appropriate pattern for timestamp.

#### Parameters

pattern | the GList containing AgsPattern. | [element-type AgsAudio.Pattern][transfer none]
timestamp | the matching AgsTimestamp |

#### Returns

Next match.

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

Since: 3.0.0

### ags_pattern_get_channel ()

    GObject *
    ags_pattern_get_channel (AgsPattern *pattern);

Get channel.

#### Parameters

pattern | the AgsPattern |

#### Returns

the AgsChannel.

[transfer full]

Since: 3.1.0

### ags_pattern_set_channel ()

    void
    ags_pattern_set_channel (AgsPattern *pattern,
                             GObject *channel);

Set channel.

#### Parameters

pattern | the AgsPattern |
channel | the AgsChannel |

Since: 3.1.0

### ags_pattern_get_timestamp ()

    AgsTimestamp *
    ags_pattern_get_timestamp (AgsPattern *pattern);

Get timestamp.

#### Parameters

pattern | the AgsPattern |

#### Returns

the AgsTimestamp.

[transfer full]

Since: 3.1.0

### ags_pattern_set_timestamp ()

    void
    ags_pattern_set_timestamp (AgsPattern *pattern,
                               AgsTimestamp *timestamp);

Set timestamp.

#### Parameters

pattern | the AgsPattern |
timestamp | the AgsTimestamp |

Since: 3.1.0

### ags_pattern_get_dim ()

    void
    ags_pattern_get_dim (AgsPattern *pattern,
                         guint *dim0,
                         guint *dim1,
                         guint *length);

Get the pattern's dimensions.

#### Parameters

pattern | an AgsPattern |
dim0 | bank 0 size. | [out]
dim1 | bank 1 size. | [out]
length | amount of beats. | [out]

Since: 3.1.0

### ags_pattern_set_dim ()

    void
    ags_pattern_set_dim (AgsPattern *pattern,
                         guint dim0,
                         guint dim1,
                         guint length);

Reallocates the pattern's dimensions.

#### Parameters

pattern | an AgsPattern |
dim0 | bank 0 size |
dim1 | bank 1 size |
length | amount of beats |

Since: 3.0.0

### ags_pattern_get_port ()

    GObject *
    ags_pattern_get_port (AgsPattern *pattern);

### ags_pattern_set_port ()

    void
    ags_pattern_set_port (AgsPattern *pattern,
                          GObject *port);

### ags_pattern_is_empty ()

    gboolean
    ags_pattern_is_empty (AgsPattern *pattern,
                          guint i,
                          guint j);

### ags_pattern_get_bit ()

    gboolean
    ags_pattern_get_bit (AgsPattern *pattern,
                         guint i,
                         guint j,
                         guint bit);

Check for tic to be played.

#### Parameters

pattern | an AgsPattern |
i | bank index 0 |
j | bank index 1 |
bit | the tic to check |

#### Returns

`TRUE` if tone is enabled.

Since: 3.0.0

### ags_pattern_toggle_bit ()

    void
    ags_pattern_toggle_bit (AgsPattern *pattern,
                            guint i,
                            guint j,
                            guint bit);

Toggle tone.

#### Parameters

pattern | an AgsPattern |
i | bank index 0 |
j | bank index 1 |
bit | the tic to toggle |

Since: 3.0.0

### ags_pattern_get_note ()

    AgsNote *
    ags_pattern_get_note (AgsPattern *pattern,
                          guint bit);

Get note of `pattern` .

#### Parameters

pattern | an AgsPattern |
bit | the tic |

#### Returns

the AgsNote at given position or `NULL`.

[transfer full]

Since: 3.3.0

### ags_pattern_new ()

    AgsPattern *
    ags_pattern_new ();

Creates a new instance of AgsPattern

#### Returns

the new AgsPattern

Since: 3.0.0

## Types and Values

### AGS_PATTERN_DEFAULT_BPM

    #define AGS_PATTERN_DEFAULT_BPM (120.0)

### AGS_PATTERN_TICS_PER_BEAT

    #define AGS_PATTERN_TICS_PER_BEAT (1.0)

### AGS_PATTERN_MINIMUM_NOTE_LENGTH

    #define AGS_PATTERN_MINIMUM_NOTE_LENGTH (1.0 / 16.0)

### AGS_PATTERN_MAXIMUM_NOTE_LENGTH

    #define AGS_PATTERN_MAXIMUM_NOTE_LENGTH (16.0)

### AGS_PATTERN_DEFAULT_LENGTH

    #define AGS_PATTERN_DEFAULT_LENGTH (65535.0 / AGS_PATTERN_TICS_PER_BEAT - AGS_PATTERN_MAXIMUM_NOTE_LENGTH)

### AGS_PATTERN_DEFAULT_JIFFIE

    #define AGS_PATTERN_DEFAULT_JIFFIE (60.0 / AGS_PATTERN_DEFAULT_BPM / AGS_PATTERN_TICS_PER_BEAT)

### AGS_PATTERN_DEFAULT_DURATION

    #define AGS_PATTERN_DEFAULT_DURATION (AGS_PATTERN_DEFAULT_LENGTH * AGS_PATTERN_DEFAULT_JIFFIE * AGS_USEC_PER_SEC)

### AGS_PATTERN_DEFAULT_OFFSET

    #define AGS_PATTERN_DEFAULT_OFFSET (64)

## Property Details

### The `“channel”` property

      “channel”                  AgsChannel *

The pattern's channel.

Owner: AgsPattern

Flags: Read / Write

Since: 3.3.0

### The `“current-bit”` property

      “current-bit”              gboolean

Offset of current position.

Owner: AgsPattern

Flags: Read

Default value: FALSE

Since: 3.0.0

### The `“first-index”` property

      “first-index”              guint

Selected bank 0.

Owner: AgsPattern

Flags: Read / Write

Allowed values: <= 256

Default value: 0

Since: 3.0.0

### The `“offset”` property

      “offset”                   guint

Position of pattern.

Owner: AgsPattern

Flags: Read / Write

Allowed values: <= 65535

Default value: 0

Since: 3.0.0

### The `“port”` property

      “port”                     AgsPort *

The pattern's port.

Owner: AgsPattern

Flags: Read / Write

Since: 3.0.0

### The `“second-index”` property

      “second-index”             guint

Selected bank 1.

Owner: AgsPattern

Flags: Read / Write

Allowed values: <= 256

Default value: 0

Since: 3.0.0

### The `“timestamp”` property

      “timestamp”                AgsTimestamp *

The pattern's timestamp.

Owner: AgsPattern

Flags: Read / Write

Since: 3.0.0