Skip to content

Extend MIDI parser and model to keep the meta-event in the tracks#1087

Draft
keryell wants to merge 8 commits intoArdour:masterfrom
keryell:add-midi-events
Draft

Extend MIDI parser and model to keep the meta-event in the tracks#1087
keryell wants to merge 8 commits intoArdour:masterfrom
keryell:add-midi-events

Conversation

@keryell
Copy link
Copy Markdown

@keryell keryell commented Mar 24, 2026

Support the meta-event described in:

  • Standard MIDI Files 1.0, In 'The Complete MIDI 1.0 Detailed Specification,
    Document Version 96.1.' The MIDI Manufacturers Association, Los Angeles, CA,
    USA.

  • Recommended Practice (RP-019) SMF Device Name and Program Name Meta
    Events. 1999, MIDI Manufacturers Association Incorporated

The meta-events are included only if the "Import MIDI markers" are selected on the "Add Existing Media" import window.

Add a LUA script to dump the non-note content of MIDI regions and file.

This is supposed to address https://discourse.ardour.org/t/importing-midi-files-with-most-metadata/113061

keryell added 7 commits March 23, 2026 22:44
Support the meta-event described in:

- Standard MIDI Files 1.0, In 'The Complete MIDI 1.0 Detailed Specification,
  Document Version 96.1.' The MIDI Manufacturers Association, Los Angeles, CA,
  USA.

- Recommended Practice (RP-019) SMF Device Name and Program Name Meta
  Events. 1999, MIDI Manufacturers Association Incorporated

Add a LUA script to dump the non-note content of MIDI regions and file.
Also extend _display_midi_meta_events.lua to display the meta-events from the
MIDI model along the content of the files.
Do not skip it when the SMF file does not exist.
Print a message about the fact that the session has to be saved to display
up-to-date SMF file information.
@pauldavisthefirst
Copy link
Copy Markdown
Contributor

Was this written using an LLM ?

Parts of it appear useful and reasonable. It isn't clear to me that meta-events belong in our Sequence object, but I'll give it some thought.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems incorrect to me that the return 0 statements here are deleted. This value is used by the caller to indicate the specific condition of an Ardour-specific sequencer-specific event.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it the idea, if we want the meta-event to be returned so it is in the track, by copying it on line 377?

memcpy(*buf, event->midi_buffer, size_t(event_size));

There is still later on line 386:

		if (is_meta) {
			return 0;
		}

left for the caller interpretation.
Actually, looking at the change you made in 1ee76f4 shows that it is actually the size == 0 which is used to discard the meta-event, not the the return value.

Your comment made be look at Type 0 track and there the meta-event was not kept. I have updated it a new commit.

@keryell
Copy link
Copy Markdown
Author

keryell commented Mar 25, 2026

Was this written using an LLM ?

Yes, most of it.

Parts of it appear useful and reasonable. It isn't clear to me that meta-events belong in our Sequence object, but I'll give it some thought.

The goal of this PR is to get some thoughts.
I am not sure about what you mean, since I do not have the big picture.
If I want do some processing on the MIDI track according to the value of some meta-events of the track, I have the feeling these should be in the track. It is possible to dive into the interchange/.../midifiles but that seems inefficient and requires to have the session saved first.

The Type 0 import path (write_midi_type0_data_to_one_file) was skipping all
meta events with if (ret == 0) continue.
Now it writes text meta events through with allow_meta=true, matching what the
Type 1 path already does.
The append_event_delta() → is_meta() filter will only let recognized
types (0x01-0x09) through.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants