sciss / scalamidi   0.2.1

Contributors Wanted GitHub

A library for accessing MIDI controllers and standard MIDI files. Mirror of

Scala versions: 2.12 2.11 2.10


Build Status Maven Central


ScalaMIDI is a library for accessing standard MIDI files in the Scala programming language. It is (C)opyright 2013–2017 by Hanns Holger Rutz. All rights reserved. ScalaOSC is released under the GNU Lesser General Public License v2.1+ and comes with absolutely no warranties. To contact the author, send an email to contact at

The example file for Erik Satie's 'Vexations', vexation.mid, is (C)opyright by Reinhard Kopiez and provided on a Creative Commons attribution (CC BY 3.0) type condition. This file is not included in the published library.


To link to this library:

libraryDependencies += "de.sciss" %% "scalamidi" % v

The current version v is "0.2.1"


ScalaMIDI currently builds against Scala 2.12, 2.11 and 2.10, using sbt 0.13. It uses the MIDI API from Java (javax.sound.midi) under the hood.


Please see the file


Reading and playing a MIDI file:

    import de.sciss.midi._

    val sq  ="vexation.mid")
    val pl  =
    val t   = sq.tracks(1)  // second of three tracks
    val ev  =      // all events in that track
    val pch = ev.collect { case Event(_, NoteOn(_, pch, _)) => pch }  // pitches % 12).toSet.toList.sorted // pitch classes (all twelve!)

Creating an example sequence:

    val ms  = (64 to 72).flatMap { pch => NoteOn(0, pch, 80) :: NoteOff(0, pch, 0) :: Nil }
    implicit val rate = TickRate.tempo(bpm = 120, tpq = 1024)
    val ev  = { case (m, i) => Event((i * 0.25 * rate.value).toLong, m) }
    val mx  =
    val t   = Track(ev)
    val sq  = Sequence(Vector(t))
    // sq.write(<path>)


  • This is a very early version
  • Currently, there is no support for many messages, such as after touch, pitch bend, time code, song pointer etc.

Note: There is another similarly named library scala-midi which is completely independent from this project.