Rule-based algorithm for melody generation written in Scala.