Skip to content

Commit

Permalink
Merge pull request #36 from romanbsd/track_name
Browse files Browse the repository at this point in the history
Add TrackNameEvent
  • Loading branch information
alextekartik authored Mar 11, 2024
2 parents d1fe83d + 895d076 commit 0dbf7fb
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/src/midi/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ abstract class MetaEvent extends MidiEvent {
int? metaCommand;
List<int> data;

static const int trackName = 0x3;
static const int metaTimeSig = 0x58;

// 2018-09-22
Expand Down Expand Up @@ -528,6 +529,8 @@ abstract class MetaEvent extends MidiEvent {
case metaEndOfTrack:
event = EndOfTrackEvent._();
break;
case trackName:
event = TrackNameEvent._();
default:
event = _MetaEvent();
break;
Expand Down Expand Up @@ -757,6 +760,19 @@ class EndOfTrackEvent extends MetaEvent {
}
}

class TrackNameEvent extends MetaEvent {
TrackNameEvent._() : super._();

TrackNameEvent() : super._withParam(MetaEvent.trackName);

String get trackName => String.fromCharCodes(data);

@override
String toString() {
return '${super.toString()} track name: $trackName';
}
}

class _MetaEvent extends MetaEvent {
_MetaEvent() : super._();
}

0 comments on commit 0dbf7fb

Please sign in to comment.