Skip to content

KenjiOhtsuka/kotlin-midi-player

Repository files navigation

Simple Kotlin Midi Player Library

Usage

(MidiSystem.getSynthesizer()) {
    Player {
        channel = channels[0]
        tempo = Tempo.Grave

        arrayOf(
                Note.C4, Note.D4, Note.E4, Note.F4, Note.G4, Note.A4, Note.B4
        ).forEach { p(it) }

        arrayOf(Chord.C, Chord.G).
                forEach { p(it) }

        p(Note.C4, Note.E4, Note.G4)
    }

    Player {
        channel = channels[0]
        tempo = Tempo.Prestissimo

        p(Note.C4, Note.E4)
        p(Note.D4, Note.D4 + 3)
        p(Note.E4, Note.E4 + 3)
    }
}

Tempo can be instantiated as follows

  • Tempo(60.0) : represents 60 bpm.
  • Tempo(1000.0, Tempo.Unit.Millisecond) : make quater note length 1000 milliseconds.

p(Note.C4) means play C4 note, as quater note.

Note.C4 + 2 is Note.D4, Note.E4 + 2 is Note.F4.

p(Chord.C) means play C chord, as quater notes.

For more detail, please look at Kotlin Midi Player Sample

Gradle

repositories {
  maven { url 'https://jitpack.io' }
}
dependencies {
  compile 'com.github.KenjiOhtsuka:kotlin-midi-player:0.0.2'
}

About

Simple Kotlin Midi Player Library. This tool makes it easy to output the sound with Kotlin DSL.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages