Hi Stephen,
I know you're trying to write your own program, maybe a bit more research might help. The fact that you don't have an arranger makes it rather difficult for you to test things out.

This is the software arranger I used for at least a couple of years. Maybe there's something on this site that may help you also.

http://www.1manband.nl/omb.htm
_________________________
best wishes
Rikki 🧸

Korg PA5X 88 note
SX900
Band in a Box 2022