8#include "utils/types.h"
10#include "juce_wrapper.h"
12namespace zrythm::structure
43 using TrackIndex =
unsigned int;
68 [[nodiscard]] Format get_format ()
const;
88 into_region (structure::arrangement::MidiRegion ®ion,
int midi_track_idx)
102 const structure::arrangement::MidiRegion ®ion,
103 const fs::path &full_path,
119 juce::MidiMessageSequence &message_sequence,
120 const structure::tracks::Tracklist &tracklist,
121 const structure::tracks::Track &track,
122 const structure::tracks::TrackLane &lane,
123 dsp::MidiEventVector * events,
124 std::optional<double> start,
125 std::optional<double> end,
126 bool lanes_as_tracks,
127 bool use_track_or_lane_pos);
145 juce::MidiMessageSequence &message_sequence,
146 const structure::tracks::Tracklist &tracklist,
147 const structure::tracks::Track &track,
148 dsp::MidiEventVector * events,
149 std::optional<double> start,
150 std::optional<double> end,
152 bool lanes_as_tracks,
157 std::unique_ptr<dsp::MidiEventVector> own_events;
158 if (!lanes_as_tracks && use_track_pos)
160 z_return_if_fail (!events);
161 midiTrackAddText (mf, track_index, textTrackName, name_.c_str ());
162 own_events = std::make_unique<dsp::MidiEventVector> ();
165 for (
auto &lane : laned_track_mixin_->lanes ())
167 lane->write_to_midi_file (
168 mf, own_events ? own_events.get () : events, start, end,
169 lanes_as_tracks, use_track_pos);
174 own_events->write_to_midi_file (mf, midi_track_pos);
180 juce::MidiFile midi_file_;
181 Format format_ = Format::MIDI0;
182 bool for_reading_ =
false;
static void export_track_to_sequence(juce::MidiMessageSequence &message_sequence, const structure::tracks::Tracklist &tracklist, const structure::tracks::Track &track, dsp::MidiEventVector *events, std::optional< double > start, std::optional< double > end, int track_index, bool lanes_as_tracks, bool use_track_pos)
Writes the track to the given MIDI file.
static void export_midi_lane_to_sequence(juce::MidiMessageSequence &message_sequence, const structure::tracks::Tracklist &tracklist, const structure::tracks::Track &track, const structure::tracks::TrackLane &lane, dsp::MidiEventVector *events, std::optional< double > start, std::optional< double > end, bool lanes_as_tracks, bool use_track_or_lane_pos)
Writes the lane to the given MIDI sequence.
static void export_midi_region_to_midi_file(const structure::arrangement::MidiRegion ®ion, const fs::path &full_path, int midi_version, bool export_full)
Exports the Region to a specified MIDI file.
bool track_has_midi_note_events(TrackIndex track_idx) const
Returns whether the given track in the midi file has data.
MidiFile(const fs::path &path)
Construct a new Midi File object for reading.
MidiFile(Format format)
Construct a new Midi File object for writing.
void into_region(structure::arrangement::MidiRegion ®ion, int midi_track_idx) const
Reads the contents of the MIDI file into a region.
int get_num_tracks(bool non_empty_only) const
Returns the number of tracks in the MIDI file.
int get_ppqn() const
Get the PPQN (Parts Per Quarter Note) of the MIDI file.
A Region containing MIDI events.
A higher level wrapper over a track collection that serves as the project's only tracklist.