Code Monkey home page Code Monkey logo

scalamidi's Introduction

ScalaMIDI

statement

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

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.

linking

To link to this library:

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

The current version v is "0.1.+"

building

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

overview

Reading and playing a MIDI file:

    import de.sciss.midi._

    val sq  = Sequence.read("vexation.mid")
    val pl  = Sequencer.open()
    pl.play(sq)
    pl.stop()
    val t   = sq.tracks(1)  // second of three tracks
    val ev  = t.events      // all events in that track
    val pch = ev.collect { case Event(_, NoteOn(_, pch, _)) => pch }  // pitches
    pch.map(_ % 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  = ms.zipWithIndex.map { case (m, i) => Event((i * 0.25 * rate.value).toLong, m) }
    val mx  = ev.map(_.tick).max
    val t   = Track(ev)
    val sq  = Sequence(Vector(t))
    // sq.write(<path>)

limitations

  • 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.

## links

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

scalamidi's People

Contributors

sciss avatar

Watchers

Chris Phelps avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.