functionality to generate melodies from STMCs