## AgsMidiUtil

AgsMidiUtil — MIDI util

## Stability Level

Stable, unless otherwise indicated

## Functions

AgsMidiUtil * | ags_midi_util_alloc ()
void | ags_midi_util_free ()
AgsMidiUtil * | ags_midi_util_copy ()
gboolean | ags_midi_util_is_key_on ()
gboolean | ags_midi_util_is_key_off ()
gboolean | ags_midi_util_is_key_pressure ()
gboolean | ags_midi_util_is_change_parameter ()
gboolean | ags_midi_util_is_pitch_bend ()
gboolean | ags_midi_util_is_change_program ()
gboolean | ags_midi_util_is_change_pressure ()
gboolean | ags_midi_util_is_sysex ()
gboolean | ags_midi_util_is_quarter_frame ()
gboolean | ags_midi_util_is_song_position ()
gboolean | ags_midi_util_is_song_select ()
gboolean | ags_midi_util_is_tune_request ()
gboolean | ags_midi_util_is_meta_event ()
gboolean | ags_midi_util_is_text_event ()
gboolean | ags_midi_util_is_copyright_notice ()
gboolean | ags_midi_util_is_sequence_name ()
gboolean | ags_midi_util_is_instrument_name ()
gboolean | ags_midi_util_is_lyric ()
gboolean | ags_midi_util_is_marker ()
gboolean | ags_midi_util_is_cue_point ()
gboolean | ags_midi_util_is_unknown_text_event ()
gboolean | ags_midi_util_is_midi_channel_prefix ()
gboolean | ags_midi_util_is_end_of_track ()
gboolean | ags_midi_util_is_smtpe ()
gboolean | ags_midi_util_is_time_signature ()
gboolean | ags_midi_util_is_key_signature ()
gboolean | ags_midi_util_is_sequencer_meta_event ()
gboolean | ags_midi_util_is_tempo ()
gboolean | ags_midi_util_is_misc_event ()
gboolean | ags_midi_util_is_undefined ()
gboolean | ags_midi_util_get_key_on ()
gboolean | ags_midi_util_get_key_off ()
gboolean | ags_midi_util_get_key_pressure ()
gboolean | ags_midi_util_get_change_parameter ()
gboolean | ags_midi_util_get_pitch_bend ()
gboolean | ags_midi_util_get_change_program ()
gboolean | ags_midi_util_get_change_pressure ()
gboolean | ags_midi_util_get_sysex ()
gboolean | ags_midi_util_get_quarter_frame ()
gboolean | ags_midi_util_get_song_position ()
gboolean | ags_midi_util_get_song_select ()
guchar * | ags_midi_util_to_smf ()
guint | ags_midi_util_delta_time_to_offset ()
gint | ags_midi_util_offset_to_delta_time ()
guint | ags_midi_util_delta_time_to_note_256th_offset ()
gint | ags_midi_util_note_256th_offset_to_delta_time ()

## Object Hierarchy

        GBoxed
        ╰── AgsMidiUtil

## Includes

    #include <ags/audio/midi/ags_midi_util.h>

## Description

Utility functions for MIDI.

## Functions

### ags_midi_util_alloc ()

    AgsMidiUtil *
    ags_midi_util_alloc ();

Allocate MIDI util.

#### Returns

the newly allocated AgsMidiUtil.

[transfer full]

Since: 5.5.0

### ags_midi_util_free ()

    void
    ags_midi_util_free (AgsMidiUtil *midi_util);

Free MIDI util.

#### Parameters

midi_util | the MIDI util |

Since: 5.5.0

### ags_midi_util_copy ()

    AgsMidiUtil *
    ags_midi_util_copy (AgsMidiUtil *midi_util);

Copy MIDI util.

#### Parameters

midi_util | the MIDI util |

#### Returns

the newly allocated AgsMidiUtil.

[transfer full]

Since: 5.5.0

