Pre-render calculation of bar length

21 views
Skip to first unread message

Personal Solutions

unread,
Oct 18, 2024, 3:31:17 PM10/18/24
to vexflow
I've just started attempting to use in a VueJs app. My requirement is take a pre-recorded MIDI file and turn it into a VexFlow score. I need to pre-calculate the size of each bar based on the transformed MIDI file so that I can create multiple lines if needed and ensure that notes do not spill over the space allocated to each bar. Is the feasible and how can it be done? I do not necessarily know the content of the MIDI file in advance. Would appreciate some guidance. Thanks.

Michael Asato Cuthbert

unread,
Oct 18, 2024, 4:23:03 PM10/18/24
to vexflow

The music21j package has tools for estimating Stave length in Vexflow — it might be overkill to import the whole package for that, but it’s open-source so you could adapt estimateStaffLength from music21j’s stream.ts (or stream/makeNotation.ts — I can’t remember where it actually lives) to do what you’d like.

Best,
Myke

Personal Solutions

unread,
Oct 20, 2024, 9:18:45 AM10/20/24
to vexflow
Thanks, that's really helpful. I'll look into that package (and probably learn a lot)!
Reply all
Reply to author
Forward
0 new messages