// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: midi.proto

#include "midi.pb.h"

#include <algorithm>

#include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/extension_set.h>
#include <google/protobuf/wire_format_lite.h>
#include <google/protobuf/descriptor.h>
#include <google/protobuf/generated_message_reflection.h>
#include <google/protobuf/reflection_ops.h>
#include <google/protobuf/wire_format.h>
// @@protoc_insertion_point(includes)
#include <google/protobuf/port_def.inc>
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Bar_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Dataset_Item_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Event_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MBar_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MEvent_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MTrack_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_StatusTrack_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Track_midi_2eproto;
extern PROTOBUF_INTERNAL_EXPORT_midi_2eproto ::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ValidTrack_midi_2eproto;
namespace midi {
class NoteDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Note> _instance;
} _Note_default_instance_;
class EventDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Event> _instance;
} _Event_default_instance_;
class BarDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Bar> _instance;
} _Bar_default_instance_;
class TrackDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Track> _instance;
} _Track_default_instance_;
class ValidTrackDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<ValidTrack> _instance;
} _ValidTrack_default_instance_;
class PieceDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Piece> _instance;
} _Piece_default_instance_;
class StatusTrackDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<StatusTrack> _instance;
} _StatusTrack_default_instance_;
class StatusDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Status> _instance;
} _Status_default_instance_;
class MEventDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MEvent> _instance;
} _MEvent_default_instance_;
class MBarDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MBar> _instance;
} _MBar_default_instance_;
class MTrackDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MTrack> _instance;
} _MTrack_default_instance_;
class MPieceDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<MPiece> _instance;
} _MPiece_default_instance_;
class Dataset_ItemDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Dataset_Item> _instance;
} _Dataset_Item_default_instance_;
class DatasetDefaultTypeInternal {
 public:
  ::PROTOBUF_NAMESPACE_ID::internal::ExplicitlyConstructed<Dataset> _instance;
} _Dataset_default_instance_;
}  // namespace midi
static void InitDefaultsscc_info_Bar_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Bar_default_instance_;
    new (ptr) ::midi::Bar();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Bar::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Bar_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Bar_midi_2eproto}, {}};

static void InitDefaultsscc_info_Dataset_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Dataset_default_instance_;
    new (ptr) ::midi::Dataset();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Dataset::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Dataset_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Dataset_midi_2eproto}, {
      &scc_info_Dataset_Item_midi_2eproto.base,}};

static void InitDefaultsscc_info_Dataset_Item_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Dataset_Item_default_instance_;
    new (ptr) ::midi::Dataset_Item();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Dataset_Item::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Dataset_Item_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Dataset_Item_midi_2eproto}, {}};

static void InitDefaultsscc_info_Event_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Event_default_instance_;
    new (ptr) ::midi::Event();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Event::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Event_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Event_midi_2eproto}, {}};

static void InitDefaultsscc_info_MBar_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_MBar_default_instance_;
    new (ptr) ::midi::MBar();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::MBar::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MBar_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_MBar_midi_2eproto}, {}};

static void InitDefaultsscc_info_MEvent_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_MEvent_default_instance_;
    new (ptr) ::midi::MEvent();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::MEvent::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_MEvent_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_MEvent_midi_2eproto}, {}};

static void InitDefaultsscc_info_MPiece_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_MPiece_default_instance_;
    new (ptr) ::midi::MPiece();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::MPiece::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<2> scc_info_MPiece_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 2, 0, InitDefaultsscc_info_MPiece_midi_2eproto}, {
      &scc_info_MTrack_midi_2eproto.base,
      &scc_info_MEvent_midi_2eproto.base,}};

static void InitDefaultsscc_info_MTrack_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_MTrack_default_instance_;
    new (ptr) ::midi::MTrack();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::MTrack::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_MTrack_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_MTrack_midi_2eproto}, {
      &scc_info_MBar_midi_2eproto.base,}};

static void InitDefaultsscc_info_Note_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Note_default_instance_;
    new (ptr) ::midi::Note();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Note::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_Note_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_Note_midi_2eproto}, {}};

static void InitDefaultsscc_info_Piece_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Piece_default_instance_;
    new (ptr) ::midi::Piece();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Piece::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<3> scc_info_Piece_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 3, 0, InitDefaultsscc_info_Piece_midi_2eproto}, {
      &scc_info_Track_midi_2eproto.base,
      &scc_info_Event_midi_2eproto.base,
      &scc_info_ValidTrack_midi_2eproto.base,}};

static void InitDefaultsscc_info_Status_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Status_default_instance_;
    new (ptr) ::midi::Status();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Status::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Status_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Status_midi_2eproto}, {
      &scc_info_StatusTrack_midi_2eproto.base,}};

static void InitDefaultsscc_info_StatusTrack_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_StatusTrack_default_instance_;
    new (ptr) ::midi::StatusTrack();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::StatusTrack::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_StatusTrack_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_StatusTrack_midi_2eproto}, {}};

static void InitDefaultsscc_info_Track_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_Track_default_instance_;
    new (ptr) ::midi::Track();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::Track::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<1> scc_info_Track_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 1, 0, InitDefaultsscc_info_Track_midi_2eproto}, {
      &scc_info_Bar_midi_2eproto.base,}};

static void InitDefaultsscc_info_ValidTrack_midi_2eproto() {
  GOOGLE_PROTOBUF_VERIFY_VERSION;

  {
    void* ptr = &::midi::_ValidTrack_default_instance_;
    new (ptr) ::midi::ValidTrack();
    ::PROTOBUF_NAMESPACE_ID::internal::OnShutdownDestroyMessage(ptr);
  }
  ::midi::ValidTrack::InitAsDefaultInstance();
}

::PROTOBUF_NAMESPACE_ID::internal::SCCInfo<0> scc_info_ValidTrack_midi_2eproto =
    {{ATOMIC_VAR_INIT(::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase::kUninitialized), 0, 0, InitDefaultsscc_info_ValidTrack_midi_2eproto}, {}};

static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_midi_2eproto[14];
static constexpr ::PROTOBUF_NAMESPACE_ID::EnumDescriptor const** file_level_enum_descriptors_midi_2eproto = nullptr;
static constexpr ::PROTOBUF_NAMESPACE_ID::ServiceDescriptor const** file_level_service_descriptors_midi_2eproto = nullptr;

const ::PROTOBUF_NAMESPACE_ID::uint32 TableStruct_midi_2eproto::offsets[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
  PROTOBUF_FIELD_OFFSET(::midi::Note, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Note, start_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, end_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, velocity_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, track_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, qstart_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, qend_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, bar_),
  PROTOBUF_FIELD_OFFSET(::midi::Note, is_drum_),
  0,
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  PROTOBUF_FIELD_OFFSET(::midi::Event, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Event, time_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, velocity_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, track_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, qtime_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, bar_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, is_drum_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, should_prune_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, track_type_),
  0,
  1,
  2,
  3,
  4,
  5,
  6,
  7,
  8,
  9,
  PROTOBUF_FIELD_OFFSET(::midi::Bar, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Bar, events_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, is_four_four_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, has_notes_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, time_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, beat_length_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, should_prune_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, is_drum_),
  ~0u,
  1,
  2,
  0,
  5,
  3,
  4,
  PROTOBUF_FIELD_OFFSET(::midi::Track, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Track, bars_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, is_drum_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, min_pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, max_pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, av_polyphony_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, note_density_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, note_density_v2_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, te_track_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, max_polyphony_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, type_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, should_prune_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, order_),
  ~0u,
  5,
  0,
  1,
  2,
  3,
  4,
  7,
  8,
  9,
  10,
  6,
  11,
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::midi::ValidTrack, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::ValidTrack, tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Piece, tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, events_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, resolution_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, tempo_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, min_pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, max_pitch_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, valid_segments_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, valid_tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, msd_cd1_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, msd_cd2_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, msd_cd2c_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, segment_length_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, valid_tracks_v2_),
  ~0u,
  ~0u,
  0,
  1,
  2,
  3,
  ~0u,
  ~0u,
  ~0u,
  ~0u,
  ~0u,
  4,
  ~0u,
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, track_id_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, track_type_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, density_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, selected_bars_),
  1,
  2,
  0,
  3,
  ~0u,
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::midi::Status, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Status, tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::MEvent, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::MEvent, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::MEvent, time_),
  PROTOBUF_FIELD_OFFSET(::midi::MEvent, velocity_),
  PROTOBUF_FIELD_OFFSET(::midi::MEvent, pitch_),
  0,
  1,
  2,
  PROTOBUF_FIELD_OFFSET(::midi::MBar, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::MBar, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::MBar, events_),
  PROTOBUF_FIELD_OFFSET(::midi::MBar, beat_length_),
  ~0u,
  0,
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, bars_),
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, density_),
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, type_),
  PROTOBUF_FIELD_OFFSET(::midi::MTrack, resample_bars_),
  ~0u,
  0,
  1,
  2,
  ~0u,
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::midi::MPiece, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::MPiece, tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::MPiece, events_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset_Item, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset_Item, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Dataset_Item, start_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset_Item, end_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset_Item, src_size_),
  0,
  1,
  2,
  ~0u,  // no _has_bits_
  PROTOBUF_FIELD_OFFSET(::midi::Dataset, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::Dataset, train_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset, valid_),
  PROTOBUF_FIELD_OFFSET(::midi::Dataset, test_),
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
  { 0, 15, sizeof(::midi::Note)},
  { 25, 40, sizeof(::midi::Event)},
  { 50, 62, sizeof(::midi::Bar)},
  { 69, 87, sizeof(::midi::Track)},
  { 100, -1, sizeof(::midi::ValidTrack)},
  { 106, 124, sizeof(::midi::Piece)},
  { 137, 147, sizeof(::midi::StatusTrack)},
  { 152, -1, sizeof(::midi::Status)},
  { 158, 166, sizeof(::midi::MEvent)},
  { 169, 176, sizeof(::midi::MBar)},
  { 178, 188, sizeof(::midi::MTrack)},
  { 193, -1, sizeof(::midi::MPiece)},
  { 200, 208, sizeof(::midi::Dataset_Item)},
  { 211, -1, sizeof(::midi::Dataset)},
};

static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Note_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Event_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Bar_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Track_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_ValidTrack_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Piece_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_StatusTrack_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Status_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_MEvent_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_MBar_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_MTrack_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_MPiece_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Dataset_Item_default_instance_),
  reinterpret_cast<const ::PROTOBUF_NAMESPACE_ID::Message*>(&::midi::_Dataset_default_instance_),
};

const char descriptor_table_protodef_midi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
  "\n\nmidi.proto\022\004midi\"\242\001\n\004Note\022\r\n\005start\030\001 \001"
  "(\005\022\013\n\003end\030\002 \001(\005\022\020\n\010velocity\030\003 \001(\005\022\r\n\005pit"
  "ch\030\004 \001(\005\022\022\n\ninstrument\030\005 \001(\005\022\r\n\005track\030\006 "
  "\001(\005\022\016\n\006qstart\030\007 \001(\005\022\014\n\004qend\030\010 \001(\005\022\013\n\003bar"
  "\030\t \001(\005\022\017\n\007is_drum\030\n \001(\010\"\260\001\n\005Event\022\014\n\004tim"
  "e\030\001 \001(\005\022\020\n\010velocity\030\002 \001(\005\022\r\n\005pitch\030\003 \001(\005"
  "\022\022\n\ninstrument\030\004 \001(\005\022\r\n\005track\030\005 \001(\005\022\r\n\005q"
  "time\030\006 \001(\005\022\013\n\003bar\030\007 \001(\005\022\017\n\007is_drum\030\010 \001(\010"
  "\022\024\n\014should_prune\030\t \001(\010\022\022\n\ntrack_type\030\n \001"
  "(\005\"\210\001\n\003Bar\022\016\n\006events\030\001 \003(\005\022\024\n\014is_four_fo"
  "ur\030\002 \001(\010\022\021\n\thas_notes\030\003 \001(\010\022\014\n\004time\030\004 \001("
  "\005\022\023\n\013beat_length\030\005 \001(\002\022\024\n\014should_prune\030\006"
  " \001(\010\022\017\n\007is_drum\030\007 \001(\010\"\214\002\n\005Track\022\027\n\004bars\030"
  "\001 \003(\0132\t.midi.Bar\022\017\n\007is_drum\030\002 \001(\010\022\021\n\tmin"
  "_pitch\030\003 \001(\005\022\021\n\tmax_pitch\030\004 \001(\005\022\022\n\ninstr"
  "ument\030\005 \001(\005\022\024\n\014av_polyphony\030\006 \001(\002\022\024\n\014not"
  "e_density\030\007 \001(\005\022\027\n\017note_density_v2\030\010 \001(\005"
  "\022\020\n\010te_track\030\t \001(\005\022\025\n\rmax_polyphony\030\n \001("
  "\005\022\014\n\004type\030\013 \001(\005\022\024\n\014should_prune\030\014 \001(\010\022\r\n"
  "\005order\030\r \001(\005\"\034\n\nValidTrack\022\016\n\006tracks\030\001 \003"
  "(\005\"\257\002\n\005Piece\022\033\n\006tracks\030\001 \003(\0132\013.midi.Trac"
  "k\022\033\n\006events\030\002 \003(\0132\013.midi.Event\022\022\n\nresolu"
  "tion\030\003 \001(\005\022\r\n\005tempo\030\004 \001(\005\022\021\n\tmin_pitch\030\005"
  " \001(\005\022\021\n\tmax_pitch\030\006 \001(\005\022\026\n\016valid_segment"
  "s\030\007 \003(\005\022\024\n\014valid_tracks\030\010 \003(\r\022\017\n\007msd_cd1"
  "\030\t \003(\t\022\017\n\007msd_cd2\030\n \003(\t\022\020\n\010msd_cd2c\030\013 \003("
  "\t\022\026\n\016segment_length\030\014 \001(\005\022)\n\017valid_track"
  "s_v2\030\r \003(\0132\020.midi.ValidTrack\"o\n\013StatusTr"
  "ack\022\020\n\010track_id\030\001 \001(\005\022\022\n\ntrack_type\030\002 \001("
  "\005\022\022\n\ninstrument\030\003 \001(\t\022\017\n\007density\030\004 \001(\005\022\025"
  "\n\rselected_bars\030\005 \003(\010\"+\n\006Status\022!\n\006track"
  "s\030\001 \003(\0132\021.midi.StatusTrack\"7\n\006MEvent\022\014\n\004"
  "time\030\001 \001(\005\022\020\n\010velocity\030\002 \001(\005\022\r\n\005pitch\030\003 "
  "\001(\005\"+\n\004MBar\022\016\n\006events\030\001 \003(\005\022\023\n\013beat_leng"
  "th\030\002 \001(\002\"l\n\006MTrack\022\030\n\004bars\030\001 \003(\0132\n.midi."
  "MBar\022\022\n\ninstrument\030\002 \001(\005\022\017\n\007density\030\003 \001("
  "\005\022\014\n\004type\030\004 \001(\005\022\025\n\rresample_bars\030\005 \003(\005\"D"
  "\n\006MPiece\022\034\n\006tracks\030\001 \003(\0132\014.midi.MTrack\022\034"
  "\n\006events\030\002 \003(\0132\014.midi.MEvent\"\247\001\n\007Dataset"
  "\022!\n\005train\030\001 \003(\0132\022.midi.Dataset.Item\022!\n\005v"
  "alid\030\002 \003(\0132\022.midi.Dataset.Item\022 \n\004test\030\003"
  " \003(\0132\022.midi.Dataset.Item\0324\n\004Item\022\r\n\005star"
  "t\030\001 \002(\004\022\013\n\003end\030\002 \002(\004\022\020\n\010src_size\030\003 \002(\004"
  ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_midi_2eproto_deps[1] = {
};
static ::PROTOBUF_NAMESPACE_ID::internal::SCCInfoBase*const descriptor_table_midi_2eproto_sccs[14] = {
  &scc_info_Bar_midi_2eproto.base,
  &scc_info_Dataset_midi_2eproto.base,
  &scc_info_Dataset_Item_midi_2eproto.base,
  &scc_info_Event_midi_2eproto.base,
  &scc_info_MBar_midi_2eproto.base,
  &scc_info_MEvent_midi_2eproto.base,
  &scc_info_MPiece_midi_2eproto.base,
  &scc_info_MTrack_midi_2eproto.base,
  &scc_info_Note_midi_2eproto.base,
  &scc_info_Piece_midi_2eproto.base,
  &scc_info_Status_midi_2eproto.base,
  &scc_info_StatusTrack_midi_2eproto.base,
  &scc_info_Track_midi_2eproto.base,
  &scc_info_ValidTrack_midi_2eproto.base,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_midi_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_midi_2eproto = {
  false, false, descriptor_table_protodef_midi_2eproto, "midi.proto", 1718,
  &descriptor_table_midi_2eproto_once, descriptor_table_midi_2eproto_sccs, descriptor_table_midi_2eproto_deps, 14, 0,
  schemas, file_default_instances, TableStruct_midi_2eproto::offsets,
  file_level_metadata_midi_2eproto, 14, file_level_enum_descriptors_midi_2eproto, file_level_service_descriptors_midi_2eproto,
};

// Force running AddDescriptors() at dynamic initialization time.
static bool dynamic_init_dummy_midi_2eproto = (static_cast<void>(::PROTOBUF_NAMESPACE_ID::internal::AddDescriptors(&descriptor_table_midi_2eproto)), true);
namespace midi {

// ===================================================================

void Note::InitAsDefaultInstance() {
}
class Note::_Internal {
 public:
  using HasBits = decltype(std::declval<Note>()._has_bits_);
  static void set_has_start(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_end(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_velocity(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_track(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_qstart(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_qend(HasBits* has_bits) {
    (*has_bits)[0] |= 128u;
  }
  static void set_has_bar(HasBits* has_bits) {
    (*has_bits)[0] |= 256u;
  }
  static void set_has_is_drum(HasBits* has_bits) {
    (*has_bits)[0] |= 512u;
  }
};

Note::Note(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Note)
}
Note::Note(const Note& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&start_, &from.start_,
    static_cast<size_t>(reinterpret_cast<char*>(&is_drum_) -
    reinterpret_cast<char*>(&start_)) + sizeof(is_drum_));
  // @@protoc_insertion_point(copy_constructor:midi.Note)
}

void Note::SharedCtor() {
  ::memset(&start_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&is_drum_) -
      reinterpret_cast<char*>(&start_)) + sizeof(is_drum_));
}

Note::~Note() {
  // @@protoc_insertion_point(destructor:midi.Note)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Note::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Note::ArenaDtor(void* object) {
  Note* _this = reinterpret_cast< Note* >(object);
  (void)_this;
}
void Note::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Note::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Note& Note::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Note_midi_2eproto.base);
  return *internal_default_instance();
}


void Note::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Note)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    ::memset(&start_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&qend_) -
        reinterpret_cast<char*>(&start_)) + sizeof(qend_));
  }
  if (cached_has_bits & 0x00000300u) {
    ::memset(&bar_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&is_drum_) -
        reinterpret_cast<char*>(&bar_)) + sizeof(is_drum_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Note::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // optional int32 start = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_start(&has_bits);
          start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 end = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_end(&has_bits);
          end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 velocity = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_velocity(&has_bits);
          velocity_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 pitch = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_pitch(&has_bits);
          pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 instrument = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          _Internal::set_has_instrument(&has_bits);
          instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 track = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          _Internal::set_has_track(&has_bits);
          track_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 qstart = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_qstart(&has_bits);
          qstart_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 qend = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          _Internal::set_has_qend(&has_bits);
          qend_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 bar = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
          _Internal::set_has_bar(&has_bits);
          bar_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool is_drum = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
          _Internal::set_has_is_drum(&has_bits);
          is_drum_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Note::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Note)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 start = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_start(), target);
  }

  // optional int32 end = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_end(), target);
  }

  // optional int32 velocity = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_velocity(), target);
  }

  // optional int32 pitch = 4;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_pitch(), target);
  }

  // optional int32 instrument = 5;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_instrument(), target);
  }

  // optional int32 track = 6;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(6, this->_internal_track(), target);
  }

  // optional int32 qstart = 7;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_qstart(), target);
  }

  // optional int32 qend = 8;
  if (cached_has_bits & 0x00000080u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(8, this->_internal_qend(), target);
  }

  // optional int32 bar = 9;
  if (cached_has_bits & 0x00000100u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(9, this->_internal_bar(), target);
  }

  // optional bool is_drum = 10;
  if (cached_has_bits & 0x00000200u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(10, this->_internal_is_drum(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Note)
  return target;
}

size_t Note::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Note)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    // optional int32 start = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_start());
    }

    // optional int32 end = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_end());
    }

    // optional int32 velocity = 3;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_velocity());
    }

    // optional int32 pitch = 4;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_pitch());
    }

    // optional int32 instrument = 5;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_instrument());
    }

    // optional int32 track = 6;
    if (cached_has_bits & 0x00000020u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track());
    }

    // optional int32 qstart = 7;
    if (cached_has_bits & 0x00000040u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_qstart());
    }

    // optional int32 qend = 8;
    if (cached_has_bits & 0x00000080u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_qend());
    }

  }
  if (cached_has_bits & 0x00000300u) {
    // optional int32 bar = 9;
    if (cached_has_bits & 0x00000100u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_bar());
    }

    // optional bool is_drum = 10;
    if (cached_has_bits & 0x00000200u) {
      total_size += 1 + 1;
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Note::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Note)
  GOOGLE_DCHECK_NE(&from, this);
  const Note* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Note>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Note)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Note)
    MergeFrom(*source);
  }
}

void Note::MergeFrom(const Note& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Note)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    if (cached_has_bits & 0x00000001u) {
      start_ = from.start_;
    }
    if (cached_has_bits & 0x00000002u) {
      end_ = from.end_;
    }
    if (cached_has_bits & 0x00000004u) {
      velocity_ = from.velocity_;
    }
    if (cached_has_bits & 0x00000008u) {
      pitch_ = from.pitch_;
    }
    if (cached_has_bits & 0x00000010u) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000020u) {
      track_ = from.track_;
    }
    if (cached_has_bits & 0x00000040u) {
      qstart_ = from.qstart_;
    }
    if (cached_has_bits & 0x00000080u) {
      qend_ = from.qend_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  if (cached_has_bits & 0x00000300u) {
    if (cached_has_bits & 0x00000100u) {
      bar_ = from.bar_;
    }
    if (cached_has_bits & 0x00000200u) {
      is_drum_ = from.is_drum_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Note::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Note)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Note::CopyFrom(const Note& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Note)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Note::IsInitialized() const {
  return true;
}

void Note::InternalSwap(Note* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Note, is_drum_)
      + sizeof(Note::is_drum_)
      - PROTOBUF_FIELD_OFFSET(Note, start_)>(
          reinterpret_cast<char*>(&start_),
          reinterpret_cast<char*>(&other->start_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Note::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Event::InitAsDefaultInstance() {
}
class Event::_Internal {
 public:
  using HasBits = decltype(std::declval<Event>()._has_bits_);
  static void set_has_time(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_velocity(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_track(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_qtime(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_bar(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_is_drum(HasBits* has_bits) {
    (*has_bits)[0] |= 128u;
  }
  static void set_has_should_prune(HasBits* has_bits) {
    (*has_bits)[0] |= 256u;
  }
  static void set_has_track_type(HasBits* has_bits) {
    (*has_bits)[0] |= 512u;
  }
};

Event::Event(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Event)
}
Event::Event(const Event& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&time_, &from.time_,
    static_cast<size_t>(reinterpret_cast<char*>(&track_type_) -
    reinterpret_cast<char*>(&time_)) + sizeof(track_type_));
  // @@protoc_insertion_point(copy_constructor:midi.Event)
}

void Event::SharedCtor() {
  ::memset(&time_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&track_type_) -
      reinterpret_cast<char*>(&time_)) + sizeof(track_type_));
}

Event::~Event() {
  // @@protoc_insertion_point(destructor:midi.Event)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Event::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Event::ArenaDtor(void* object) {
  Event* _this = reinterpret_cast< Event* >(object);
  (void)_this;
}
void Event::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Event::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Event& Event::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Event_midi_2eproto.base);
  return *internal_default_instance();
}


void Event::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Event)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    ::memset(&time_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&is_drum_) -
        reinterpret_cast<char*>(&time_)) + sizeof(is_drum_));
  }
  if (cached_has_bits & 0x00000300u) {
    ::memset(&should_prune_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&track_type_) -
        reinterpret_cast<char*>(&should_prune_)) + sizeof(track_type_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Event::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // optional int32 time = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_time(&has_bits);
          time_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 velocity = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_velocity(&has_bits);
          velocity_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 pitch = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_pitch(&has_bits);
          pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 instrument = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_instrument(&has_bits);
          instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 track = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          _Internal::set_has_track(&has_bits);
          track_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 qtime = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          _Internal::set_has_qtime(&has_bits);
          qtime_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 bar = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_bar(&has_bits);
          bar_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool is_drum = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          _Internal::set_has_is_drum(&has_bits);
          is_drum_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool should_prune = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
          _Internal::set_has_should_prune(&has_bits);
          should_prune_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 track_type = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
          _Internal::set_has_track_type(&has_bits);
          track_type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Event::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Event)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 time = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_time(), target);
  }

  // optional int32 velocity = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_velocity(), target);
  }

  // optional int32 pitch = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_pitch(), target);
  }

  // optional int32 instrument = 4;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_instrument(), target);
  }

  // optional int32 track = 5;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_track(), target);
  }

  // optional int32 qtime = 6;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(6, this->_internal_qtime(), target);
  }

  // optional int32 bar = 7;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_bar(), target);
  }

  // optional bool is_drum = 8;
  if (cached_has_bits & 0x00000080u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(8, this->_internal_is_drum(), target);
  }

  // optional bool should_prune = 9;
  if (cached_has_bits & 0x00000100u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(9, this->_internal_should_prune(), target);
  }

  // optional int32 track_type = 10;
  if (cached_has_bits & 0x00000200u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(10, this->_internal_track_type(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Event)
  return target;
}

size_t Event::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Event)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    // optional int32 time = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_time());
    }

    // optional int32 velocity = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_velocity());
    }

    // optional int32 pitch = 3;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_pitch());
    }

    // optional int32 instrument = 4;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_instrument());
    }

    // optional int32 track = 5;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track());
    }

    // optional int32 qtime = 6;
    if (cached_has_bits & 0x00000020u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_qtime());
    }

    // optional int32 bar = 7;
    if (cached_has_bits & 0x00000040u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_bar());
    }

    // optional bool is_drum = 8;
    if (cached_has_bits & 0x00000080u) {
      total_size += 1 + 1;
    }

  }
  if (cached_has_bits & 0x00000300u) {
    // optional bool should_prune = 9;
    if (cached_has_bits & 0x00000100u) {
      total_size += 1 + 1;
    }

    // optional int32 track_type = 10;
    if (cached_has_bits & 0x00000200u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track_type());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Event::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Event)
  GOOGLE_DCHECK_NE(&from, this);
  const Event* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Event>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Event)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Event)
    MergeFrom(*source);
  }
}

void Event::MergeFrom(const Event& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Event)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    if (cached_has_bits & 0x00000001u) {
      time_ = from.time_;
    }
    if (cached_has_bits & 0x00000002u) {
      velocity_ = from.velocity_;
    }
    if (cached_has_bits & 0x00000004u) {
      pitch_ = from.pitch_;
    }
    if (cached_has_bits & 0x00000008u) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000010u) {
      track_ = from.track_;
    }
    if (cached_has_bits & 0x00000020u) {
      qtime_ = from.qtime_;
    }
    if (cached_has_bits & 0x00000040u) {
      bar_ = from.bar_;
    }
    if (cached_has_bits & 0x00000080u) {
      is_drum_ = from.is_drum_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  if (cached_has_bits & 0x00000300u) {
    if (cached_has_bits & 0x00000100u) {
      should_prune_ = from.should_prune_;
    }
    if (cached_has_bits & 0x00000200u) {
      track_type_ = from.track_type_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Event::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Event)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Event::CopyFrom(const Event& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Event)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Event::IsInitialized() const {
  return true;
}

void Event::InternalSwap(Event* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Event, track_type_)
      + sizeof(Event::track_type_)
      - PROTOBUF_FIELD_OFFSET(Event, time_)>(
          reinterpret_cast<char*>(&time_),
          reinterpret_cast<char*>(&other->time_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Event::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Bar::InitAsDefaultInstance() {
}
class Bar::_Internal {
 public:
  using HasBits = decltype(std::declval<Bar>()._has_bits_);
  static void set_has_is_four_four(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_has_notes(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_time(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_beat_length(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_should_prune(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_is_drum(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
};

Bar::Bar(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  events_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Bar)
}
Bar::Bar(const Bar& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      events_(from.events_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&time_, &from.time_,
    static_cast<size_t>(reinterpret_cast<char*>(&beat_length_) -
    reinterpret_cast<char*>(&time_)) + sizeof(beat_length_));
  // @@protoc_insertion_point(copy_constructor:midi.Bar)
}

void Bar::SharedCtor() {
  ::memset(&time_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&beat_length_) -
      reinterpret_cast<char*>(&time_)) + sizeof(beat_length_));
}

Bar::~Bar() {
  // @@protoc_insertion_point(destructor:midi.Bar)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Bar::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Bar::ArenaDtor(void* object) {
  Bar* _this = reinterpret_cast< Bar* >(object);
  (void)_this;
}
void Bar::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Bar::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Bar& Bar::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Bar_midi_2eproto.base);
  return *internal_default_instance();
}


void Bar::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Bar)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  events_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000003fu) {
    ::memset(&time_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&beat_length_) -
        reinterpret_cast<char*>(&time_)) + sizeof(beat_length_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Bar::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated int32 events = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_events(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_events(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool is_four_four = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_is_four_four(&has_bits);
          is_four_four_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool has_notes = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_has_notes(&has_bits);
          has_notes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 time = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_time(&has_bits);
          time_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional float beat_length = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 45)) {
          _Internal::set_has_beat_length(&has_bits);
          beat_length_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else goto handle_unusual;
        continue;
      // optional bool should_prune = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          _Internal::set_has_should_prune(&has_bits);
          should_prune_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool is_drum = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_is_drum(&has_bits);
          is_drum_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Bar::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Bar)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated int32 events = 1;
  for (int i = 0, n = this->_internal_events_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_events(i), target);
  }

  cached_has_bits = _has_bits_[0];
  // optional bool is_four_four = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_is_four_four(), target);
  }

  // optional bool has_notes = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_has_notes(), target);
  }

  // optional int32 time = 4;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_time(), target);
  }

  // optional float beat_length = 5;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(5, this->_internal_beat_length(), target);
  }

  // optional bool should_prune = 6;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(6, this->_internal_should_prune(), target);
  }

  // optional bool is_drum = 7;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(7, this->_internal_is_drum(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Bar)
  return target;
}

size_t Bar::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Bar)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated int32 events = 1;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->events_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_events_size());
    total_size += data_size;
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000003fu) {
    // optional int32 time = 4;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_time());
    }

    // optional bool is_four_four = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 + 1;
    }

    // optional bool has_notes = 3;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 + 1;
    }

    // optional bool should_prune = 6;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 + 1;
    }

    // optional bool is_drum = 7;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 + 1;
    }

    // optional float beat_length = 5;
    if (cached_has_bits & 0x00000020u) {
      total_size += 1 + 4;
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Bar::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Bar)
  GOOGLE_DCHECK_NE(&from, this);
  const Bar* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Bar>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Bar)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Bar)
    MergeFrom(*source);
  }
}

void Bar::MergeFrom(const Bar& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Bar)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  events_.MergeFrom(from.events_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000003fu) {
    if (cached_has_bits & 0x00000001u) {
      time_ = from.time_;
    }
    if (cached_has_bits & 0x00000002u) {
      is_four_four_ = from.is_four_four_;
    }
    if (cached_has_bits & 0x00000004u) {
      has_notes_ = from.has_notes_;
    }
    if (cached_has_bits & 0x00000008u) {
      should_prune_ = from.should_prune_;
    }
    if (cached_has_bits & 0x00000010u) {
      is_drum_ = from.is_drum_;
    }
    if (cached_has_bits & 0x00000020u) {
      beat_length_ = from.beat_length_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Bar::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Bar)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Bar::CopyFrom(const Bar& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Bar)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Bar::IsInitialized() const {
  return true;
}

void Bar::InternalSwap(Bar* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  events_.InternalSwap(&other->events_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Bar, beat_length_)
      + sizeof(Bar::beat_length_)
      - PROTOBUF_FIELD_OFFSET(Bar, time_)>(
          reinterpret_cast<char*>(&time_),
          reinterpret_cast<char*>(&other->time_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Bar::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Track::InitAsDefaultInstance() {
}
class Track::_Internal {
 public:
  using HasBits = decltype(std::declval<Track>()._has_bits_);
  static void set_has_is_drum(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_min_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_max_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_av_polyphony(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_note_density(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_note_density_v2(HasBits* has_bits) {
    (*has_bits)[0] |= 128u;
  }
  static void set_has_te_track(HasBits* has_bits) {
    (*has_bits)[0] |= 256u;
  }
  static void set_has_max_polyphony(HasBits* has_bits) {
    (*has_bits)[0] |= 512u;
  }
  static void set_has_type(HasBits* has_bits) {
    (*has_bits)[0] |= 1024u;
  }
  static void set_has_should_prune(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_order(HasBits* has_bits) {
    (*has_bits)[0] |= 2048u;
  }
};

Track::Track(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  bars_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Track)
}
Track::Track(const Track& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      bars_(from.bars_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&min_pitch_, &from.min_pitch_,
    static_cast<size_t>(reinterpret_cast<char*>(&order_) -
    reinterpret_cast<char*>(&min_pitch_)) + sizeof(order_));
  // @@protoc_insertion_point(copy_constructor:midi.Track)
}

void Track::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Track_midi_2eproto.base);
  ::memset(&min_pitch_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&order_) -
      reinterpret_cast<char*>(&min_pitch_)) + sizeof(order_));
}

Track::~Track() {
  // @@protoc_insertion_point(destructor:midi.Track)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Track::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Track::ArenaDtor(void* object) {
  Track* _this = reinterpret_cast< Track* >(object);
  (void)_this;
}
void Track::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Track::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Track& Track::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Track_midi_2eproto.base);
  return *internal_default_instance();
}


void Track::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Track)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  bars_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    ::memset(&min_pitch_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&note_density_v2_) -
        reinterpret_cast<char*>(&min_pitch_)) + sizeof(note_density_v2_));
  }
  if (cached_has_bits & 0x00000f00u) {
    ::memset(&te_track_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&order_) -
        reinterpret_cast<char*>(&te_track_)) + sizeof(order_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Track::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.Bar bars = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_bars(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      // optional bool is_drum = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_is_drum(&has_bits);
          is_drum_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 min_pitch = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_min_pitch(&has_bits);
          min_pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 max_pitch = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_max_pitch(&has_bits);
          max_pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 instrument = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          _Internal::set_has_instrument(&has_bits);
          instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional float av_polyphony = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 53)) {
          _Internal::set_has_av_polyphony(&has_bits);
          av_polyphony_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else goto handle_unusual;
        continue;
      // optional int32 note_density = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_note_density(&has_bits);
          note_density_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 note_density_v2 = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          _Internal::set_has_note_density_v2(&has_bits);
          note_density_v2_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 te_track = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
          _Internal::set_has_te_track(&has_bits);
          te_track_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 max_polyphony = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
          _Internal::set_has_max_polyphony(&has_bits);
          max_polyphony_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 type = 11;
      case 11:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 88)) {
          _Internal::set_has_type(&has_bits);
          type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool should_prune = 12;
      case 12:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) {
          _Internal::set_has_should_prune(&has_bits);
          should_prune_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 order = 13;
      case 13:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) {
          _Internal::set_has_order(&has_bits);
          order_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Track::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Track)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.Bar bars = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_bars_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_bars(i), target, stream);
  }

  cached_has_bits = _has_bits_[0];
  // optional bool is_drum = 2;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(2, this->_internal_is_drum(), target);
  }

  // optional int32 min_pitch = 3;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_min_pitch(), target);
  }

  // optional int32 max_pitch = 4;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_max_pitch(), target);
  }

  // optional int32 instrument = 5;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_instrument(), target);
  }

  // optional float av_polyphony = 6;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(6, this->_internal_av_polyphony(), target);
  }

  // optional int32 note_density = 7;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_note_density(), target);
  }

  // optional int32 note_density_v2 = 8;
  if (cached_has_bits & 0x00000080u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(8, this->_internal_note_density_v2(), target);
  }

  // optional int32 te_track = 9;
  if (cached_has_bits & 0x00000100u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(9, this->_internal_te_track(), target);
  }

  // optional int32 max_polyphony = 10;
  if (cached_has_bits & 0x00000200u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(10, this->_internal_max_polyphony(), target);
  }

  // optional int32 type = 11;
  if (cached_has_bits & 0x00000400u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(11, this->_internal_type(), target);
  }

  // optional bool should_prune = 12;
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(12, this->_internal_should_prune(), target);
  }

  // optional int32 order = 13;
  if (cached_has_bits & 0x00000800u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(13, this->_internal_order(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Track)
  return target;
}

size_t Track::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Track)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.Bar bars = 1;
  total_size += 1UL * this->_internal_bars_size();
  for (const auto& msg : this->bars_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    // optional int32 min_pitch = 3;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_min_pitch());
    }

    // optional int32 max_pitch = 4;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_max_pitch());
    }

    // optional int32 instrument = 5;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_instrument());
    }

    // optional float av_polyphony = 6;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 + 4;
    }

    // optional int32 note_density = 7;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_note_density());
    }

    // optional bool is_drum = 2;
    if (cached_has_bits & 0x00000020u) {
      total_size += 1 + 1;
    }

    // optional bool should_prune = 12;
    if (cached_has_bits & 0x00000040u) {
      total_size += 1 + 1;
    }

    // optional int32 note_density_v2 = 8;
    if (cached_has_bits & 0x00000080u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_note_density_v2());
    }

  }
  if (cached_has_bits & 0x00000f00u) {
    // optional int32 te_track = 9;
    if (cached_has_bits & 0x00000100u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_te_track());
    }

    // optional int32 max_polyphony = 10;
    if (cached_has_bits & 0x00000200u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_max_polyphony());
    }

    // optional int32 type = 11;
    if (cached_has_bits & 0x00000400u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_type());
    }

    // optional int32 order = 13;
    if (cached_has_bits & 0x00000800u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_order());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Track::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Track)
  GOOGLE_DCHECK_NE(&from, this);
  const Track* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Track>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Track)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Track)
    MergeFrom(*source);
  }
}

void Track::MergeFrom(const Track& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Track)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  bars_.MergeFrom(from.bars_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    if (cached_has_bits & 0x00000001u) {
      min_pitch_ = from.min_pitch_;
    }
    if (cached_has_bits & 0x00000002u) {
      max_pitch_ = from.max_pitch_;
    }
    if (cached_has_bits & 0x00000004u) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000008u) {
      av_polyphony_ = from.av_polyphony_;
    }
    if (cached_has_bits & 0x00000010u) {
      note_density_ = from.note_density_;
    }
    if (cached_has_bits & 0x00000020u) {
      is_drum_ = from.is_drum_;
    }
    if (cached_has_bits & 0x00000040u) {
      should_prune_ = from.should_prune_;
    }
    if (cached_has_bits & 0x00000080u) {
      note_density_v2_ = from.note_density_v2_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  if (cached_has_bits & 0x00000f00u) {
    if (cached_has_bits & 0x00000100u) {
      te_track_ = from.te_track_;
    }
    if (cached_has_bits & 0x00000200u) {
      max_polyphony_ = from.max_polyphony_;
    }
    if (cached_has_bits & 0x00000400u) {
      type_ = from.type_;
    }
    if (cached_has_bits & 0x00000800u) {
      order_ = from.order_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Track::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Track)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Track::CopyFrom(const Track& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Track)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Track::IsInitialized() const {
  return true;
}

void Track::InternalSwap(Track* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  bars_.InternalSwap(&other->bars_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Track, order_)
      + sizeof(Track::order_)
      - PROTOBUF_FIELD_OFFSET(Track, min_pitch_)>(
          reinterpret_cast<char*>(&min_pitch_),
          reinterpret_cast<char*>(&other->min_pitch_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Track::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void ValidTrack::InitAsDefaultInstance() {
}
class ValidTrack::_Internal {
 public:
};

ValidTrack::ValidTrack(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  tracks_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.ValidTrack)
}
ValidTrack::ValidTrack(const ValidTrack& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      tracks_(from.tracks_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:midi.ValidTrack)
}

void ValidTrack::SharedCtor() {
}

ValidTrack::~ValidTrack() {
  // @@protoc_insertion_point(destructor:midi.ValidTrack)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void ValidTrack::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void ValidTrack::ArenaDtor(void* object) {
  ValidTrack* _this = reinterpret_cast< ValidTrack* >(object);
  (void)_this;
}
void ValidTrack::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void ValidTrack::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const ValidTrack& ValidTrack::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_ValidTrack_midi_2eproto.base);
  return *internal_default_instance();
}


void ValidTrack::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.ValidTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  tracks_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* ValidTrack::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated int32 tracks = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_tracks(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_tracks(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* ValidTrack::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.ValidTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated int32 tracks = 1;
  for (int i = 0, n = this->_internal_tracks_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_tracks(i), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.ValidTrack)
  return target;
}

size_t ValidTrack::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.ValidTrack)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated int32 tracks = 1;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->tracks_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_tracks_size());
    total_size += data_size;
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void ValidTrack::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.ValidTrack)
  GOOGLE_DCHECK_NE(&from, this);
  const ValidTrack* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<ValidTrack>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.ValidTrack)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.ValidTrack)
    MergeFrom(*source);
  }
}

void ValidTrack::MergeFrom(const ValidTrack& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.ValidTrack)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  tracks_.MergeFrom(from.tracks_);
}

void ValidTrack::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.ValidTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void ValidTrack::CopyFrom(const ValidTrack& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.ValidTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool ValidTrack::IsInitialized() const {
  return true;
}

void ValidTrack::InternalSwap(ValidTrack* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  tracks_.InternalSwap(&other->tracks_);
}

::PROTOBUF_NAMESPACE_ID::Metadata ValidTrack::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Piece::InitAsDefaultInstance() {
}
class Piece::_Internal {
 public:
  using HasBits = decltype(std::declval<Piece>()._has_bits_);
  static void set_has_resolution(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_tempo(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_min_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_max_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_segment_length(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
};

Piece::Piece(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  tracks_(arena),
  events_(arena),
  valid_segments_(arena),
  valid_tracks_(arena),
  msd_cd1_(arena),
  msd_cd2_(arena),
  msd_cd2c_(arena),
  valid_tracks_v2_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Piece)
}
Piece::Piece(const Piece& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      tracks_(from.tracks_),
      events_(from.events_),
      valid_segments_(from.valid_segments_),
      valid_tracks_(from.valid_tracks_),
      msd_cd1_(from.msd_cd1_),
      msd_cd2_(from.msd_cd2_),
      msd_cd2c_(from.msd_cd2c_),
      valid_tracks_v2_(from.valid_tracks_v2_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&resolution_, &from.resolution_,
    static_cast<size_t>(reinterpret_cast<char*>(&segment_length_) -
    reinterpret_cast<char*>(&resolution_)) + sizeof(segment_length_));
  // @@protoc_insertion_point(copy_constructor:midi.Piece)
}

void Piece::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Piece_midi_2eproto.base);
  ::memset(&resolution_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&segment_length_) -
      reinterpret_cast<char*>(&resolution_)) + sizeof(segment_length_));
}

Piece::~Piece() {
  // @@protoc_insertion_point(destructor:midi.Piece)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Piece::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Piece::ArenaDtor(void* object) {
  Piece* _this = reinterpret_cast< Piece* >(object);
  (void)_this;
}
void Piece::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Piece::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Piece& Piece::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Piece_midi_2eproto.base);
  return *internal_default_instance();
}


void Piece::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Piece)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  tracks_.Clear();
  events_.Clear();
  valid_segments_.Clear();
  valid_tracks_.Clear();
  msd_cd1_.Clear();
  msd_cd2_.Clear();
  msd_cd2c_.Clear();
  valid_tracks_v2_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000001fu) {
    ::memset(&resolution_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&segment_length_) -
        reinterpret_cast<char*>(&resolution_)) + sizeof(segment_length_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Piece::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.Track tracks = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_tracks(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated .midi.Event events = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_events(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
        } else goto handle_unusual;
        continue;
      // optional int32 resolution = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_resolution(&has_bits);
          resolution_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 tempo = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_tempo(&has_bits);
          tempo_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 min_pitch = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          _Internal::set_has_min_pitch(&has_bits);
          min_pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 max_pitch = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          _Internal::set_has_max_pitch(&has_bits);
          max_pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated int32 valid_segments = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_valid_segments(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<56>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_valid_segments(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated uint32 valid_tracks = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_valid_tracks(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint32(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<64>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedUInt32Parser(_internal_mutable_valid_tracks(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated string msd_cd1 = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) {
          ptr -= 1;
          do {
            ptr += 1;
            auto str = _internal_add_msd_cd1();
            ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
            #ifndef NDEBUG
            ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.Piece.msd_cd1");
            #endif  // !NDEBUG
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<74>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated string msd_cd2 = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82)) {
          ptr -= 1;
          do {
            ptr += 1;
            auto str = _internal_add_msd_cd2();
            ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
            #ifndef NDEBUG
            ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.Piece.msd_cd2");
            #endif  // !NDEBUG
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated string msd_cd2c = 11;
      case 11:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 90)) {
          ptr -= 1;
          do {
            ptr += 1;
            auto str = _internal_add_msd_cd2c();
            ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
            #ifndef NDEBUG
            ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.Piece.msd_cd2c");
            #endif  // !NDEBUG
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<90>(ptr));
        } else goto handle_unusual;
        continue;
      // optional int32 segment_length = 12;
      case 12:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) {
          _Internal::set_has_segment_length(&has_bits);
          segment_length_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated .midi.ValidTrack valid_tracks_v2 = 13;
      case 13:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 106)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_valid_tracks_v2(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<106>(ptr));
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Piece::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Piece)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.Track tracks = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_tracks_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_tracks(i), target, stream);
  }

  // repeated .midi.Event events = 2;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_events_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(2, this->_internal_events(i), target, stream);
  }

  cached_has_bits = _has_bits_[0];
  // optional int32 resolution = 3;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_resolution(), target);
  }

  // optional int32 tempo = 4;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_tempo(), target);
  }

  // optional int32 min_pitch = 5;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_min_pitch(), target);
  }

  // optional int32 max_pitch = 6;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(6, this->_internal_max_pitch(), target);
  }

  // repeated int32 valid_segments = 7;
  for (int i = 0, n = this->_internal_valid_segments_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_valid_segments(i), target);
  }

  // repeated uint32 valid_tracks = 8;
  for (int i = 0, n = this->_internal_valid_tracks_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt32ToArray(8, this->_internal_valid_tracks(i), target);
  }

  // repeated string msd_cd1 = 9;
  for (int i = 0, n = this->_internal_msd_cd1_size(); i < n; i++) {
    const auto& s = this->_internal_msd_cd1(i);
    ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
      s.data(), static_cast<int>(s.length()),
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
      "midi.Piece.msd_cd1");
    target = stream->WriteString(9, s, target);
  }

  // repeated string msd_cd2 = 10;
  for (int i = 0, n = this->_internal_msd_cd2_size(); i < n; i++) {
    const auto& s = this->_internal_msd_cd2(i);
    ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
      s.data(), static_cast<int>(s.length()),
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
      "midi.Piece.msd_cd2");
    target = stream->WriteString(10, s, target);
  }

  // repeated string msd_cd2c = 11;
  for (int i = 0, n = this->_internal_msd_cd2c_size(); i < n; i++) {
    const auto& s = this->_internal_msd_cd2c(i);
    ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
      s.data(), static_cast<int>(s.length()),
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
      "midi.Piece.msd_cd2c");
    target = stream->WriteString(11, s, target);
  }

  // optional int32 segment_length = 12;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(12, this->_internal_segment_length(), target);
  }

  // repeated .midi.ValidTrack valid_tracks_v2 = 13;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_valid_tracks_v2_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(13, this->_internal_valid_tracks_v2(i), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Piece)
  return target;
}

size_t Piece::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Piece)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.Track tracks = 1;
  total_size += 1UL * this->_internal_tracks_size();
  for (const auto& msg : this->tracks_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated .midi.Event events = 2;
  total_size += 1UL * this->_internal_events_size();
  for (const auto& msg : this->events_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated int32 valid_segments = 7;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->valid_segments_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_valid_segments_size());
    total_size += data_size;
  }

  // repeated uint32 valid_tracks = 8;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      UInt32Size(this->valid_tracks_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_valid_tracks_size());
    total_size += data_size;
  }

  // repeated string msd_cd1 = 9;
  total_size += 1 *
      ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(msd_cd1_.size());
  for (int i = 0, n = msd_cd1_.size(); i < n; i++) {
    total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
      msd_cd1_.Get(i));
  }

  // repeated string msd_cd2 = 10;
  total_size += 1 *
      ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(msd_cd2_.size());
  for (int i = 0, n = msd_cd2_.size(); i < n; i++) {
    total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
      msd_cd2_.Get(i));
  }

  // repeated string msd_cd2c = 11;
  total_size += 1 *
      ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(msd_cd2c_.size());
  for (int i = 0, n = msd_cd2c_.size(); i < n; i++) {
    total_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
      msd_cd2c_.Get(i));
  }

  // repeated .midi.ValidTrack valid_tracks_v2 = 13;
  total_size += 1UL * this->_internal_valid_tracks_v2_size();
  for (const auto& msg : this->valid_tracks_v2_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000001fu) {
    // optional int32 resolution = 3;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_resolution());
    }

    // optional int32 tempo = 4;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_tempo());
    }

    // optional int32 min_pitch = 5;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_min_pitch());
    }

    // optional int32 max_pitch = 6;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_max_pitch());
    }

    // optional int32 segment_length = 12;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_segment_length());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Piece::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Piece)
  GOOGLE_DCHECK_NE(&from, this);
  const Piece* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Piece>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Piece)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Piece)
    MergeFrom(*source);
  }
}

void Piece::MergeFrom(const Piece& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Piece)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  tracks_.MergeFrom(from.tracks_);
  events_.MergeFrom(from.events_);
  valid_segments_.MergeFrom(from.valid_segments_);
  valid_tracks_.MergeFrom(from.valid_tracks_);
  msd_cd1_.MergeFrom(from.msd_cd1_);
  msd_cd2_.MergeFrom(from.msd_cd2_);
  msd_cd2c_.MergeFrom(from.msd_cd2c_);
  valid_tracks_v2_.MergeFrom(from.valid_tracks_v2_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000001fu) {
    if (cached_has_bits & 0x00000001u) {
      resolution_ = from.resolution_;
    }
    if (cached_has_bits & 0x00000002u) {
      tempo_ = from.tempo_;
    }
    if (cached_has_bits & 0x00000004u) {
      min_pitch_ = from.min_pitch_;
    }
    if (cached_has_bits & 0x00000008u) {
      max_pitch_ = from.max_pitch_;
    }
    if (cached_has_bits & 0x00000010u) {
      segment_length_ = from.segment_length_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Piece::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Piece)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Piece::CopyFrom(const Piece& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Piece)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Piece::IsInitialized() const {
  return true;
}

void Piece::InternalSwap(Piece* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  tracks_.InternalSwap(&other->tracks_);
  events_.InternalSwap(&other->events_);
  valid_segments_.InternalSwap(&other->valid_segments_);
  valid_tracks_.InternalSwap(&other->valid_tracks_);
  msd_cd1_.InternalSwap(&other->msd_cd1_);
  msd_cd2_.InternalSwap(&other->msd_cd2_);
  msd_cd2c_.InternalSwap(&other->msd_cd2c_);
  valid_tracks_v2_.InternalSwap(&other->valid_tracks_v2_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Piece, segment_length_)
      + sizeof(Piece::segment_length_)
      - PROTOBUF_FIELD_OFFSET(Piece, resolution_)>(
          reinterpret_cast<char*>(&resolution_),
          reinterpret_cast<char*>(&other->resolution_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Piece::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void StatusTrack::InitAsDefaultInstance() {
}
class StatusTrack::_Internal {
 public:
  using HasBits = decltype(std::declval<StatusTrack>()._has_bits_);
  static void set_has_track_id(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_track_type(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_density(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
};

StatusTrack::StatusTrack(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  selected_bars_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.StatusTrack)
}
StatusTrack::StatusTrack(const StatusTrack& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      selected_bars_(from.selected_bars_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  instrument_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  if (from._internal_has_instrument()) {
    instrument_.Set(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), from._internal_instrument(),
      GetArena());
  }
  ::memcpy(&track_id_, &from.track_id_,
    static_cast<size_t>(reinterpret_cast<char*>(&density_) -
    reinterpret_cast<char*>(&track_id_)) + sizeof(density_));
  // @@protoc_insertion_point(copy_constructor:midi.StatusTrack)
}

void StatusTrack::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_StatusTrack_midi_2eproto.base);
  instrument_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  ::memset(&track_id_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&density_) -
      reinterpret_cast<char*>(&track_id_)) + sizeof(density_));
}

StatusTrack::~StatusTrack() {
  // @@protoc_insertion_point(destructor:midi.StatusTrack)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void StatusTrack::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
  instrument_.DestroyNoArena(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
}

void StatusTrack::ArenaDtor(void* object) {
  StatusTrack* _this = reinterpret_cast< StatusTrack* >(object);
  (void)_this;
}
void StatusTrack::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void StatusTrack::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const StatusTrack& StatusTrack::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_StatusTrack_midi_2eproto.base);
  return *internal_default_instance();
}


void StatusTrack::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.StatusTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  selected_bars_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    instrument_.ClearNonDefaultToEmpty();
  }
  if (cached_has_bits & 0x0000000eu) {
    ::memset(&track_id_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&density_) -
        reinterpret_cast<char*>(&track_id_)) + sizeof(density_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* StatusTrack::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // optional int32 track_id = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_track_id(&has_bits);
          track_id_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 track_type = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_track_type(&has_bits);
          track_type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional string instrument = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
          auto str = _internal_mutable_instrument();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          #ifndef NDEBUG
          ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.StatusTrack.instrument");
          #endif  // !NDEBUG
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 density = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_density(&has_bits);
          density_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated bool selected_bars = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_selected_bars(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<40>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedBoolParser(_internal_mutable_selected_bars(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* StatusTrack::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.StatusTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 track_id = 1;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_track_id(), target);
  }

  // optional int32 track_type = 2;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_track_type(), target);
  }

  // optional string instrument = 3;
  if (cached_has_bits & 0x00000001u) {
    ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::VerifyUTF8StringNamedField(
      this->_internal_instrument().data(), static_cast<int>(this->_internal_instrument().length()),
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::SERIALIZE,
      "midi.StatusTrack.instrument");
    target = stream->WriteStringMaybeAliased(
        3, this->_internal_instrument(), target);
  }

  // optional int32 density = 4;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_density(), target);
  }

  // repeated bool selected_bars = 5;
  for (int i = 0, n = this->_internal_selected_bars_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(5, this->_internal_selected_bars(i), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.StatusTrack)
  return target;
}

size_t StatusTrack::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.StatusTrack)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated bool selected_bars = 5;
  {
    unsigned int count = static_cast<unsigned int>(this->_internal_selected_bars_size());
    size_t data_size = 1UL * count;
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_selected_bars_size());
    total_size += data_size;
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    // optional string instrument = 3;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
          this->_internal_instrument());
    }

    // optional int32 track_id = 1;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track_id());
    }

    // optional int32 track_type = 2;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track_type());
    }

    // optional int32 density = 4;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_density());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void StatusTrack::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.StatusTrack)
  GOOGLE_DCHECK_NE(&from, this);
  const StatusTrack* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<StatusTrack>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.StatusTrack)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.StatusTrack)
    MergeFrom(*source);
  }
}

void StatusTrack::MergeFrom(const StatusTrack& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.StatusTrack)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  selected_bars_.MergeFrom(from.selected_bars_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_instrument(from._internal_instrument());
    }
    if (cached_has_bits & 0x00000002u) {
      track_id_ = from.track_id_;
    }
    if (cached_has_bits & 0x00000004u) {
      track_type_ = from.track_type_;
    }
    if (cached_has_bits & 0x00000008u) {
      density_ = from.density_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void StatusTrack::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.StatusTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void StatusTrack::CopyFrom(const StatusTrack& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.StatusTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool StatusTrack::IsInitialized() const {
  return true;
}

void StatusTrack::InternalSwap(StatusTrack* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  selected_bars_.InternalSwap(&other->selected_bars_);
  instrument_.Swap(&other->instrument_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(StatusTrack, density_)
      + sizeof(StatusTrack::density_)
      - PROTOBUF_FIELD_OFFSET(StatusTrack, track_id_)>(
          reinterpret_cast<char*>(&track_id_),
          reinterpret_cast<char*>(&other->track_id_));
}

::PROTOBUF_NAMESPACE_ID::Metadata StatusTrack::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Status::InitAsDefaultInstance() {
}
class Status::_Internal {
 public:
};

Status::Status(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  tracks_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Status)
}
Status::Status(const Status& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      tracks_(from.tracks_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:midi.Status)
}

void Status::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Status_midi_2eproto.base);
}

Status::~Status() {
  // @@protoc_insertion_point(destructor:midi.Status)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Status::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Status::ArenaDtor(void* object) {
  Status* _this = reinterpret_cast< Status* >(object);
  (void)_this;
}
void Status::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Status::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Status& Status::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Status_midi_2eproto.base);
  return *internal_default_instance();
}


void Status::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Status)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  tracks_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Status::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.StatusTrack tracks = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_tracks(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Status::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Status)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.StatusTrack tracks = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_tracks_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_tracks(i), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Status)
  return target;
}

size_t Status::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Status)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.StatusTrack tracks = 1;
  total_size += 1UL * this->_internal_tracks_size();
  for (const auto& msg : this->tracks_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Status::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Status)
  GOOGLE_DCHECK_NE(&from, this);
  const Status* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Status>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Status)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Status)
    MergeFrom(*source);
  }
}

void Status::MergeFrom(const Status& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Status)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  tracks_.MergeFrom(from.tracks_);
}

void Status::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Status)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Status::CopyFrom(const Status& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Status)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Status::IsInitialized() const {
  return true;
}

void Status::InternalSwap(Status* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  tracks_.InternalSwap(&other->tracks_);
}

::PROTOBUF_NAMESPACE_ID::Metadata Status::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void MEvent::InitAsDefaultInstance() {
}
class MEvent::_Internal {
 public:
  using HasBits = decltype(std::declval<MEvent>()._has_bits_);
  static void set_has_time(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_velocity(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_pitch(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
};

MEvent::MEvent(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.MEvent)
}
MEvent::MEvent(const MEvent& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&time_, &from.time_,
    static_cast<size_t>(reinterpret_cast<char*>(&pitch_) -
    reinterpret_cast<char*>(&time_)) + sizeof(pitch_));
  // @@protoc_insertion_point(copy_constructor:midi.MEvent)
}

void MEvent::SharedCtor() {
  ::memset(&time_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&pitch_) -
      reinterpret_cast<char*>(&time_)) + sizeof(pitch_));
}

MEvent::~MEvent() {
  // @@protoc_insertion_point(destructor:midi.MEvent)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void MEvent::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void MEvent::ArenaDtor(void* object) {
  MEvent* _this = reinterpret_cast< MEvent* >(object);
  (void)_this;
}
void MEvent::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void MEvent::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const MEvent& MEvent::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MEvent_midi_2eproto.base);
  return *internal_default_instance();
}


void MEvent::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.MEvent)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    ::memset(&time_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&pitch_) -
        reinterpret_cast<char*>(&time_)) + sizeof(pitch_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* MEvent::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // optional int32 time = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_time(&has_bits);
          time_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 velocity = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_velocity(&has_bits);
          velocity_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 pitch = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_pitch(&has_bits);
          pitch_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* MEvent::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.MEvent)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 time = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_time(), target);
  }

  // optional int32 velocity = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_velocity(), target);
  }

  // optional int32 pitch = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_pitch(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.MEvent)
  return target;
}

size_t MEvent::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.MEvent)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    // optional int32 time = 1;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_time());
    }

    // optional int32 velocity = 2;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_velocity());
    }

    // optional int32 pitch = 3;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_pitch());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void MEvent::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.MEvent)
  GOOGLE_DCHECK_NE(&from, this);
  const MEvent* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MEvent>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.MEvent)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.MEvent)
    MergeFrom(*source);
  }
}

void MEvent::MergeFrom(const MEvent& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.MEvent)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      time_ = from.time_;
    }
    if (cached_has_bits & 0x00000002u) {
      velocity_ = from.velocity_;
    }
    if (cached_has_bits & 0x00000004u) {
      pitch_ = from.pitch_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void MEvent::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.MEvent)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MEvent::CopyFrom(const MEvent& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.MEvent)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MEvent::IsInitialized() const {
  return true;
}

void MEvent::InternalSwap(MEvent* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(MEvent, pitch_)
      + sizeof(MEvent::pitch_)
      - PROTOBUF_FIELD_OFFSET(MEvent, time_)>(
          reinterpret_cast<char*>(&time_),
          reinterpret_cast<char*>(&other->time_));
}

::PROTOBUF_NAMESPACE_ID::Metadata MEvent::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void MBar::InitAsDefaultInstance() {
}
class MBar::_Internal {
 public:
  using HasBits = decltype(std::declval<MBar>()._has_bits_);
  static void set_has_beat_length(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
};

MBar::MBar(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  events_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.MBar)
}
MBar::MBar(const MBar& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      events_(from.events_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  beat_length_ = from.beat_length_;
  // @@protoc_insertion_point(copy_constructor:midi.MBar)
}

void MBar::SharedCtor() {
  beat_length_ = 0;
}

MBar::~MBar() {
  // @@protoc_insertion_point(destructor:midi.MBar)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void MBar::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void MBar::ArenaDtor(void* object) {
  MBar* _this = reinterpret_cast< MBar* >(object);
  (void)_this;
}
void MBar::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void MBar::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const MBar& MBar::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MBar_midi_2eproto.base);
  return *internal_default_instance();
}


void MBar::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.MBar)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  events_.Clear();
  beat_length_ = 0;
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* MBar::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated int32 events = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_events(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<8>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_events(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional float beat_length = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 21)) {
          _Internal::set_has_beat_length(&has_bits);
          beat_length_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* MBar::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.MBar)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated int32 events = 1;
  for (int i = 0, n = this->_internal_events_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_events(i), target);
  }

  cached_has_bits = _has_bits_[0];
  // optional float beat_length = 2;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(2, this->_internal_beat_length(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.MBar)
  return target;
}

size_t MBar::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.MBar)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated int32 events = 1;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->events_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_events_size());
    total_size += data_size;
  }

  // optional float beat_length = 2;
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    total_size += 1 + 4;
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void MBar::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.MBar)
  GOOGLE_DCHECK_NE(&from, this);
  const MBar* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MBar>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.MBar)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.MBar)
    MergeFrom(*source);
  }
}

void MBar::MergeFrom(const MBar& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.MBar)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  events_.MergeFrom(from.events_);
  if (from._internal_has_beat_length()) {
    _internal_set_beat_length(from._internal_beat_length());
  }
}

void MBar::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.MBar)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MBar::CopyFrom(const MBar& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.MBar)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MBar::IsInitialized() const {
  return true;
}

void MBar::InternalSwap(MBar* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  events_.InternalSwap(&other->events_);
  swap(beat_length_, other->beat_length_);
}

::PROTOBUF_NAMESPACE_ID::Metadata MBar::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void MTrack::InitAsDefaultInstance() {
}
class MTrack::_Internal {
 public:
  using HasBits = decltype(std::declval<MTrack>()._has_bits_);
  static void set_has_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_density(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_type(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
};

MTrack::MTrack(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  bars_(arena),
  resample_bars_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.MTrack)
}
MTrack::MTrack(const MTrack& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_),
      bars_(from.bars_),
      resample_bars_(from.resample_bars_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&instrument_, &from.instrument_,
    static_cast<size_t>(reinterpret_cast<char*>(&type_) -
    reinterpret_cast<char*>(&instrument_)) + sizeof(type_));
  // @@protoc_insertion_point(copy_constructor:midi.MTrack)
}

void MTrack::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MTrack_midi_2eproto.base);
  ::memset(&instrument_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&type_) -
      reinterpret_cast<char*>(&instrument_)) + sizeof(type_));
}

MTrack::~MTrack() {
  // @@protoc_insertion_point(destructor:midi.MTrack)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void MTrack::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void MTrack::ArenaDtor(void* object) {
  MTrack* _this = reinterpret_cast< MTrack* >(object);
  (void)_this;
}
void MTrack::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void MTrack::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const MTrack& MTrack::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MTrack_midi_2eproto.base);
  return *internal_default_instance();
}


void MTrack::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.MTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  bars_.Clear();
  resample_bars_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    ::memset(&instrument_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&type_) -
        reinterpret_cast<char*>(&instrument_)) + sizeof(type_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* MTrack::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.MBar bars = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_bars(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      // optional int32 instrument = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_instrument(&has_bits);
          instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 density = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_density(&has_bits);
          density_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 type = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_type(&has_bits);
          type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated int32 resample_bars = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_resample_bars(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<40>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 42) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_resample_bars(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* MTrack::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.MTrack)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.MBar bars = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_bars_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_bars(i), target, stream);
  }

  cached_has_bits = _has_bits_[0];
  // optional int32 instrument = 2;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_instrument(), target);
  }

  // optional int32 density = 3;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_density(), target);
  }

  // optional int32 type = 4;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_type(), target);
  }

  // repeated int32 resample_bars = 5;
  for (int i = 0, n = this->_internal_resample_bars_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_resample_bars(i), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.MTrack)
  return target;
}

size_t MTrack::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.MTrack)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.MBar bars = 1;
  total_size += 1UL * this->_internal_bars_size();
  for (const auto& msg : this->bars_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated int32 resample_bars = 5;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->resample_bars_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_resample_bars_size());
    total_size += data_size;
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    // optional int32 instrument = 2;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_instrument());
    }

    // optional int32 density = 3;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_density());
    }

    // optional int32 type = 4;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_type());
    }

  }
  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void MTrack::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.MTrack)
  GOOGLE_DCHECK_NE(&from, this);
  const MTrack* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MTrack>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.MTrack)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.MTrack)
    MergeFrom(*source);
  }
}

void MTrack::MergeFrom(const MTrack& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.MTrack)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  bars_.MergeFrom(from.bars_);
  resample_bars_.MergeFrom(from.resample_bars_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000002u) {
      density_ = from.density_;
    }
    if (cached_has_bits & 0x00000004u) {
      type_ = from.type_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void MTrack::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.MTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MTrack::CopyFrom(const MTrack& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.MTrack)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MTrack::IsInitialized() const {
  return true;
}

void MTrack::InternalSwap(MTrack* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  bars_.InternalSwap(&other->bars_);
  resample_bars_.InternalSwap(&other->resample_bars_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(MTrack, type_)
      + sizeof(MTrack::type_)
      - PROTOBUF_FIELD_OFFSET(MTrack, instrument_)>(
          reinterpret_cast<char*>(&instrument_),
          reinterpret_cast<char*>(&other->instrument_));
}

::PROTOBUF_NAMESPACE_ID::Metadata MTrack::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void MPiece::InitAsDefaultInstance() {
}
class MPiece::_Internal {
 public:
};

MPiece::MPiece(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  tracks_(arena),
  events_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.MPiece)
}
MPiece::MPiece(const MPiece& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      tracks_(from.tracks_),
      events_(from.events_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:midi.MPiece)
}

void MPiece::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_MPiece_midi_2eproto.base);
}

MPiece::~MPiece() {
  // @@protoc_insertion_point(destructor:midi.MPiece)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void MPiece::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void MPiece::ArenaDtor(void* object) {
  MPiece* _this = reinterpret_cast< MPiece* >(object);
  (void)_this;
}
void MPiece::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void MPiece::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const MPiece& MPiece::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_MPiece_midi_2eproto.base);
  return *internal_default_instance();
}


void MPiece::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.MPiece)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  tracks_.Clear();
  events_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* MPiece::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.MTrack tracks = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_tracks(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated .midi.MEvent events = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_events(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* MPiece::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.MPiece)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.MTrack tracks = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_tracks_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_tracks(i), target, stream);
  }

  // repeated .midi.MEvent events = 2;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_events_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(2, this->_internal_events(i), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.MPiece)
  return target;
}

size_t MPiece::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.MPiece)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.MTrack tracks = 1;
  total_size += 1UL * this->_internal_tracks_size();
  for (const auto& msg : this->tracks_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated .midi.MEvent events = 2;
  total_size += 1UL * this->_internal_events_size();
  for (const auto& msg : this->events_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void MPiece::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.MPiece)
  GOOGLE_DCHECK_NE(&from, this);
  const MPiece* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<MPiece>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.MPiece)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.MPiece)
    MergeFrom(*source);
  }
}

void MPiece::MergeFrom(const MPiece& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.MPiece)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  tracks_.MergeFrom(from.tracks_);
  events_.MergeFrom(from.events_);
}

void MPiece::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.MPiece)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void MPiece::CopyFrom(const MPiece& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.MPiece)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool MPiece::IsInitialized() const {
  return true;
}

void MPiece::InternalSwap(MPiece* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  tracks_.InternalSwap(&other->tracks_);
  events_.InternalSwap(&other->events_);
}

::PROTOBUF_NAMESPACE_ID::Metadata MPiece::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Dataset_Item::InitAsDefaultInstance() {
}
class Dataset_Item::_Internal {
 public:
  using HasBits = decltype(std::declval<Dataset_Item>()._has_bits_);
  static void set_has_start(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_end(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_src_size(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static bool MissingRequiredFields(const HasBits& has_bits) {
    return ((has_bits[0] & 0x00000007) ^ 0x00000007) != 0;
  }
};

Dataset_Item::Dataset_Item(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Dataset.Item)
}
Dataset_Item::Dataset_Item(const Dataset_Item& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&start_, &from.start_,
    static_cast<size_t>(reinterpret_cast<char*>(&src_size_) -
    reinterpret_cast<char*>(&start_)) + sizeof(src_size_));
  // @@protoc_insertion_point(copy_constructor:midi.Dataset.Item)
}

void Dataset_Item::SharedCtor() {
  ::memset(&start_, 0, static_cast<size_t>(
      reinterpret_cast<char*>(&src_size_) -
      reinterpret_cast<char*>(&start_)) + sizeof(src_size_));
}

Dataset_Item::~Dataset_Item() {
  // @@protoc_insertion_point(destructor:midi.Dataset.Item)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Dataset_Item::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Dataset_Item::ArenaDtor(void* object) {
  Dataset_Item* _this = reinterpret_cast< Dataset_Item* >(object);
  (void)_this;
}
void Dataset_Item::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Dataset_Item::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Dataset_Item& Dataset_Item::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Dataset_Item_midi_2eproto.base);
  return *internal_default_instance();
}


void Dataset_Item::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Dataset.Item)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    ::memset(&start_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&src_size_) -
        reinterpret_cast<char*>(&start_)) + sizeof(src_size_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Dataset_Item::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // required uint64 start = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_start(&has_bits);
          start_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // required uint64 end = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_end(&has_bits);
          end_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // required uint64 src_size = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_src_size(&has_bits);
          src_size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  _has_bits_.Or(has_bits);
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Dataset_Item::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Dataset.Item)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // required uint64 start = 1;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(1, this->_internal_start(), target);
  }

  // required uint64 end = 2;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(2, this->_internal_end(), target);
  }

  // required uint64 src_size = 3;
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteUInt64ToArray(3, this->_internal_src_size(), target);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Dataset.Item)
  return target;
}

size_t Dataset_Item::RequiredFieldsByteSizeFallback() const {
// @@protoc_insertion_point(required_fields_byte_size_fallback_start:midi.Dataset.Item)
  size_t total_size = 0;

  if (_internal_has_start()) {
    // required uint64 start = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_start());
  }

  if (_internal_has_end()) {
    // required uint64 end = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_end());
  }

  if (_internal_has_src_size()) {
    // required uint64 src_size = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_src_size());
  }

  return total_size;
}
size_t Dataset_Item::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Dataset.Item)
  size_t total_size = 0;

  if (((_has_bits_[0] & 0x00000007) ^ 0x00000007) == 0) {  // All required fields are present.
    // required uint64 start = 1;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_start());

    // required uint64 end = 2;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_end());

    // required uint64 src_size = 3;
    total_size += 1 +
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::UInt64Size(
        this->_internal_src_size());

  } else {
    total_size += RequiredFieldsByteSizeFallback();
  }
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Dataset_Item::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Dataset.Item)
  GOOGLE_DCHECK_NE(&from, this);
  const Dataset_Item* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Dataset_Item>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Dataset.Item)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Dataset.Item)
    MergeFrom(*source);
  }
}

void Dataset_Item::MergeFrom(const Dataset_Item& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Dataset.Item)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      start_ = from.start_;
    }
    if (cached_has_bits & 0x00000002u) {
      end_ = from.end_;
    }
    if (cached_has_bits & 0x00000004u) {
      src_size_ = from.src_size_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

void Dataset_Item::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Dataset.Item)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Dataset_Item::CopyFrom(const Dataset_Item& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Dataset.Item)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Dataset_Item::IsInitialized() const {
  if (_Internal::MissingRequiredFields(_has_bits_)) return false;
  return true;
}

void Dataset_Item::InternalSwap(Dataset_Item* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  swap(_has_bits_[0], other->_has_bits_[0]);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Dataset_Item, src_size_)
      + sizeof(Dataset_Item::src_size_)
      - PROTOBUF_FIELD_OFFSET(Dataset_Item, start_)>(
          reinterpret_cast<char*>(&start_),
          reinterpret_cast<char*>(&other->start_));
}

::PROTOBUF_NAMESPACE_ID::Metadata Dataset_Item::GetMetadata() const {
  return GetMetadataStatic();
}


// ===================================================================

void Dataset::InitAsDefaultInstance() {
}
class Dataset::_Internal {
 public:
};

Dataset::Dataset(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  train_(arena),
  valid_(arena),
  test_(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.Dataset)
}
Dataset::Dataset(const Dataset& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      train_(from.train_),
      valid_(from.valid_),
      test_(from.test_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  // @@protoc_insertion_point(copy_constructor:midi.Dataset)
}

void Dataset::SharedCtor() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&scc_info_Dataset_midi_2eproto.base);
}

Dataset::~Dataset() {
  // @@protoc_insertion_point(destructor:midi.Dataset)
  SharedDtor();
  _internal_metadata_.Delete<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

void Dataset::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
}

void Dataset::ArenaDtor(void* object) {
  Dataset* _this = reinterpret_cast< Dataset* >(object);
  (void)_this;
}
void Dataset::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void Dataset::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}
const Dataset& Dataset::default_instance() {
  ::PROTOBUF_NAMESPACE_ID::internal::InitSCC(&::scc_info_Dataset_midi_2eproto.base);
  return *internal_default_instance();
}


void Dataset::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.Dataset)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  train_.Clear();
  valid_.Clear();
  test_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* Dataset::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  ::PROTOBUF_NAMESPACE_ID::Arena* arena = GetArena(); (void)arena;
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // repeated .midi.Dataset.Item train = 1;
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 10)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_train(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<10>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated .midi.Dataset.Item valid = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 18)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_valid(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<18>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated .midi.Dataset.Item test = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 26)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_test(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<26>(ptr));
        } else goto handle_unusual;
        continue;
      default: {
      handle_unusual:
        if ((tag & 7) == 4 || tag == 0) {
          ctx->SetLastTag(tag);
          goto success;
        }
        ptr = UnknownFieldParse(tag,
            _internal_metadata_.mutable_unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(),
            ptr, ctx);
        CHK_(ptr != nullptr);
        continue;
      }
    }  // switch
  }  // while
success:
  return ptr;
failure:
  ptr = nullptr;
  goto success;
#undef CHK_
}

::PROTOBUF_NAMESPACE_ID::uint8* Dataset::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.Dataset)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  // repeated .midi.Dataset.Item train = 1;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_train_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(1, this->_internal_train(i), target, stream);
  }

  // repeated .midi.Dataset.Item valid = 2;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_valid_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(2, this->_internal_valid(i), target, stream);
  }

  // repeated .midi.Dataset.Item test = 3;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_test_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(3, this->_internal_test(i), target, stream);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormat::InternalSerializeUnknownFieldsToArray(
        _internal_metadata_.unknown_fields<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(::PROTOBUF_NAMESPACE_ID::UnknownFieldSet::default_instance), target, stream);
  }
  // @@protoc_insertion_point(serialize_to_array_end:midi.Dataset)
  return target;
}

size_t Dataset::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.Dataset)
  size_t total_size = 0;

  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  // Prevent compiler warnings about cached_has_bits being unused
  (void) cached_has_bits;

  // repeated .midi.Dataset.Item train = 1;
  total_size += 1UL * this->_internal_train_size();
  for (const auto& msg : this->train_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated .midi.Dataset.Item valid = 2;
  total_size += 1UL * this->_internal_valid_size();
  for (const auto& msg : this->valid_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated .midi.Dataset.Item test = 3;
  total_size += 1UL * this->_internal_test_size();
  for (const auto& msg : this->test_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  if (PROTOBUF_PREDICT_FALSE(_internal_metadata_.have_unknown_fields())) {
    return ::PROTOBUF_NAMESPACE_ID::internal::ComputeUnknownFieldsSize(
        _internal_metadata_, total_size, &_cached_size_);
  }
  int cached_size = ::PROTOBUF_NAMESPACE_ID::internal::ToCachedSize(total_size);
  SetCachedSize(cached_size);
  return total_size;
}

void Dataset::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.Dataset)
  GOOGLE_DCHECK_NE(&from, this);
  const Dataset* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<Dataset>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.Dataset)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.Dataset)
    MergeFrom(*source);
  }
}

void Dataset::MergeFrom(const Dataset& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.Dataset)
  GOOGLE_DCHECK_NE(&from, this);
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  train_.MergeFrom(from.train_);
  valid_.MergeFrom(from.valid_);
  test_.MergeFrom(from.test_);
}

void Dataset::CopyFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_copy_from_start:midi.Dataset)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

void Dataset::CopyFrom(const Dataset& from) {
// @@protoc_insertion_point(class_specific_copy_from_start:midi.Dataset)
  if (&from == this) return;
  Clear();
  MergeFrom(from);
}

bool Dataset::IsInitialized() const {
  if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(train_)) return false;
  if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(valid_)) return false;
  if (!::PROTOBUF_NAMESPACE_ID::internal::AllAreInitialized(test_)) return false;
  return true;
}

void Dataset::InternalSwap(Dataset* other) {
  using std::swap;
  _internal_metadata_.Swap<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(&other->_internal_metadata_);
  train_.InternalSwap(&other->train_);
  valid_.InternalSwap(&other->valid_);
  test_.InternalSwap(&other->test_);
}

::PROTOBUF_NAMESPACE_ID::Metadata Dataset::GetMetadata() const {
  return GetMetadataStatic();
}


// @@protoc_insertion_point(namespace_scope)
}  // namespace midi
PROTOBUF_NAMESPACE_OPEN
template<> PROTOBUF_NOINLINE ::midi::Note* Arena::CreateMaybeMessage< ::midi::Note >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Note >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Event* Arena::CreateMaybeMessage< ::midi::Event >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Event >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Bar* Arena::CreateMaybeMessage< ::midi::Bar >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Bar >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Track* Arena::CreateMaybeMessage< ::midi::Track >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Track >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::ValidTrack* Arena::CreateMaybeMessage< ::midi::ValidTrack >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::ValidTrack >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Piece* Arena::CreateMaybeMessage< ::midi::Piece >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Piece >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::StatusTrack* Arena::CreateMaybeMessage< ::midi::StatusTrack >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::StatusTrack >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Status* Arena::CreateMaybeMessage< ::midi::Status >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Status >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::MEvent* Arena::CreateMaybeMessage< ::midi::MEvent >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::MEvent >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::MBar* Arena::CreateMaybeMessage< ::midi::MBar >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::MBar >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::MTrack* Arena::CreateMaybeMessage< ::midi::MTrack >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::MTrack >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::MPiece* Arena::CreateMaybeMessage< ::midi::MPiece >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::MPiece >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Dataset_Item* Arena::CreateMaybeMessage< ::midi::Dataset_Item >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Dataset_Item >(arena);
}
template<> PROTOBUF_NOINLINE ::midi::Dataset* Arena::CreateMaybeMessage< ::midi::Dataset >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::Dataset >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

// @@protoc_insertion_point(global_scope)
#include <google/protobuf/port_undef.inc>
