Skip to content

Add examples on how to write LiveEvents to mid files #24

Description

@Qualphey

I'm trying to write events, coming from jack midi input port, to a mid file. I guess I could say I'm trying to record a midi sequence. The documentation doesn't really have much info nor any examples on how to write live event sequences to mid files.

I still tried and couldn't figure out how to convert LiveEvent to TrackEvent, so I could write it.

I've set up an SMF:

let header = midly::Header {
  format: midly::Format::SingleTrack, // Replace with the desired format
  timing: midly::Timing::Metrical(480.into()), // Replace with the desired timing information
};
let smf = midly::Smf::new(header);

and then tried to push an event to the first track:

let arena = midly::Arena::new();    
...
let live_event = LiveEvent::parse(data).unwrap();
smf.tracks[0].push(live_event.as_track_event(&arena));

But as_track_event returns TrackEventKind and I can't find no way to convert that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions