How to convert a list of MIDI data to lilypond format?

I have a Python program which creates a list of MIDI values: [Channel, Track, Time_Start, Note, Dur, and Vel]. How can I create a lilypond file from this list? I would like to do this using Scamp, if possible. I do not want to use abjad directly.

My main problem is what to do with the MIDI Time_Start values? How do I add [note, dur, vel] values to a Score() object at a particular time?

Is Transcribing a performance the only way to add data to a Score() object?

Thank you!

You could try something like this, although I’m realizing I have some improvements to make!

from scamp import *


notes = [
    # Channel, Track, Time_Start, Note, Dur, and Vel
    
    # Track 1
    (1, 1, 1.0, 60, 1.0, 100),
    (1, 1, 2.0, 66, 2.0, 100),
    (1, 1, 4.0, 62, 4.0, 100),
    (1, 1, 6.0, 66, 2.0, 100),
    
    # Track 2
    (1, 2, 0.0, 62, 4.0, 100),
    (1, 2, 2.0, 66, 2.0, 100),    
    (1, 2, 5.0, 60, 1.0, 100),
    (1, 2, 6.0, 66, 2.0, 100),
]


channel1_track1_notes = [
    PerformanceNote(start_beat=note[2], length=note[4], pitch=note[3], volume=note[5], properties=NoteProperties("c major"))
    for note in notes
    if note[0] == 1 and note[1] == 1
]

channel1_track2_notes = [
    PerformanceNote(start_beat=note[2], length=note[4], pitch=note[3], volume=note[5], properties=NoteProperties("c major"))
    for note in notes
    if note[0] == 1 and note[1] == 2
]


perf = Performance([
    PerformancePart(ScampInstrument("Viola"), voices=channel1_track1_notes),
    PerformancePart(ScampInstrument("Piano"), voices=channel1_track2_notes),
])

perf.to_score(time_signature="4/4").show()

Marc, thank you so much! I just tried it and it works perfectly. I didn’t expect you to write my code for me, just give me a nudge in the right direction. Thanks again!

Sincerely,
Happy Scamp User

Well, I realized that there were a couple gotchas in setting up the performance, because of things I should probably fix. You shouldn’t have to create a Scamp instrument in order to build a performance!