generates an ostinato given a melody