8#include "utils/types.h"
10#include <juce_audio_basics/juce_audio_basics.h>
45 using TrackIndex =
unsigned int;
70 [[nodiscard]] Format get_format ()
const;
105 const std::filesystem::path &full_path,
121 juce::MidiMessageSequence &message_sequence,
126 std::optional<double> start,
127 std::optional<double> end,
128 bool lanes_as_tracks,
129 bool use_track_or_lane_pos);
147 juce::MidiMessageSequence &message_sequence,
151 std::optional<double> start,
152 std::optional<double> end,
154 bool lanes_as_tracks,
159 std::unique_ptr<dsp::MidiEventVector> own_events;
160 if (!lanes_as_tracks && use_track_pos)
162 z_return_if_fail (!events);
163 midiTrackAddText (mf, track_index, textTrackName, name_.c_str ());
164 own_events = std::make_unique<dsp::MidiEventVector> ();
167 for (
auto &lane : laned_track_mixin_->lanes ())
169 lane->write_to_midi_file (
170 mf, own_events ? own_events.get () : events, start, end,
171 lanes_as_tracks, use_track_pos);
176 own_events->write_to_midi_file (mf, midi_track_pos);
182 juce::MidiFile midi_file_;
183 Format format_ = Format::MIDI0;
184 bool for_reading_ =
false;
static void export_midi_region_to_midi_file(const structure::arrangement::MidiRegion ®ion, const std::filesystem::path &full_path, int midi_version, bool export_full)
Exports the Region to a specified MIDI file.
void into_region(structure::arrangement::MidiRegion ®ion, int midi_track_idx) const
Reads the contents of the MIDI file into a region.
MidiFile(Format format)
Construct a new Midi File object for writing.
bool track_has_midi_note_events(TrackIndex track_idx) const
Returns whether the given track in the midi file has data.
MidiFile(const std::filesystem::path &path)
Construct a new Midi File object for reading.
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.
int get_ppqn() const
Get the PPQN (Parts Per Quarter Note) of the MIDI file.
int get_num_tracks(bool non_empty_only) const
Returns the number of tracks in the 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.
A lock-free thread-safe vector of MidiEvents.
A Region containing MIDI events.
A container of MIDI or Audio regions.
Represents a track in the project.
A higher level wrapper over a track collection that serves as the project's only tracklist.