This paper introduces TunesFormer, an efficient Transformer-based
dual-decoder model specifically designed for the generation of melodies that
adhere to user-defined musical forms. Trained on 214,122 Irish tunes,
TunesFormer utilizes techniques including bar patching and control codes. Bar
patching reduces sequence length and generation time, while control codes guide
TunesFormer in producing melodies that conform to desired musical forms. Our
evaluation demonstrates TunesFormer's superior efficiency, being 3.22 times
faster than GPT-2 and 1.79 times faster than a model with linear complexity of
equal scale while offering comparable performance in controllability and other
metrics. TunesFormer provides a novel tool for musicians, composers, and music
enthusiasts alike to explore the vast landscape of Irish music. Our model and
code are available at https://github.com/sander-wood/tunesformer.Comment: 5 pages, 3 figures, 1 tabl