## AgsMidi

AgsMidi — Midi class supporting selection and clipboard.

## Stability Level

Stable, unless otherwise indicated

## Functions

#define | AGS_MIDI_GET_OBJ_MUTEX()
GRecMutex * | ags_midi_get_obj_mutex ()
gboolean | ags_midi_test_flags ()
void | ags_midi_set_flags ()
void | ags_midi_unset_flags ()
GList * | ags_midi_find_near_timestamp ()
gint | ags_midi_sort_func ()
GObject * | ags_midi_get_audio ()
void | ags_midi_set_audio ()
guint | ags_midi_get_audio_channel ()
void | ags_midi_set_audio_channel ()
AgsTimestamp * | ags_midi_get_timestamp ()
void | ags_midi_set_timestamp ()
GList * | ags_midi_get_track ()
void | ags_midi_set_track ()
GList * | ags_midi_add ()
void | ags_midi_add_track ()
void | ags_midi_remove_track ()
AgsMidi * | ags_midi_new ()

## Properties

AgsAudio * | audio | Read / Write
guint | audio-channel | Read / Write
AgsTimestamp * | timestamp | Read / Write
gpointer | track | Read / Write

## Types and Values

#define | AGS_MIDI_DEFAULT_BPM
#define | AGS_MIDI_TICS_PER_BEAT
#define | AGS_MIDI_MINIMUM_TRACK_LENGTH
#define | AGS_MIDI_DEFAULT_LENGTH
#define | AGS_MIDI_DEFAULT_JIFFIE
#define | AGS_MIDI_DEFAULT_DURATION
#define | AGS_MIDI_DEFAULT_OFFSET
#define | AGS_MIDI_CLIPBOARD_VERSION
#define | AGS_MIDI_CLIPBOARD_TYPE
#define | AGS_MIDI_CLIPBOARD_FORMAT
enum | AgsMidiFlags

## Object Hierarchy

        GObject
        ╰── AgsMidi

## Includes

    #include <ags/audio/ags_midi.h>

## Description

AgsMidi acts as a container of AgsTrack.

## Functions

### AGS_MIDI_GET_OBJ_MUTEX()

    #define AGS_MIDI_GET_OBJ_MUTEX(obj) (&(((AgsMidi *) obj)->obj_mutex))

### ags_midi_get_obj_mutex ()

    GRecMutex *
    ags_midi_get_obj_mutex (AgsMidi *midi);

Get object mutex.

#### Parameters

midi | the AgsMidi |

#### Returns

the GRecMutex to lock `midi`

Since: 3.1.0

### ags_midi_test_flags ()

    gboolean
    ags_midi_test_flags (AgsMidi *midi,
                         AgsMidiFlags flags);

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

#### Parameters

midi | the AgsMidi |
flags | the flags |

#### Returns

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

Since: 3.0.0

### ags_midi_set_flags ()

    void
    ags_midi_set_flags (AgsMidi *midi,
                        AgsMidiFlags flags);

Set `flags` on `midi` .

#### Parameters

midi | the AgsMidi |
flags | the flags |

Since: 3.0.0

### ags_midi_unset_flags ()

    void
    ags_midi_unset_flags (AgsMidi *midi,
                          AgsMidiFlags flags);

Unset `flags` on `midi` .

#### Parameters

midi | the AgsMidi |
flags | the flags |

Since: 3.0.0

### ags_midi_find_near_timestamp ()

    GList *
    ags_midi_find_near_timestamp (GList *midi,
                                  guint audio_channel,
                                  AgsTimestamp *timestamp);

Retrieve appropriate midi for timestamp.

#### Parameters

midi | the GList containing AgsMidi. | [element-type AgsAudio.Midi][transfer none]
audio_channel | the matching audio channel |
timestamp | the matching timestamp, or `NULL` to match any timestamp. | [allow-none]

#### Returns

Next match.

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

Since: 3.0.0

### ags_midi_sort_func ()

    gint
    ags_midi_sort_func (gconstpointer a,
                        gconstpointer b);

Compare `a` and `b` .

#### Parameters

a | the AgsMidi |
b | another AgsMidi |

#### Returns

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

Since: 3.0.0

### ags_midi_get_audio ()

    GObject *
    ags_midi_get_audio (AgsMidi *midi);

Get audio.

#### Parameters

midi | the AgsMidi |

#### Returns

the AgsAudio.

[transfer full]

Since: 3.1.0

### ags_midi_set_audio ()

    void
    ags_midi_set_audio (AgsMidi *midi,
                        GObject *audio);

Set audio.

#### Parameters

midi | the AgsMidi |
audio | the AgsAudio |

Since: 3.1.0

### ags_midi_get_audio_channel ()

    guint
    ags_midi_get_audio_channel (AgsMidi *midi);

Gets audio channel.

#### Parameters

midi | the AgsMidi |

#### Returns

the audio channel

Since: 3.1.0

### ags_midi_set_audio_channel ()

    void
    ags_midi_set_audio_channel (AgsMidi *midi,
                                guint audio_channel);

Sets audio channel.

#### Parameters

midi | the AgsMidi |
audio_channel | the audio channel |

Since: 3.1.0

### ags_midi_get_timestamp ()

    AgsTimestamp *
    ags_midi_get_timestamp (AgsMidi *midi);

Get timestamp.

#### Parameters

midi | the AgsMidi |

#### Returns

the AgsTimestamp.

[transfer full]

Since: 3.1.0

### ags_midi_set_timestamp ()

    void
    ags_midi_set_timestamp (AgsMidi *midi,
                            AgsTimestamp *timestamp);

Set timestamp.

#### Parameters

midi | the AgsMidi |
timestamp | the AgsTimestamp |

Since: 3.1.0

### ags_midi_get_track ()

    GList *
    ags_midi_get_track (AgsMidi *midi);

Get track.

#### Parameters

midi | the AgsMidi |

#### Returns

the GList containig AgsTrack.

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

Since: 3.1.0

### ags_midi_set_track ()

    void
    ags_midi_set_track (AgsMidi *midi,
                        GList *track);

Set track by replacing existing.

#### Parameters

midi | the AgsMidi |
track | the GList containing AgsTrack. | [element-type AgsAudio.Track][transfer full]

Since: 3.1.0

### ags_midi_add ()

    GList *
    ags_midi_add (GList *midi,
                  AgsMidi *new_midi);

Add `new_midi` sorted to `midi`

#### Parameters

midi | the GList containing AgsMidi. | [element-type AgsAudio.Midi][transfer none]
new_midi | the midi to add |

#### Returns

the new beginning of `midi` .

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

Since: 3.0.0

### ags_midi_add_track ()

    void
    ags_midi_add_track (AgsMidi *midi,
                        AgsTrack *track,
                        gboolean use_selection_list);

Adds a track to midi.

#### Parameters

midi | an AgsMidi |
track | the AgsTrack to add |
use_selection_list | if `TRUE` add to selection, else to default midi |

Since: 3.0.0

### ags_midi_remove_track ()

    void
    ags_midi_remove_track (AgsMidi *midi,
                           AgsTrack *track,
                           gboolean use_selection_list);

Removes a track from midi.

#### Parameters

midi | an AgsMidi |
track | the AgsTrack to remove |
use_selection_list | if `TRUE` remove from selection, else from default midi |

Since: 3.0.0

### ags_midi_new ()

    AgsMidi *
    ags_midi_new (GObject *audio,
                  guint audio_channel);

Creates a new instance of AgsMidi.

#### Parameters

audio | the assigned AgsAudio |
audio_channel | the audio channel to be used |

#### Returns

the new AgsMidi

Since: 3.0.0

## Types and Values

### AGS_MIDI_DEFAULT_BPM

    #define AGS_MIDI_DEFAULT_BPM (120.0)

### AGS_MIDI_TICS_PER_BEAT

    #define AGS_MIDI_TICS_PER_BEAT (1.0)

### AGS_MIDI_MINIMUM_TRACK_LENGTH

    #define AGS_MIDI_MINIMUM_TRACK_LENGTH (1.0 / 16.0)

### AGS_MIDI_DEFAULT_LENGTH

    #define AGS_MIDI_DEFAULT_LENGTH (65535.0 / AGS_MIDI_TICS_PER_BEAT - AGS_MIDI_MINIMUM_TRACK_LENGTH)

### AGS_MIDI_DEFAULT_JIFFIE

    #define AGS_MIDI_DEFAULT_JIFFIE (60.0 / AGS_MIDI_DEFAULT_BPM / AGS_MIDI_TICS_PER_BEAT)

### AGS_MIDI_DEFAULT_DURATION

    #define AGS_MIDI_DEFAULT_DURATION (AGS_MIDI_DEFAULT_LENGTH * AGS_MIDI_DEFAULT_JIFFIE * AGS_USEC_PER_SEC)

### AGS_MIDI_DEFAULT_OFFSET

    #define AGS_MIDI_DEFAULT_OFFSET (64 * (1 / AGS_MIDI_MINIMUM_TRACK_LENGTH))

### AGS_MIDI_CLIPBOARD_VERSION

    #define AGS_MIDI_CLIPBOARD_VERSION "1.4.0"

### AGS_MIDI_CLIPBOARD_TYPE

    #define AGS_MIDI_CLIPBOARD_TYPE "AgsMidiClipboardXml"

### AGS_MIDI_CLIPBOARD_FORMAT

    #define AGS_MIDI_CLIPBOARD_FORMAT "AgsMidiNativeLevel"

### enum AgsMidiFlags

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

#### Members

AGS_MIDI_BYPASS | ignore any midi data |

## Property Details

### The `“audio”` property

      “audio”                    AgsAudio *

The assigned AgsAudio

Owner: AgsMidi

Flags: Read / Write

Since: 3.0.0

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

      “audio-channel”            guint

The midi's audio-channel.

Owner: AgsMidi

Flags: Read / Write

Default value: 0

Since: 3.0.0

### The `“timestamp”` property

      “timestamp”                AgsTimestamp *

The midi's timestamp.

Owner: AgsMidi

Flags: Read / Write

Since: 3.0.0

### The `“track”` property

      “track”                    gpointer

The assigned AgsTrack

[transfer full]

Owner: AgsMidi

Flags: Read / Write

Since: 3.0.0