Zrythm v2.0.0-alpha.1
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::MidiFile Class Reference

MIDI file handling. More...

#include <src/gui/backend/io/midi_file.h>

Public Types

enum class  Format { MIDI0 , MIDI1 , MIDI2 }
using TrackIndex = unsigned int

Public Member Functions

 MidiFile (Format format)
 Construct a new Midi File object for writing.
 MidiFile (const std::filesystem::path &path)
 Construct a new Midi File object for reading.
bool track_has_midi_note_events (TrackIndex track_idx) const
 Returns whether the given track in the midi file has data.
int get_num_tracks (bool non_empty_only) const
 Returns the number of tracks in the MIDI file.
Format get_format () const
int get_ppqn () const
 Get the PPQN (Parts Per Quarter Note) of the MIDI file.
void into_clip (structure::arrangement::MidiClip &clip, int midi_track_idx) const
 Reads the contents of the MIDI file into a clip.

Static Public Member Functions

static void export_midi_clip_to_midi_file (const structure::arrangement::MidiClip &clip, const std::filesystem::path &full_path, int midi_version, bool export_full)
 Exports the Clip to a specified MIDI file.

Detailed Description

MIDI file handling.

Definition at line 34 of file midi_file.h.

Member Typedef Documentation

◆ TrackIndex

using zrythm::MidiFile::TrackIndex = unsigned int

Definition at line 44 of file midi_file.h.

Member Enumeration Documentation

◆ Format

enum class zrythm::MidiFile::Format
strong

Definition at line 37 of file midi_file.h.

Constructor & Destructor Documentation

◆ MidiFile()

zrythm::MidiFile::MidiFile ( const std::filesystem::path & path)

Construct a new Midi File object for reading.

Parameters
pathPath to read.
Exceptions
ZrythmExceptionIf the file could not be read.

Member Function Documentation

◆ export_midi_clip_to_midi_file()

void zrythm::MidiFile::export_midi_clip_to_midi_file ( const structure::arrangement::MidiClip & clip,
const std::filesystem::path & full_path,
int midi_version,
bool export_full )
static

Exports the Clip to a specified MIDI file.

FIXME: this needs refactoring. taken out of MidiClip class.

Parameters
full_pathAbsolute path to the MIDI file.
export_fullTraverse loops and export the MIDI file as it would be played inside Zrythm. If this is false, only the original clip (from true start to true end) is exported.

◆ get_ppqn()

int zrythm::MidiFile::get_ppqn ( ) const

Get the PPQN (Parts Per Quarter Note) of the MIDI file.

Returns
int
Exceptions
ZrythmExceptionIf the MIDI file does not contain a PPQN value.

◆ into_clip()

void zrythm::MidiFile::into_clip ( structure::arrangement::MidiClip & clip,
int midi_track_idx ) const

Reads the contents of the MIDI file into a clip.

Parameters
clipA freshly created clip to fill.
midi_track_idxThe index of this track, starting from 0. This will be sequential, ie, if idx 1 is requested and the MIDI file only has tracks 5 and 7, it will use track 7.
Exceptions
ZrythmExceptionOn error.

The documentation for this class was generated from the following file: