// 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>

PROTOBUF_PRAGMA_INIT_SEG
namespace midi {
constexpr Event::Event(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : time_(0)
  , velocity_(0)
  , pitch_(0)
  , internal_instrument_(0)
  , internal_track_type_(0)
  , internal_duration_(0){}
struct EventDefaultTypeInternal {
  constexpr EventDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~EventDefaultTypeInternal() {}
  union {
    Event _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT EventDefaultTypeInternal _Event_default_instance_;
constexpr Bar::Bar(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : events_()
  , internal_feature_()
  , internal_has_notes_(false)
  , internal_beat_length_(0)
  , ts_numerator_(0)
  , ts_denominator_(0){}
struct BarDefaultTypeInternal {
  constexpr BarDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~BarDefaultTypeInternal() {}
  union {
    Bar _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT BarDefaultTypeInternal _Bar_default_instance_;
constexpr Track::Track(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : bars_()
  , internal_train_types_()
  , internal_features_()
  , instrument_(0)
  , track_type_(0)
{}
struct TrackDefaultTypeInternal {
  constexpr TrackDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~TrackDefaultTypeInternal() {}
  union {
    Track _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT TrackDefaultTypeInternal _Track_default_instance_;
constexpr Piece::Piece(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : tracks_()
  , events_()
  , internal_valid_segments_()
  , internal_valid_tracks_()
  , internal_valid_tracks_v2_()
  , internal_genre_data_()
  , resolution_(0)
  , tempo_(0)
  , internal_segment_length_(0){}
struct PieceDefaultTypeInternal {
  constexpr PieceDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~PieceDefaultTypeInternal() {}
  union {
    Piece _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT PieceDefaultTypeInternal _Piece_default_instance_;
constexpr StatusTrack::StatusTrack(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : selected_bars_()
  , internal_embeds_()
  , internal_ts_numerators_()
  , internal_ts_denominators_()
  , internal_genre_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , track_id_(0)
  , track_type_(0)

  , instrument_(0)

  , density_(0)

  , autoregressive_(false)
  , ignore_(false)
  , min_polyphony_q_(0)

  , max_polyphony_q_(0)

  , min_note_duration_q_(0)

  , max_note_duration_q_(0)
{}
struct StatusTrackDefaultTypeInternal {
  constexpr StatusTrackDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~StatusTrackDefaultTypeInternal() {}
  union {
    StatusTrack _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StatusTrackDefaultTypeInternal _StatusTrack_default_instance_;
constexpr Status::Status(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : tracks_(){}
struct StatusDefaultTypeInternal {
  constexpr StatusDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~StatusDefaultTypeInternal() {}
  union {
    Status _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT StatusDefaultTypeInternal _Status_default_instance_;
constexpr SampleParam::SampleParam(
  ::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized)
  : ckpt_(&::PROTOBUF_NAMESPACE_ID::internal::fixed_address_empty_string)
  , tracks_per_step_(0)
  , bars_per_step_(0)
  , model_dim_(0)
  , percentage_(0)
  , temperature_(0)
  , batch_size_(0)
  , shuffle_(false)
  , verbose_(false)
  , internal_skip_preprocess_(false)
  , internal_random_sample_mode_(false)
  , max_steps_(0)
  , polyphony_hard_limit_(0)
  , internal_disable_masking_(false){}
struct SampleParamDefaultTypeInternal {
  constexpr SampleParamDefaultTypeInternal()
    : _instance(::PROTOBUF_NAMESPACE_ID::internal::ConstantInitialized{}) {}
  ~SampleParamDefaultTypeInternal() {}
  union {
    SampleParam _instance;
  };
};
PROTOBUF_ATTRIBUTE_NO_DESTROY PROTOBUF_CONSTINIT SampleParamDefaultTypeInternal _SampleParam_default_instance_;
}  // namespace midi
static ::PROTOBUF_NAMESPACE_ID::Metadata file_level_metadata_midi_2eproto[7];
static const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* file_level_enum_descriptors_midi_2eproto[3];
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::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, internal_instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, internal_track_type_),
  PROTOBUF_FIELD_OFFSET(::midi::Event, internal_duration_),
  0,
  1,
  2,
  3,
  4,
  5,
  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, ts_numerator_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, ts_denominator_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, internal_beat_length_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, internal_has_notes_),
  PROTOBUF_FIELD_OFFSET(::midi::Bar, internal_feature_),
  ~0u,
  2,
  3,
  1,
  0,
  ~0u,
  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, instrument_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, track_type_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, internal_train_types_),
  PROTOBUF_FIELD_OFFSET(::midi::Track, internal_features_),
  ~0u,
  0,
  1,
  ~0u,
  ~0u,
  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, internal_valid_segments_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, internal_valid_tracks_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, internal_segment_length_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, internal_valid_tracks_v2_),
  PROTOBUF_FIELD_OFFSET(::midi::Piece, internal_genre_data_),
  ~0u,
  ~0u,
  0,
  1,
  ~0u,
  ~0u,
  2,
  ~0u,
  ~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, selected_bars_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, autoregressive_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, ignore_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, density_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, min_polyphony_q_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, max_polyphony_q_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, min_note_duration_q_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, max_note_duration_q_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, internal_ts_numerators_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, internal_ts_denominators_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, internal_embeds_),
  PROTOBUF_FIELD_OFFSET(::midi::StatusTrack, internal_genre_),
  1,
  2,
  3,
  ~0u,
  5,
  6,
  4,
  7,
  8,
  9,
  10,
  ~0u,
  ~0u,
  ~0u,
  0,
  ~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::SampleParam, _has_bits_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, _internal_metadata_),
  ~0u,  // no _extensions_
  ~0u,  // no _oneof_case_
  ~0u,  // no _weak_field_map_
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, tracks_per_step_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, bars_per_step_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, model_dim_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, percentage_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, batch_size_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, temperature_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, max_steps_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, polyphony_hard_limit_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, shuffle_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, verbose_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, ckpt_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, internal_skip_preprocess_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, internal_random_sample_mode_),
  PROTOBUF_FIELD_OFFSET(::midi::SampleParam, internal_disable_masking_),
  1,
  2,
  3,
  4,
  6,
  5,
  11,
  12,
  7,
  8,
  0,
  9,
  10,
  13,
};
static const ::PROTOBUF_NAMESPACE_ID::internal::MigrationSchema schemas[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) = {
  { 0, 11, sizeof(::midi::Event)},
  { 17, 28, sizeof(::midi::Bar)},
  { 34, 44, sizeof(::midi::Track)},
  { 49, 63, sizeof(::midi::Piece)},
  { 72, 92, sizeof(::midi::StatusTrack)},
  { 107, -1, sizeof(::midi::Status)},
  { 113, 132, sizeof(::midi::SampleParam)},
};

static ::PROTOBUF_NAMESPACE_ID::Message const * const file_default_instances[] = {
  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::_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::_SampleParam_default_instance_),
};

const char descriptor_table_protodef_midi_2eproto[] PROTOBUF_SECTION_VARIABLE(protodesc_cold) =
  "\n\nmidi.proto\022\004midi\032\020track_type.proto\032\nen"
  "um.proto\032\023midi_internal.proto\"\253\001\n\005Event\022"
  "\030\n\004time\030\001 \001(\005B\n\220\265\030\000\210\265\030\300\204=\022\032\n\010velocity\030\002 "
  "\001(\005B\010\220\265\030\000\210\265\030\177\022\027\n\005pitch\030\003 \001(\005B\010\220\265\030\000\210\265\030\177\022\033"
  "\n\023internal_instrument\030\004 \001(\005\022\033\n\023internal_"
  "track_type\030\n \001(\005\022\031\n\021internal_duration\030\013 "
  "\001(\005\"\326\001\n\003Bar\022\034\n\006events\030\001 \003(\005B\014\220\265\030\000\210\265\030\377\377\377\377"
  "\007\022 \n\014ts_numerator\030\010 \001(\005B\n\220\265\030\001\210\265\030\300\204=\022\"\n\016t"
  "s_denominator\030\t \001(\005B\n\220\265\030\001\210\265\030\300\204=\022\034\n\024inter"
  "nal_beat_length\030\005 \001(\002\022\032\n\022internal_has_no"
  "tes\030\003 \001(\010\0221\n\020internal_feature\030\n \003(\0132\027.mi"
  "di.ContinuousFeature\"\304\001\n\005Track\022\027\n\004bars\030\001"
  " \003(\0132\t.midi.Bar\022\034\n\ninstrument\030\003 \001(\005B\010\220\265\030"
  "\000\210\265\030\177\022$\n\ntrack_type\030\005 \001(\0162\020.midi.TRACK_T"
  "YPE\022.\n\024internal_train_types\030\006 \003(\0162\020.midi"
  ".TRACK_TYPE\022.\n\021internal_features\030\007 \003(\0132\023"
  ".midi.TrackFeatures\"\275\002\n\005Piece\022\033\n\006tracks\030"
  "\001 \003(\0132\013.midi.Track\022\033\n\006events\030\002 \003(\0132\013.mid"
  "i.Event\022\034\n\nresolution\030\003 \001(\005B\010\220\265\030\001\210\265\030\014\022\031\n"
  "\005tempo\030\004 \001(\005B\n\220\265\030\001\210\265\030\300\204=\022\037\n\027internal_val"
  "id_segments\030\007 \003(\005\022\035\n\025internal_valid_trac"
  "ks\030\010 \003(\r\022\037\n\027internal_segment_length\030\014 \001("
  "\005\0222\n\030internal_valid_tracks_v2\030\r \003(\0132\020.mi"
  "di.ValidTrack\022,\n\023internal_genre_data\030\016 \003"
  "(\0132\017.midi.GenreData\"\256\004\n\013StatusTrack\022\034\n\010t"
  "rack_id\030\001 \001(\005B\n\220\265\030\000\210\265\030\300\204=\022$\n\ntrack_type\030"
  "\002 \001(\0162\020.midi.TRACK_TYPE\022!\n\ninstrument\030\003 "
  "\001(\0162\r.midi.GM_TYPE\022\025\n\rselected_bars\030\005 \003("
  "\010\022\026\n\016autoregressive\030\006 \001(\010\022\016\n\006ignore\030\007 \001("
  "\010\022#\n\007density\030\004 \001(\0162\022.midi.DensityLevel\022-"
  "\n\017min_polyphony_q\030\n \001(\0162\024.midi.Polyphony"
  "Level\022-\n\017max_polyphony_q\030\013 \001(\0162\024.midi.Po"
  "lyphonyLevel\0224\n\023min_note_duration_q\030\014 \001("
  "\0162\027.midi.NoteDurationLevel\0224\n\023max_note_d"
  "uration_q\030\r \001(\0162\027.midi.NoteDurationLevel"
  "\022\036\n\026internal_ts_numerators\030\016 \003(\005\022 \n\030inte"
  "rnal_ts_denominators\030\017 \003(\005\0220\n\017internal_e"
  "mbeds\030\010 \003(\0132\027.midi.ContinuousFeature\022\026\n\016"
  "internal_genre\030\t \001(\t\"+\n\006Status\022!\n\006tracks"
  "\030\001 \003(\0132\021.midi.StatusTrack\"\256\003\n\013SamplePara"
  "m\022!\n\017tracks_per_step\030\001 \001(\005B\010\220\265\030\001\210\265\030\014\022\037\n\r"
  "bars_per_step\030\002 \001(\005B\010\220\265\030\001\210\265\030\010\022\033\n\tmodel_d"
  "im\030\003 \001(\005B\010\220\265\030\001\210\265\030\010\022\034\n\npercentage\030\005 \001(\005B\010"
  "\220\265\030\001\210\265\030d\022\034\n\nbatch_size\030\007 \001(\005B\010\220\265\030\001\210\265\030\001\022#"
  "\n\013temperature\030\006 \001(\002B\016\245\265\030\000\000\000\?\235\265\030\000\000\000@\022\034\n\tm"
  "ax_steps\030\r \001(\005B\t\220\265\030\000\210\265\030\200\020\022&\n\024polyphony_h"
  "ard_limit\030\016 \001(\005B\010\220\265\030\000\210\265\030d\022\017\n\007shuffle\030\004 \001"
  "(\010\022\017\n\007verbose\030\010 \001(\010\022\014\n\004ckpt\030\t \001(\t\022 \n\030int"
  "ernal_skip_preprocess\030\014 \001(\010\022#\n\033internal_"
  "random_sample_mode\030\017 \001(\010\022 \n\030internal_dis"
  "able_masking\030\020 \001(\010*\231\001\n\016PolyphonyLevel\022\021\n"
  "\rPOLYPHONY_ANY\020\000\022\021\n\rPOLYPHONY_ONE\020\001\022\021\n\rP"
  "OLYPHONY_TWO\020\002\022\023\n\017POLYPHONY_THREE\020\003\022\022\n\016P"
  "OLYPHONY_FOUR\020\004\022\022\n\016POLYPHONY_FIVE\020\005\022\021\n\rP"
  "OLYPHONY_SIX\020\006*\253\001\n\021NoteDurationLevel\022\020\n\014"
  "DURATION_ANY\020\000\022\032\n\026DURATION_THIRTY_SECOND"
  "\020\001\022\026\n\022DURATION_SIXTEENTH\020\002\022\023\n\017DURATION_E"
  "IGHTH\020\003\022\024\n\020DURATION_QUARTER\020\004\022\021\n\rDURATIO"
  "N_HALF\020\005\022\022\n\016DURATION_WHOLE\020\006*\322\001\n\014Density"
  "Level\022\017\n\013DENSITY_ANY\020\000\022\017\n\013DENSITY_ONE\020\001\022"
  "\017\n\013DENSITY_TWO\020\002\022\021\n\rDENSITY_THREE\020\003\022\020\n\014D"
  "ENSITY_FOUR\020\004\022\020\n\014DENSITY_FIVE\020\005\022\017\n\013DENSI"
  "TY_SIX\020\006\022\021\n\rDENSITY_SEVEN\020\007\022\021\n\rDENSITY_E"
  "IGHT\020\010\022\020\n\014DENSITY_NINE\020\t\022\017\n\013DENSITY_TEN\020"
  "\n"
  ;
static const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable*const descriptor_table_midi_2eproto_deps[3] = {
  &::descriptor_table_enum_2eproto,
  &::descriptor_table_midi_5finternal_2eproto,
  &::descriptor_table_track_5ftype_2eproto,
};
static ::PROTOBUF_NAMESPACE_ID::internal::once_flag descriptor_table_midi_2eproto_once;
const ::PROTOBUF_NAMESPACE_ID::internal::DescriptorTable descriptor_table_midi_2eproto = {
  false, false, 2561, descriptor_table_protodef_midi_2eproto, "midi.proto", 
  &descriptor_table_midi_2eproto_once, descriptor_table_midi_2eproto_deps, 3, 7,
  schemas, file_default_instances, TableStruct_midi_2eproto::offsets,
  file_level_metadata_midi_2eproto, file_level_enum_descriptors_midi_2eproto, file_level_service_descriptors_midi_2eproto,
};
PROTOBUF_ATTRIBUTE_WEAK ::PROTOBUF_NAMESPACE_ID::Metadata
descriptor_table_midi_2eproto_metadata_getter(int index) {
  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_midi_2eproto);
  return descriptor_table_midi_2eproto.file_level_metadata[index];
}

// Force running AddDescriptors() at dynamic initialization time.
PROTOBUF_ATTRIBUTE_INIT_PRIORITY static ::PROTOBUF_NAMESPACE_ID::internal::AddDescriptorsRunner dynamic_init_dummy_midi_2eproto(&descriptor_table_midi_2eproto);
namespace midi {
const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* PolyphonyLevel_descriptor() {
  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_midi_2eproto);
  return file_level_enum_descriptors_midi_2eproto[0];
}
bool PolyphonyLevel_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      return true;
    default:
      return false;
  }
}

const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* NoteDurationLevel_descriptor() {
  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_midi_2eproto);
  return file_level_enum_descriptors_midi_2eproto[1];
}
bool NoteDurationLevel_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
      return true;
    default:
      return false;
  }
}

const ::PROTOBUF_NAMESPACE_ID::EnumDescriptor* DensityLevel_descriptor() {
  ::PROTOBUF_NAMESPACE_ID::internal::AssignDescriptors(&descriptor_table_midi_2eproto);
  return file_level_enum_descriptors_midi_2eproto[2];
}
bool DensityLevel_IsValid(int value) {
  switch (value) {
    case 0:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    case 6:
    case 7:
    case 8:
    case 9:
    case 10:
      return true;
    default:
      return false;
  }
}


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

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_internal_instrument(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_internal_track_type(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_internal_duration(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
};

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*>(&internal_duration_) -
    reinterpret_cast<char*>(&time_)) + sizeof(internal_duration_));
  // @@protoc_insertion_point(copy_constructor:midi.Event)
}

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

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);
}

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 & 0x0000003fu) {
    ::memset(&time_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&internal_duration_) -
        reinterpret_cast<char*>(&time_)) + sizeof(internal_duration_));
  }
  _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{};
  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 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
      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 [(.midi.maxval) = 127, (.midi.minval) = 0];
      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 [(.midi.maxval) = 127, (.midi.minval) = 0];
      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 internal_instrument = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_internal_instrument(&has_bits);
          internal_instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 internal_track_type = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
          _Internal::set_has_internal_track_type(&has_bits);
          internal_track_type_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 internal_duration = 11;
      case 11:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 88)) {
          _Internal::set_has_internal_duration(&has_bits);
          internal_duration_ = ::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 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
  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 [(.midi.maxval) = 127, (.midi.minval) = 0];
  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 [(.midi.maxval) = 127, (.midi.minval) = 0];
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_pitch(), target);
  }

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

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

  // optional int32 internal_duration = 11;
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(11, this->_internal_internal_duration(), 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 & 0x0000003fu) {
    // optional int32 time = 1 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_time());
    }

    // optional int32 velocity = 2 [(.midi.maxval) = 127, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_velocity());
    }

    // optional int32 pitch = 3 [(.midi.maxval) = 127, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_pitch());
    }

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

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

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

  }
  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 & 0x0000003fu) {
    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) {
      internal_instrument_ = from.internal_instrument_;
    }
    if (cached_has_bits & 0x00000010u) {
      internal_track_type_ = from.internal_track_type_;
    }
    if (cached_has_bits & 0x00000020u) {
      internal_duration_ = from.internal_duration_;
    }
    _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, internal_duration_)
      + sizeof(Event::internal_duration_)
      - PROTOBUF_FIELD_OFFSET(Event, time_)>(
          reinterpret_cast<char*>(&time_),
          reinterpret_cast<char*>(&other->time_));
}

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


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

class Bar::_Internal {
 public:
  using HasBits = decltype(std::declval<Bar>()._has_bits_);
  static void set_has_ts_numerator(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_ts_denominator(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_internal_beat_length(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_internal_has_notes(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
};

void Bar::clear_internal_feature() {
  internal_feature_.Clear();
}
Bar::Bar(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  events_(arena),
  internal_feature_(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_feature_(from.internal_feature_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&internal_has_notes_, &from.internal_has_notes_,
    static_cast<size_t>(reinterpret_cast<char*>(&ts_denominator_) -
    reinterpret_cast<char*>(&internal_has_notes_)) + sizeof(ts_denominator_));
  // @@protoc_insertion_point(copy_constructor:midi.Bar)
}

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

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);
}

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();
  internal_feature_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    ::memset(&internal_has_notes_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&ts_denominator_) -
        reinterpret_cast<char*>(&internal_has_notes_)) + sizeof(ts_denominator_));
  }
  _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{};
  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 [(.midi.maxval) = 2147483647, (.midi.minval) = 0];
      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 internal_has_notes = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_internal_has_notes(&has_bits);
          internal_has_notes_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional float internal_beat_length = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 45)) {
          _Internal::set_has_internal_beat_length(&has_bits);
          internal_beat_length_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else goto handle_unusual;
        continue;
      // optional int32 ts_numerator = 8 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          _Internal::set_has_ts_numerator(&has_bits);
          ts_numerator_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 ts_denominator = 9 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 72)) {
          _Internal::set_has_ts_denominator(&has_bits);
          ts_denominator_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated .midi.ContinuousFeature internal_feature = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 82)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_internal_feature(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<82>(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 [(.midi.maxval) = 2147483647, (.midi.minval) = 0];
  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 internal_has_notes = 3;
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(3, this->_internal_internal_has_notes(), target);
  }

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

  // optional int32 ts_numerator = 8 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(8, this->_internal_ts_numerator(), target);
  }

  // optional int32 ts_denominator = 9 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(9, this->_internal_ts_denominator(), target);
  }

  // repeated .midi.ContinuousFeature internal_feature = 10;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_internal_feature_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(10, this->_internal_internal_feature(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.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 [(.midi.maxval) = 2147483647, (.midi.minval) = 0];
  {
    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;
  }

  // repeated .midi.ContinuousFeature internal_feature = 10;
  total_size += 1UL * this->_internal_internal_feature_size();
  for (const auto& msg : this->internal_feature_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    // optional bool internal_has_notes = 3;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 + 1;
    }

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

    // optional int32 ts_numerator = 8 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_ts_numerator());
    }

    // optional int32 ts_denominator = 9 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_ts_denominator());
    }

  }
  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_);
  internal_feature_.MergeFrom(from.internal_feature_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x0000000fu) {
    if (cached_has_bits & 0x00000001u) {
      internal_has_notes_ = from.internal_has_notes_;
    }
    if (cached_has_bits & 0x00000002u) {
      internal_beat_length_ = from.internal_beat_length_;
    }
    if (cached_has_bits & 0x00000004u) {
      ts_numerator_ = from.ts_numerator_;
    }
    if (cached_has_bits & 0x00000008u) {
      ts_denominator_ = from.ts_denominator_;
    }
    _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_);
  internal_feature_.InternalSwap(&other->internal_feature_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Bar, ts_denominator_)
      + sizeof(Bar::ts_denominator_)
      - PROTOBUF_FIELD_OFFSET(Bar, internal_has_notes_)>(
          reinterpret_cast<char*>(&internal_has_notes_),
          reinterpret_cast<char*>(&other->internal_has_notes_));
}

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


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

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

void Track::clear_internal_features() {
  internal_features_.Clear();
}
Track::Track(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  bars_(arena),
  internal_train_types_(arena),
  internal_features_(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_train_types_(from.internal_train_types_),
      internal_features_(from.internal_features_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&instrument_, &from.instrument_,
    static_cast<size_t>(reinterpret_cast<char*>(&track_type_) -
    reinterpret_cast<char*>(&instrument_)) + sizeof(track_type_));
  // @@protoc_insertion_point(copy_constructor:midi.Track)
}

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

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);
}

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();
  internal_train_types_.Clear();
  internal_features_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    ::memset(&instrument_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&track_type_) -
        reinterpret_cast<char*>(&instrument_)) + sizeof(track_type_));
  }
  _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{};
  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 int32 instrument = 3 [(.midi.maxval) = 127, (.midi.minval) = 0];
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_instrument(&has_bits);
          instrument_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional .midi.TRACK_TYPE track_type = 5;
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::TRACK_TYPE_IsValid(val))) {
            _internal_set_track_type(static_cast<::midi::TRACK_TYPE>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(5, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // repeated .midi.TRACK_TYPE internal_train_types = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          ptr -= 1;
          do {
            ptr += 1;
            ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
            CHK_(ptr);
            if (PROTOBUF_PREDICT_TRUE(::midi::TRACK_TYPE_IsValid(val))) {
              _internal_add_internal_train_types(static_cast<::midi::TRACK_TYPE>(val));
            } else {
              ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(6, val, mutable_unknown_fields());
            }
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<48>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 50) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedEnumParser<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(_internal_mutable_internal_train_types(), ptr, ctx, ::midi::TRACK_TYPE_IsValid, &_internal_metadata_, 6);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated .midi.TrackFeatures internal_features = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 58)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_internal_features(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<58>(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 int32 instrument = 3 [(.midi.maxval) = 127, (.midi.minval) = 0];
  if (cached_has_bits & 0x00000001u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_instrument(), target);
  }

  // optional .midi.TRACK_TYPE track_type = 5;
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      5, this->_internal_track_type(), target);
  }

  // repeated .midi.TRACK_TYPE internal_train_types = 6;
  for (int i = 0, n = this->_internal_internal_train_types_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
        6, this->_internal_internal_train_types(i), target);
  }

  // repeated .midi.TrackFeatures internal_features = 7;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_internal_features_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(7, this->_internal_internal_features(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.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);
  }

  // repeated .midi.TRACK_TYPE internal_train_types = 6;
  {
    size_t data_size = 0;
    unsigned int count = static_cast<unsigned int>(this->_internal_internal_train_types_size());for (unsigned int i = 0; i < count; i++) {
      data_size += ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(
        this->_internal_internal_train_types(static_cast<int>(i)));
    }
    total_size += (1UL * count) + data_size;
  }

  // repeated .midi.TrackFeatures internal_features = 7;
  total_size += 1UL * this->_internal_internal_features_size();
  for (const auto& msg : this->internal_features_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    // optional int32 instrument = 3 [(.midi.maxval) = 127, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_instrument());
    }

    // optional .midi.TRACK_TYPE track_type = 5;
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(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 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_);
  internal_train_types_.MergeFrom(from.internal_train_types_);
  internal_features_.MergeFrom(from.internal_features_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000003u) {
    if (cached_has_bits & 0x00000001u) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000002u) {
      track_type_ = from.track_type_;
    }
    _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_);
  internal_train_types_.InternalSwap(&other->internal_train_types_);
  internal_features_.InternalSwap(&other->internal_features_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Track, track_type_)
      + sizeof(Track::track_type_)
      - PROTOBUF_FIELD_OFFSET(Track, instrument_)>(
          reinterpret_cast<char*>(&instrument_),
          reinterpret_cast<char*>(&other->instrument_));
}

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


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

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_internal_segment_length(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
};

void Piece::clear_internal_valid_tracks_v2() {
  internal_valid_tracks_v2_.Clear();
}
void Piece::clear_internal_genre_data() {
  internal_genre_data_.Clear();
}
Piece::Piece(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  tracks_(arena),
  events_(arena),
  internal_valid_segments_(arena),
  internal_valid_tracks_(arena),
  internal_valid_tracks_v2_(arena),
  internal_genre_data_(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_),
      internal_valid_segments_(from.internal_valid_segments_),
      internal_valid_tracks_(from.internal_valid_tracks_),
      internal_valid_tracks_v2_(from.internal_valid_tracks_v2_),
      internal_genre_data_(from.internal_genre_data_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ::memcpy(&resolution_, &from.resolution_,
    static_cast<size_t>(reinterpret_cast<char*>(&internal_segment_length_) -
    reinterpret_cast<char*>(&resolution_)) + sizeof(internal_segment_length_));
  // @@protoc_insertion_point(copy_constructor:midi.Piece)
}

void Piece::SharedCtor() {
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&resolution_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&internal_segment_length_) -
    reinterpret_cast<char*>(&resolution_)) + sizeof(internal_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);
}

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();
  internal_valid_segments_.Clear();
  internal_valid_tracks_.Clear();
  internal_valid_tracks_v2_.Clear();
  internal_genre_data_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    ::memset(&resolution_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&internal_segment_length_) -
        reinterpret_cast<char*>(&resolution_)) + sizeof(internal_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{};
  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 [(.midi.maxval) = 12, (.midi.minval) = 1];
      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 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
      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;
      // repeated int32 internal_valid_segments = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_internal_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_internal_valid_segments(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated uint32 internal_valid_tracks = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_internal_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_internal_valid_tracks(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 internal_segment_length = 12;
      case 12:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) {
          _Internal::set_has_internal_segment_length(&has_bits);
          internal_segment_length_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated .midi.ValidTrack internal_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_internal_valid_tracks_v2(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<106>(ptr));
        } else goto handle_unusual;
        continue;
      // repeated .midi.GenreData internal_genre_data = 14;
      case 14:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 114)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_internal_genre_data(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<114>(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 [(.midi.maxval) = 12, (.midi.minval) = 1];
  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 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(4, this->_internal_tempo(), target);
  }

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

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

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

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

  // repeated .midi.GenreData internal_genre_data = 14;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_internal_genre_data_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(14, this->_internal_internal_genre_data(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 internal_valid_segments = 7;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->internal_valid_segments_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_internal_valid_segments_size());
    total_size += data_size;
  }

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

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

  // repeated .midi.GenreData internal_genre_data = 14;
  total_size += 1UL * this->_internal_internal_genre_data_size();
  for (const auto& msg : this->internal_genre_data_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    // optional int32 resolution = 3 [(.midi.maxval) = 12, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_resolution());
    }

    // optional int32 tempo = 4 [(.midi.maxval) = 1000000, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_tempo());
    }

    // optional int32 internal_segment_length = 12;
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_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_);
  internal_valid_segments_.MergeFrom(from.internal_valid_segments_);
  internal_valid_tracks_.MergeFrom(from.internal_valid_tracks_);
  internal_valid_tracks_v2_.MergeFrom(from.internal_valid_tracks_v2_);
  internal_genre_data_.MergeFrom(from.internal_genre_data_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x00000007u) {
    if (cached_has_bits & 0x00000001u) {
      resolution_ = from.resolution_;
    }
    if (cached_has_bits & 0x00000002u) {
      tempo_ = from.tempo_;
    }
    if (cached_has_bits & 0x00000004u) {
      internal_segment_length_ = from.internal_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_);
  internal_valid_segments_.InternalSwap(&other->internal_valid_segments_);
  internal_valid_tracks_.InternalSwap(&other->internal_valid_tracks_);
  internal_valid_tracks_v2_.InternalSwap(&other->internal_valid_tracks_v2_);
  internal_genre_data_.InternalSwap(&other->internal_genre_data_);
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(Piece, internal_segment_length_)
      + sizeof(Piece::internal_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();
}


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

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] |= 8u;
  }
  static void set_has_autoregressive(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_ignore(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_density(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_min_polyphony_q(HasBits* has_bits) {
    (*has_bits)[0] |= 128u;
  }
  static void set_has_max_polyphony_q(HasBits* has_bits) {
    (*has_bits)[0] |= 256u;
  }
  static void set_has_min_note_duration_q(HasBits* has_bits) {
    (*has_bits)[0] |= 512u;
  }
  static void set_has_max_note_duration_q(HasBits* has_bits) {
    (*has_bits)[0] |= 1024u;
  }
  static void set_has_internal_genre(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
};

void StatusTrack::clear_internal_embeds() {
  internal_embeds_.Clear();
}
StatusTrack::StatusTrack(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena),
  selected_bars_(arena),
  internal_embeds_(arena),
  internal_ts_numerators_(arena),
  internal_ts_denominators_(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_embeds_(from.internal_embeds_),
      internal_ts_numerators_(from.internal_ts_numerators_),
      internal_ts_denominators_(from.internal_ts_denominators_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  internal_genre_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  if (from._internal_has_internal_genre()) {
    internal_genre_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_internal_genre(), 
      GetArena());
  }
  ::memcpy(&track_id_, &from.track_id_,
    static_cast<size_t>(reinterpret_cast<char*>(&max_note_duration_q_) -
    reinterpret_cast<char*>(&track_id_)) + sizeof(max_note_duration_q_));
  // @@protoc_insertion_point(copy_constructor:midi.StatusTrack)
}

void StatusTrack::SharedCtor() {
internal_genre_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&track_id_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&max_note_duration_q_) -
    reinterpret_cast<char*>(&track_id_)) + sizeof(max_note_duration_q_));
}

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

void StatusTrack::SharedDtor() {
  GOOGLE_DCHECK(GetArena() == nullptr);
  internal_genre_.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);
}

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();
  internal_embeds_.Clear();
  internal_ts_numerators_.Clear();
  internal_ts_denominators_.Clear();
  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x00000001u) {
    internal_genre_.ClearNonDefaultToEmpty();
  }
  if (cached_has_bits & 0x000000feu) {
    ::memset(&track_id_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&min_polyphony_q_) -
        reinterpret_cast<char*>(&track_id_)) + sizeof(min_polyphony_q_));
  }
  if (cached_has_bits & 0x00000700u) {
    ::memset(&max_polyphony_q_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&max_note_duration_q_) -
        reinterpret_cast<char*>(&max_polyphony_q_)) + sizeof(max_note_duration_q_));
  }
  _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{};
  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 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
      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 .midi.TRACK_TYPE track_type = 2;
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::TRACK_TYPE_IsValid(val))) {
            _internal_set_track_type(static_cast<::midi::TRACK_TYPE>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(2, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // optional .midi.GM_TYPE instrument = 3;
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::GM_TYPE_IsValid(val))) {
            _internal_set_instrument(static_cast<::midi::GM_TYPE>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(3, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // optional .midi.DensityLevel density = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::DensityLevel_IsValid(val))) {
            _internal_set_density(static_cast<::midi::DensityLevel>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(4, val, mutable_unknown_fields());
          }
        } 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;
      // optional bool autoregressive = 6;
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 48)) {
          _Internal::set_has_autoregressive(&has_bits);
          autoregressive_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool ignore = 7;
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_ignore(&has_bits);
          ignore_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated .midi.ContinuousFeature internal_embeds = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 66)) {
          ptr -= 1;
          do {
            ptr += 1;
            ptr = ctx->ParseMessage(_internal_add_internal_embeds(), ptr);
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<66>(ptr));
        } else goto handle_unusual;
        continue;
      // optional string internal_genre = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) {
          auto str = _internal_mutable_internal_genre();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          #ifndef NDEBUG
          ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.StatusTrack.internal_genre");
          #endif  // !NDEBUG
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional .midi.PolyphonyLevel min_polyphony_q = 10;
      case 10:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 80)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::PolyphonyLevel_IsValid(val))) {
            _internal_set_min_polyphony_q(static_cast<::midi::PolyphonyLevel>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(10, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // optional .midi.PolyphonyLevel max_polyphony_q = 11;
      case 11:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 88)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::PolyphonyLevel_IsValid(val))) {
            _internal_set_max_polyphony_q(static_cast<::midi::PolyphonyLevel>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(11, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // optional .midi.NoteDurationLevel min_note_duration_q = 12;
      case 12:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::NoteDurationLevel_IsValid(val))) {
            _internal_set_min_note_duration_q(static_cast<::midi::NoteDurationLevel>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(12, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // optional .midi.NoteDurationLevel max_note_duration_q = 13;
      case 13:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) {
          ::PROTOBUF_NAMESPACE_ID::uint64 val = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
          if (PROTOBUF_PREDICT_TRUE(::midi::NoteDurationLevel_IsValid(val))) {
            _internal_set_max_note_duration_q(static_cast<::midi::NoteDurationLevel>(val));
          } else {
            ::PROTOBUF_NAMESPACE_ID::internal::WriteVarint(13, val, mutable_unknown_fields());
          }
        } else goto handle_unusual;
        continue;
      // repeated int32 internal_ts_numerators = 14;
      case 14:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 112)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_internal_ts_numerators(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<112>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 114) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_internal_ts_numerators(), ptr, ctx);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // repeated int32 internal_ts_denominators = 15;
      case 15:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 120)) {
          ptr -= 1;
          do {
            ptr += 1;
            _internal_add_internal_ts_denominators(::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr));
            CHK_(ptr);
            if (!ctx->DataAvailable(ptr)) break;
          } while (::PROTOBUF_NAMESPACE_ID::internal::ExpectTag<120>(ptr));
        } else if (static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 122) {
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::PackedInt32Parser(_internal_mutable_internal_ts_denominators(), 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 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_track_id(), target);
  }

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

  // optional .midi.GM_TYPE instrument = 3;
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      3, this->_internal_instrument(), target);
  }

  // optional .midi.DensityLevel density = 4;
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      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);
  }

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

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

  // repeated .midi.ContinuousFeature internal_embeds = 8;
  for (unsigned int i = 0,
      n = static_cast<unsigned int>(this->_internal_internal_embeds_size()); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      InternalWriteMessage(8, this->_internal_internal_embeds(i), target, stream);
  }

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

  // optional .midi.PolyphonyLevel min_polyphony_q = 10;
  if (cached_has_bits & 0x00000080u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      10, this->_internal_min_polyphony_q(), target);
  }

  // optional .midi.PolyphonyLevel max_polyphony_q = 11;
  if (cached_has_bits & 0x00000100u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      11, this->_internal_max_polyphony_q(), target);
  }

  // optional .midi.NoteDurationLevel min_note_duration_q = 12;
  if (cached_has_bits & 0x00000200u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      12, this->_internal_min_note_duration_q(), target);
  }

  // optional .midi.NoteDurationLevel max_note_duration_q = 13;
  if (cached_has_bits & 0x00000400u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteEnumToArray(
      13, this->_internal_max_note_duration_q(), target);
  }

  // repeated int32 internal_ts_numerators = 14;
  for (int i = 0, n = this->_internal_internal_ts_numerators_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(14, this->_internal_internal_ts_numerators(i), target);
  }

  // repeated int32 internal_ts_denominators = 15;
  for (int i = 0, n = this->_internal_internal_ts_denominators_size(); i < n; i++) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(15, this->_internal_internal_ts_denominators(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;
  }

  // repeated .midi.ContinuousFeature internal_embeds = 8;
  total_size += 1UL * this->_internal_internal_embeds_size();
  for (const auto& msg : this->internal_embeds_) {
    total_size +=
      ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::MessageSize(msg);
  }

  // repeated int32 internal_ts_numerators = 14;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->internal_ts_numerators_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_internal_ts_numerators_size());
    total_size += data_size;
  }

  // repeated int32 internal_ts_denominators = 15;
  {
    size_t data_size = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::
      Int32Size(this->internal_ts_denominators_);
    total_size += 1 *
                  ::PROTOBUF_NAMESPACE_ID::internal::FromIntSize(this->_internal_internal_ts_denominators_size());
    total_size += data_size;
  }

  cached_has_bits = _has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    // optional string internal_genre = 9;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
          this->_internal_internal_genre());
    }

    // optional int32 track_id = 1 [(.midi.maxval) = 1000000, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_track_id());
    }

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

    // optional .midi.GM_TYPE instrument = 3;
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_instrument());
    }

    // optional .midi.DensityLevel density = 4;
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_density());
    }

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

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

    // optional .midi.PolyphonyLevel min_polyphony_q = 10;
    if (cached_has_bits & 0x00000080u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_min_polyphony_q());
    }

  }
  if (cached_has_bits & 0x00000700u) {
    // optional .midi.PolyphonyLevel max_polyphony_q = 11;
    if (cached_has_bits & 0x00000100u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_max_polyphony_q());
    }

    // optional .midi.NoteDurationLevel min_note_duration_q = 12;
    if (cached_has_bits & 0x00000200u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_min_note_duration_q());
    }

    // optional .midi.NoteDurationLevel max_note_duration_q = 13;
    if (cached_has_bits & 0x00000400u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::EnumSize(this->_internal_max_note_duration_q());
    }

  }
  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_);
  internal_embeds_.MergeFrom(from.internal_embeds_);
  internal_ts_numerators_.MergeFrom(from.internal_ts_numerators_);
  internal_ts_denominators_.MergeFrom(from.internal_ts_denominators_);
  cached_has_bits = from._has_bits_[0];
  if (cached_has_bits & 0x000000ffu) {
    if (cached_has_bits & 0x00000001u) {
      _internal_set_internal_genre(from._internal_internal_genre());
    }
    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) {
      instrument_ = from.instrument_;
    }
    if (cached_has_bits & 0x00000010u) {
      density_ = from.density_;
    }
    if (cached_has_bits & 0x00000020u) {
      autoregressive_ = from.autoregressive_;
    }
    if (cached_has_bits & 0x00000040u) {
      ignore_ = from.ignore_;
    }
    if (cached_has_bits & 0x00000080u) {
      min_polyphony_q_ = from.min_polyphony_q_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  if (cached_has_bits & 0x00000700u) {
    if (cached_has_bits & 0x00000100u) {
      max_polyphony_q_ = from.max_polyphony_q_;
    }
    if (cached_has_bits & 0x00000200u) {
      min_note_duration_q_ = from.min_note_duration_q_;
    }
    if (cached_has_bits & 0x00000400u) {
      max_note_duration_q_ = from.max_note_duration_q_;
    }
    _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_);
  internal_embeds_.InternalSwap(&other->internal_embeds_);
  internal_ts_numerators_.InternalSwap(&other->internal_ts_numerators_);
  internal_ts_denominators_.InternalSwap(&other->internal_ts_denominators_);
  internal_genre_.Swap(&other->internal_genre_, &::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited(), GetArena());
  ::PROTOBUF_NAMESPACE_ID::internal::memswap<
      PROTOBUF_FIELD_OFFSET(StatusTrack, max_note_duration_q_)
      + sizeof(StatusTrack::max_note_duration_q_)
      - 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();
}


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

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() {
}

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);
}

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
  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();
}


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

class SampleParam::_Internal {
 public:
  using HasBits = decltype(std::declval<SampleParam>()._has_bits_);
  static void set_has_tracks_per_step(HasBits* has_bits) {
    (*has_bits)[0] |= 2u;
  }
  static void set_has_bars_per_step(HasBits* has_bits) {
    (*has_bits)[0] |= 4u;
  }
  static void set_has_model_dim(HasBits* has_bits) {
    (*has_bits)[0] |= 8u;
  }
  static void set_has_percentage(HasBits* has_bits) {
    (*has_bits)[0] |= 16u;
  }
  static void set_has_batch_size(HasBits* has_bits) {
    (*has_bits)[0] |= 64u;
  }
  static void set_has_temperature(HasBits* has_bits) {
    (*has_bits)[0] |= 32u;
  }
  static void set_has_max_steps(HasBits* has_bits) {
    (*has_bits)[0] |= 2048u;
  }
  static void set_has_polyphony_hard_limit(HasBits* has_bits) {
    (*has_bits)[0] |= 4096u;
  }
  static void set_has_shuffle(HasBits* has_bits) {
    (*has_bits)[0] |= 128u;
  }
  static void set_has_verbose(HasBits* has_bits) {
    (*has_bits)[0] |= 256u;
  }
  static void set_has_ckpt(HasBits* has_bits) {
    (*has_bits)[0] |= 1u;
  }
  static void set_has_internal_skip_preprocess(HasBits* has_bits) {
    (*has_bits)[0] |= 512u;
  }
  static void set_has_internal_random_sample_mode(HasBits* has_bits) {
    (*has_bits)[0] |= 1024u;
  }
  static void set_has_internal_disable_masking(HasBits* has_bits) {
    (*has_bits)[0] |= 8192u;
  }
};

SampleParam::SampleParam(::PROTOBUF_NAMESPACE_ID::Arena* arena)
  : ::PROTOBUF_NAMESPACE_ID::Message(arena) {
  SharedCtor();
  RegisterArenaDtor(arena);
  // @@protoc_insertion_point(arena_constructor:midi.SampleParam)
}
SampleParam::SampleParam(const SampleParam& from)
  : ::PROTOBUF_NAMESPACE_ID::Message(),
      _has_bits_(from._has_bits_) {
  _internal_metadata_.MergeFrom<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>(from._internal_metadata_);
  ckpt_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
  if (from._internal_has_ckpt()) {
    ckpt_.Set(::PROTOBUF_NAMESPACE_ID::internal::ArenaStringPtr::EmptyDefault{}, from._internal_ckpt(), 
      GetArena());
  }
  ::memcpy(&tracks_per_step_, &from.tracks_per_step_,
    static_cast<size_t>(reinterpret_cast<char*>(&internal_disable_masking_) -
    reinterpret_cast<char*>(&tracks_per_step_)) + sizeof(internal_disable_masking_));
  // @@protoc_insertion_point(copy_constructor:midi.SampleParam)
}

void SampleParam::SharedCtor() {
ckpt_.UnsafeSetDefault(&::PROTOBUF_NAMESPACE_ID::internal::GetEmptyStringAlreadyInited());
::memset(reinterpret_cast<char*>(this) + static_cast<size_t>(
    reinterpret_cast<char*>(&tracks_per_step_) - reinterpret_cast<char*>(this)),
    0, static_cast<size_t>(reinterpret_cast<char*>(&internal_disable_masking_) -
    reinterpret_cast<char*>(&tracks_per_step_)) + sizeof(internal_disable_masking_));
}

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

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

void SampleParam::ArenaDtor(void* object) {
  SampleParam* _this = reinterpret_cast< SampleParam* >(object);
  (void)_this;
}
void SampleParam::RegisterArenaDtor(::PROTOBUF_NAMESPACE_ID::Arena*) {
}
void SampleParam::SetCachedSize(int size) const {
  _cached_size_.Set(size);
}

void SampleParam::Clear() {
// @@protoc_insertion_point(message_clear_start:midi.SampleParam)
  ::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 & 0x00000001u) {
    ckpt_.ClearNonDefaultToEmpty();
  }
  if (cached_has_bits & 0x000000feu) {
    ::memset(&tracks_per_step_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&shuffle_) -
        reinterpret_cast<char*>(&tracks_per_step_)) + sizeof(shuffle_));
  }
  if (cached_has_bits & 0x00003f00u) {
    ::memset(&verbose_, 0, static_cast<size_t>(
        reinterpret_cast<char*>(&internal_disable_masking_) -
        reinterpret_cast<char*>(&verbose_)) + sizeof(internal_disable_masking_));
  }
  _has_bits_.Clear();
  _internal_metadata_.Clear<::PROTOBUF_NAMESPACE_ID::UnknownFieldSet>();
}

const char* SampleParam::_InternalParse(const char* ptr, ::PROTOBUF_NAMESPACE_ID::internal::ParseContext* ctx) {
#define CHK_(x) if (PROTOBUF_PREDICT_FALSE(!(x))) goto failure
  _Internal::HasBits has_bits{};
  while (!ctx->Done(&ptr)) {
    ::PROTOBUF_NAMESPACE_ID::uint32 tag;
    ptr = ::PROTOBUF_NAMESPACE_ID::internal::ReadTag(ptr, &tag);
    CHK_(ptr);
    switch (tag >> 3) {
      // optional int32 tracks_per_step = 1 [(.midi.maxval) = 12, (.midi.minval) = 1];
      case 1:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 8)) {
          _Internal::set_has_tracks_per_step(&has_bits);
          tracks_per_step_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 bars_per_step = 2 [(.midi.maxval) = 8, (.midi.minval) = 1];
      case 2:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 16)) {
          _Internal::set_has_bars_per_step(&has_bits);
          bars_per_step_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 model_dim = 3 [(.midi.maxval) = 8, (.midi.minval) = 1];
      case 3:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 24)) {
          _Internal::set_has_model_dim(&has_bits);
          model_dim_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool shuffle = 4;
      case 4:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 32)) {
          _Internal::set_has_shuffle(&has_bits);
          shuffle_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 percentage = 5 [(.midi.maxval) = 100, (.midi.minval) = 1];
      case 5:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 40)) {
          _Internal::set_has_percentage(&has_bits);
          percentage_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional float temperature = 6 [(.midi.fmaxval) = 2, (.midi.fminval) = 0.5];
      case 6:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 53)) {
          _Internal::set_has_temperature(&has_bits);
          temperature_ = ::PROTOBUF_NAMESPACE_ID::internal::UnalignedLoad<float>(ptr);
          ptr += sizeof(float);
        } else goto handle_unusual;
        continue;
      // optional int32 batch_size = 7 [(.midi.maxval) = 1, (.midi.minval) = 1];
      case 7:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 56)) {
          _Internal::set_has_batch_size(&has_bits);
          batch_size_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool verbose = 8;
      case 8:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 64)) {
          _Internal::set_has_verbose(&has_bits);
          verbose_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional string ckpt = 9;
      case 9:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 74)) {
          auto str = _internal_mutable_ckpt();
          ptr = ::PROTOBUF_NAMESPACE_ID::internal::InlineGreedyStringParser(str, ptr, ctx);
          #ifndef NDEBUG
          ::PROTOBUF_NAMESPACE_ID::internal::VerifyUTF8(str, "midi.SampleParam.ckpt");
          #endif  // !NDEBUG
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool internal_skip_preprocess = 12;
      case 12:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 96)) {
          _Internal::set_has_internal_skip_preprocess(&has_bits);
          internal_skip_preprocess_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 max_steps = 13 [(.midi.maxval) = 2048, (.midi.minval) = 0];
      case 13:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 104)) {
          _Internal::set_has_max_steps(&has_bits);
          max_steps_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional int32 polyphony_hard_limit = 14 [(.midi.maxval) = 100, (.midi.minval) = 0];
      case 14:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 112)) {
          _Internal::set_has_polyphony_hard_limit(&has_bits);
          polyphony_hard_limit_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool internal_random_sample_mode = 15;
      case 15:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 120)) {
          _Internal::set_has_internal_random_sample_mode(&has_bits);
          internal_random_sample_mode_ = ::PROTOBUF_NAMESPACE_ID::internal::ReadVarint64(&ptr);
          CHK_(ptr);
        } else goto handle_unusual;
        continue;
      // optional bool internal_disable_masking = 16;
      case 16:
        if (PROTOBUF_PREDICT_TRUE(static_cast<::PROTOBUF_NAMESPACE_ID::uint8>(tag) == 128)) {
          _Internal::set_has_internal_disable_masking(&has_bits);
          internal_disable_masking_ = ::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* SampleParam::_InternalSerialize(
    ::PROTOBUF_NAMESPACE_ID::uint8* target, ::PROTOBUF_NAMESPACE_ID::io::EpsCopyOutputStream* stream) const {
  // @@protoc_insertion_point(serialize_to_array_start:midi.SampleParam)
  ::PROTOBUF_NAMESPACE_ID::uint32 cached_has_bits = 0;
  (void) cached_has_bits;

  cached_has_bits = _has_bits_[0];
  // optional int32 tracks_per_step = 1 [(.midi.maxval) = 12, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000002u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(1, this->_internal_tracks_per_step(), target);
  }

  // optional int32 bars_per_step = 2 [(.midi.maxval) = 8, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000004u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(2, this->_internal_bars_per_step(), target);
  }

  // optional int32 model_dim = 3 [(.midi.maxval) = 8, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000008u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(3, this->_internal_model_dim(), target);
  }

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

  // optional int32 percentage = 5 [(.midi.maxval) = 100, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000010u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(5, this->_internal_percentage(), target);
  }

  // optional float temperature = 6 [(.midi.fmaxval) = 2, (.midi.fminval) = 0.5];
  if (cached_has_bits & 0x00000020u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteFloatToArray(6, this->_internal_temperature(), target);
  }

  // optional int32 batch_size = 7 [(.midi.maxval) = 1, (.midi.minval) = 1];
  if (cached_has_bits & 0x00000040u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(7, this->_internal_batch_size(), target);
  }

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

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

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

  // optional int32 max_steps = 13 [(.midi.maxval) = 2048, (.midi.minval) = 0];
  if (cached_has_bits & 0x00000800u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(13, this->_internal_max_steps(), target);
  }

  // optional int32 polyphony_hard_limit = 14 [(.midi.maxval) = 100, (.midi.minval) = 0];
  if (cached_has_bits & 0x00001000u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteInt32ToArray(14, this->_internal_polyphony_hard_limit(), target);
  }

  // optional bool internal_random_sample_mode = 15;
  if (cached_has_bits & 0x00000400u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(15, this->_internal_internal_random_sample_mode(), target);
  }

  // optional bool internal_disable_masking = 16;
  if (cached_has_bits & 0x00002000u) {
    target = stream->EnsureSpace(target);
    target = ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::WriteBoolToArray(16, this->_internal_internal_disable_masking(), 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.SampleParam)
  return target;
}

size_t SampleParam::ByteSizeLong() const {
// @@protoc_insertion_point(message_byte_size_start:midi.SampleParam)
  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 string ckpt = 9;
    if (cached_has_bits & 0x00000001u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::StringSize(
          this->_internal_ckpt());
    }

    // optional int32 tracks_per_step = 1 [(.midi.maxval) = 12, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000002u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_tracks_per_step());
    }

    // optional int32 bars_per_step = 2 [(.midi.maxval) = 8, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000004u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_bars_per_step());
    }

    // optional int32 model_dim = 3 [(.midi.maxval) = 8, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000008u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_model_dim());
    }

    // optional int32 percentage = 5 [(.midi.maxval) = 100, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000010u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_percentage());
    }

    // optional float temperature = 6 [(.midi.fmaxval) = 2, (.midi.fminval) = 0.5];
    if (cached_has_bits & 0x00000020u) {
      total_size += 1 + 4;
    }

    // optional int32 batch_size = 7 [(.midi.maxval) = 1, (.midi.minval) = 1];
    if (cached_has_bits & 0x00000040u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_batch_size());
    }

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

  }
  if (cached_has_bits & 0x00003f00u) {
    // optional bool verbose = 8;
    if (cached_has_bits & 0x00000100u) {
      total_size += 1 + 1;
    }

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

    // optional bool internal_random_sample_mode = 15;
    if (cached_has_bits & 0x00000400u) {
      total_size += 1 + 1;
    }

    // optional int32 max_steps = 13 [(.midi.maxval) = 2048, (.midi.minval) = 0];
    if (cached_has_bits & 0x00000800u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_max_steps());
    }

    // optional int32 polyphony_hard_limit = 14 [(.midi.maxval) = 100, (.midi.minval) = 0];
    if (cached_has_bits & 0x00001000u) {
      total_size += 1 +
        ::PROTOBUF_NAMESPACE_ID::internal::WireFormatLite::Int32Size(
          this->_internal_polyphony_hard_limit());
    }

    // optional bool internal_disable_masking = 16;
    if (cached_has_bits & 0x00002000u) {
      total_size += 2 + 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 SampleParam::MergeFrom(const ::PROTOBUF_NAMESPACE_ID::Message& from) {
// @@protoc_insertion_point(generalized_merge_from_start:midi.SampleParam)
  GOOGLE_DCHECK_NE(&from, this);
  const SampleParam* source =
      ::PROTOBUF_NAMESPACE_ID::DynamicCastToGenerated<SampleParam>(
          &from);
  if (source == nullptr) {
  // @@protoc_insertion_point(generalized_merge_from_cast_fail:midi.SampleParam)
    ::PROTOBUF_NAMESPACE_ID::internal::ReflectionOps::Merge(from, this);
  } else {
  // @@protoc_insertion_point(generalized_merge_from_cast_success:midi.SampleParam)
    MergeFrom(*source);
  }
}

void SampleParam::MergeFrom(const SampleParam& from) {
// @@protoc_insertion_point(class_specific_merge_from_start:midi.SampleParam)
  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) {
      _internal_set_ckpt(from._internal_ckpt());
    }
    if (cached_has_bits & 0x00000002u) {
      tracks_per_step_ = from.tracks_per_step_;
    }
    if (cached_has_bits & 0x00000004u) {
      bars_per_step_ = from.bars_per_step_;
    }
    if (cached_has_bits & 0x00000008u) {
      model_dim_ = from.model_dim_;
    }
    if (cached_has_bits & 0x00000010u) {
      percentage_ = from.percentage_;
    }
    if (cached_has_bits & 0x00000020u) {
      temperature_ = from.temperature_;
    }
    if (cached_has_bits & 0x00000040u) {
      batch_size_ = from.batch_size_;
    }
    if (cached_has_bits & 0x00000080u) {
      shuffle_ = from.shuffle_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
  if (cached_has_bits & 0x00003f00u) {
    if (cached_has_bits & 0x00000100u) {
      verbose_ = from.verbose_;
    }
    if (cached_has_bits & 0x00000200u) {
      internal_skip_preprocess_ = from.internal_skip_preprocess_;
    }
    if (cached_has_bits & 0x00000400u) {
      internal_random_sample_mode_ = from.internal_random_sample_mode_;
    }
    if (cached_has_bits & 0x00000800u) {
      max_steps_ = from.max_steps_;
    }
    if (cached_has_bits & 0x00001000u) {
      polyphony_hard_limit_ = from.polyphony_hard_limit_;
    }
    if (cached_has_bits & 0x00002000u) {
      internal_disable_masking_ = from.internal_disable_masking_;
    }
    _has_bits_[0] |= cached_has_bits;
  }
}

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

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

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

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

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


// @@protoc_insertion_point(namespace_scope)
}  // namespace midi
PROTOBUF_NAMESPACE_OPEN
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::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::SampleParam* Arena::CreateMaybeMessage< ::midi::SampleParam >(Arena* arena) {
  return Arena::CreateMessageInternal< ::midi::SampleParam >(arena);
}
PROTOBUF_NAMESPACE_CLOSE

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