### ags_midi_util_is_key_on ()

    gboolean
    ags_midi_util_is_key_on (AgsMidiUtil *midi_util,
                             guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_key_off ()

    gboolean
    ags_midi_util_is_key_off (AgsMidiUtil *midi_util,
                              guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_key_pressure ()

    gboolean
    ags_midi_util_is_key_pressure (AgsMidiUtil *midi_util,
                                   guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_change_parameter ()

    gboolean
    ags_midi_util_is_change_parameter (AgsMidiUtil *midi_util,
                                       guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_pitch_bend ()

    gboolean
    ags_midi_util_is_pitch_bend (AgsMidiUtil *midi_util,
                                 guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_change_program ()

    gboolean
    ags_midi_util_is_change_program (AgsMidiUtil *midi_util,
                                     guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_change_pressure ()

    gboolean
    ags_midi_util_is_change_pressure (AgsMidiUtil *midi_util,
                                      guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_sysex ()

    gboolean
    ags_midi_util_is_sysex (AgsMidiUtil *midi_util,
                            guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_quarter_frame ()

    gboolean
    ags_midi_util_is_quarter_frame (AgsMidiUtil *midi_util,
                                    guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_song_position ()

    gboolean
    ags_midi_util_is_song_position (AgsMidiUtil *midi_util,
                                    guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_song_select ()

    gboolean
    ags_midi_util_is_song_select (AgsMidiUtil *midi_util,
                                  guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_tune_request ()

    gboolean
    ags_midi_util_is_tune_request (AgsMidiUtil *midi_util,
                                   guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_meta_event ()

    gboolean
    ags_midi_util_is_meta_event (AgsMidiUtil *midi_util,
                                 guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 3.0.0

### ags_midi_util_is_text_event ()

    gboolean
    ags_midi_util_is_text_event (AgsMidiUtil *midi_util,
                                 guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_copyright_notice ()

    gboolean
    ags_midi_util_is_copyright_notice (AgsMidiUtil *midi_util,
                                       guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_sequence_name ()

    gboolean
    ags_midi_util_is_sequence_name (AgsMidiUtil *midi_util,
                                    guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_instrument_name ()

    gboolean
    ags_midi_util_is_instrument_name (AgsMidiUtil *midi_util,
                                      guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_lyric ()

    gboolean
    ags_midi_util_is_lyric (AgsMidiUtil *midi_util,
                            guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_marker ()

    gboolean
    ags_midi_util_is_marker (AgsMidiUtil *midi_util,
                             guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_cue_point ()

    gboolean
    ags_midi_util_is_cue_point (AgsMidiUtil *midi_util,
                                guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_unknown_text_event ()

    gboolean
    ags_midi_util_is_unknown_text_event (AgsMidiUtil *midi_util,
                                         guchar *buffer);

### ags_midi_util_is_midi_channel_prefix ()

    gboolean
    ags_midi_util_is_midi_channel_prefix (AgsMidiUtil *midi_util,
                                          guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_end_of_track ()

    gboolean
    ags_midi_util_is_end_of_track (AgsMidiUtil *midi_util,
                                   guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_smtpe ()

    gboolean
    ags_midi_util_is_smtpe (AgsMidiUtil *midi_util,
                            guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_time_signature ()

    gboolean
    ags_midi_util_is_time_signature (AgsMidiUtil *midi_util,
                                     guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_key_signature ()

    gboolean
    ags_midi_util_is_key_signature (AgsMidiUtil *midi_util,
                                    guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_sequencer_meta_event ()

    gboolean
    ags_midi_util_is_sequencer_meta_event (AgsMidiUtil *midi_util,
                                           guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_tempo ()

    gboolean
    ags_midi_util_is_tempo (AgsMidiUtil *midi_util,
                            guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_misc_event ()

    gboolean
    ags_midi_util_is_misc_event (AgsMidiUtil *midi_util,
                                 guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_is_undefined ()

    gboolean
    ags_midi_util_is_undefined (AgsMidiUtil *midi_util,
                                guchar *buffer);

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |

#### Returns

`TRUE` on success, otherwise `FALSE`

Since: 6.16.18

### ags_midi_util_get_key_on ()

    gboolean
    ags_midi_util_get_key_on (AgsMidiUtil *midi_util,
                              guchar *buffer,
                              gint *channel,
                              gint *key,
                              gint *velocity);

Get key on fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
key | the return location of key. | [out]
velocity | the return location of velocity. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_key_off ()

    gboolean
    ags_midi_util_get_key_off (AgsMidiUtil *midi_util,
                               guchar *buffer,
                               gint *channel,
                               gint *key,
                               gint *velocity);

Get key off fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
key | the return location of key. | [out]
velocity | the return location of velocity. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_key_pressure ()

    gboolean
    ags_midi_util_get_key_pressure (AgsMidiUtil *midi_util,
                                    guchar *buffer,
                                    gint *channel,
                                    gint *key,
                                    gint *pressure);

Get key pressure fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
key | the return location of key. | [out]
pressure | the return location of pressure. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_change_parameter ()

    gboolean
    ags_midi_util_get_change_parameter (AgsMidiUtil *midi_util,
                                        guchar *buffer,
                                        gint *channel,
                                        gint *control,
                                        gint *value);

Get change parameter fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
control | the return location of control. | [out]
value | the return location of value. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_pitch_bend ()

    gboolean
    ags_midi_util_get_pitch_bend (AgsMidiUtil *midi_util,
                                  guchar *buffer,
                                  gint *channel,
                                  gint *transmitter);

Get pitch bend fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
transmitter | the return location of transmitter signed 14 bit integer. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_change_program ()

    gboolean
    ags_midi_util_get_change_program (AgsMidiUtil *midi_util,
                                      guchar *buffer,
                                      gint *channel,
                                      gint *program);

Get change program fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
program | the return location of program. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_change_pressure ()

    gboolean
    ags_midi_util_get_change_pressure (AgsMidiUtil *midi_util,
                                       guchar *buffer,
                                       gint *channel,
                                       gint *pressure);

Get change pressure fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
channel | the return location of channel. | [out]
pressure | the return location of pressure. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_sysex ()

    gboolean
    ags_midi_util_get_sysex (AgsMidiUtil *midi_util,
                             guchar *buffer,
                             guchar **data,
                             gint *length);

Get sysex fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
data | the return location of data. | [out][transfer full]
length | the return location of length. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_quarter_frame ()

    gboolean
    ags_midi_util_get_quarter_frame (AgsMidiUtil *midi_util,
                                     guchar *buffer,
                                     gint *message_type,
                                     gint *values);

Get quarter frame fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
message_type | the return location of message type. | [out]
values | the return location of values. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_song_position ()

    gboolean
    ags_midi_util_get_song_position (AgsMidiUtil *midi_util,
                                     guchar *buffer,
                                     gint *song_position);

Get song position fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
song_position | the return location of song position. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_get_song_select ()

    gboolean
    ags_midi_util_get_song_select (AgsMidiUtil *midi_util,
                                   guchar *buffer,
                                   gint *song_select);

Get song select fields of `buffer` .

#### Parameters

midi_util | the AgsMidiUtil |
buffer | the MIDI buffer |
song_select | the return location of song select. | [out]

#### Returns

`TRUE` if successful, otherwise `FALSE`

Since: 3.13.0

### ags_midi_util_to_smf ()

    guchar *
    ags_midi_util_to_smf (AgsMidiUtil *midi_util,
                          guchar *midi_buffer,
                          guint buffer_length,
                          gint delta_time,
                          guint *smf_buffer_length);

Convert real-time MIDI to SMF.

#### Parameters

midi_util | the AgsMidiUtil |
midi_buffer | the MIDI buffer |
buffer_length | the buffer length |
delta_time | the delta time |
smf_buffer_length | the return location of resulting length |

#### Returns

the SMF buffer

Since: 3.0.0

### ags_midi_util_delta_time_to_offset ()

    guint
    ags_midi_util_delta_time_to_offset (AgsMidiUtil *midi_util,
                                        gdouble delay_factor,
                                        gint division,
                                        gint tempo,
                                        gint bpm,
                                        gint delta_time);

Delta time to offset.

#### Parameters

midi_util | the AgsMidiUtil |
delay_factor | delay factor |
division | division |
tempo | tempo |
bpm | bpm |
delta_time | delta time |

#### Returns

the offset

Since: 3.0.0

### ags_midi_util_offset_to_delta_time ()

    gint
    ags_midi_util_offset_to_delta_time (AgsMidiUtil *midi_util,
                                        gdouble delay_factor,
                                        gint division,
                                        gint tempo,
                                        gint bpm,
                                        guint x);

Offset to delta time.

#### Parameters

midi_util | the AgsMidiUtil |
delay_factor | delay factor |
division | division |
tempo | tempo |
bpm | bpm |
x | note offset |

#### Returns

the delta time

Since: 3.0.0

### ags_midi_util_delta_time_to_note_256th_offset ()

    guint
    ags_midi_util_delta_time_to_note_256th_offset
                                   (AgsMidiUtil *midi_util,
                                    gdouble delay_factor,
                                    gint division,
                                    gint tempo,
                                    gint bpm,
                                    gint delta_time);

Delta time to note 256th offset.

#### Parameters

midi_util | the AgsMidiUtil |
delay_factor | delay factor |
division | division |
tempo | tempo |
bpm | bpm |
delta_time | delta time |

#### Returns

the note 256th offset

Since: 6.1.0

### ags_midi_util_note_256th_offset_to_delta_time ()

    gint
    ags_midi_util_note_256th_offset_to_delta_time
                                   (AgsMidiUtil *midi_util,
                                    gdouble delay_factor,
                                    gint division,
                                    gint tempo,
                                    gint bpm,
                                    guint x_256th);

Note 256th offset to delta time.

#### Parameters

midi_util | the AgsMidiUtil |
delay_factor | delay factor |
division | division |
tempo | tempo |
bpm | bpm |
x_256th | note 256th offset |

#### Returns

the delta time

Since: 6.1.0