Giter VIP home page Giter VIP logo

midi4j's Introduction

midi4j

Midi Sound Files Player and Meta Info Parser

Java implementation of a Midi file Player & Midi Meta Info Parser Library. This implementation is using vanilla Java classes without any 3rd party libraries.

If you just want to play a Midi file and don't want to delve into the midi classes (Like the Sequencer, Synthesizer, Tracks etc), then just use the Midi class, point it to your Midi file and use the play() method to play it, togglePause() to unqpause or navigate to any place in the Midi file jumpToPosition(long milliseconds).

If you want to parse a Midi file, to read the MetaData written about it, from a Disclaimer, to copyright notice, through titles and the track messages then just use the MidiInfo class and call the relevant methods.

Methods names are self-explanatory, and JavaDocs exist - these are your friends.

midi4j was created with convenience and simplicity in mind, so it consists of only those two important files.

Midi.java - which is used to play/pause/jumpToPosition the Midi file.

MidiInfo.java - is used to parse the Meta Information from the Midi file (if midi info was indeed put into the Midi file)

Maven

<dependency>
<groupId>org.chaiware</groupId>
<artifactId>midi4j</artifactId>
<version>1.0</version>
</dependency>

Examples

(A complete example with additional functionality can be found in the Midi4jExample.java file)

Midi Player Example

Midi midi = new Midi($PATH_TO_MIDI_FILE$);
midi.play(); // Plays Asynchronously
midi.jumpToPositionInMS(midi.getCurrentPositionInMS() + 50000); // Jumps forward
while (midi.isPlaying())
Thread.sleep(250);
midi.shutdown();

Midi Info Example

MidiInfo midiInfo = new MidiInfo($PATH_TO_MIDI_FILE$);
Map<MidiMetaMessageType, String> metaInfo = midiInfo.getAllMetaInfo();
for (Map.Entry<MidiMetaMessageType, String> entry : metaInfo.entrySet())
System.out.println(entry.getKey().getReadableMetaName() + "\n" + entry.getValue() + "\n\n");

Simple Project Using Midi4j

You can see a simple project using midi4j here: FloppyMidiPlayer
The above project uses midi4j in order to play Midi files from Floppy diskettes

Its code is simple to understand, it scans the floppy diskette and plays all the midi files it finds in it, while enabling navigation in the Midi file, pausing it and looking at the MetaInfo in the Midi file.

midi4j's People

Contributors

chaiavi avatar

Stargazers

 avatar

Watchers

 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.