All Projects → feross → Timidity

feross / Timidity

Licence: mit
Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity

Programming Languages

javascript
184084 projects - #8 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to Timidity

Yt Player
Simple, robust, blazing-fast YouTube Player API
Stars: ✭ 576 (+160.63%)
Mutual labels:  player, browser
Low Latency Android Ios Linux Windows Tvos Macos Interactive Audio Platform
🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
Stars: ✭ 1,121 (+407.24%)
Mutual labels:  midi, webassembly
Webaudiofont
Use full GM set of musical instruments to play MIDI and single sounds or effects. Support for reverberation and equaliser. No plugins, no Flash. Pure HTML5 implementation compatible with desktop and mobile browser. See live examples.
Stars: ✭ 600 (+171.49%)
Mutual labels:  player, midi
Clubber
Application of music theory in audio reactive visualizations
Stars: ✭ 325 (+47.06%)
Mutual labels:  midi, web-audio
Fetch Stream Audio
Low Latency web audio playback examples for decoding audio streams in chunks with Fetch & Streams APIs
Stars: ✭ 153 (-30.77%)
Mutual labels:  web-audio, webassembly
Jzz
MIDI library for Node.js and web-browsers
Stars: ✭ 325 (+47.06%)
Mutual labels:  midi, web-audio
Kjplayerdemo
视频播放壳子:动态切换内核,支持边下边播边缓存的播放器方案,视频支持格式:mp4、m3u8、wav、avi,音频支持格式:midi、mp3
Stars: ✭ 60 (-72.85%)
Mutual labels:  player, midi
linux-show-player
Linux Show Player - Cue player designed for stage productions
Stars: ✭ 147 (-33.48%)
Mutual labels:  player, midi
Libarchivejs
Archive library for browsers
Stars: ✭ 145 (-34.39%)
Mutual labels:  webassembly, browser
Percy
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering.
Stars: ✭ 1,856 (+739.82%)
Mutual labels:  webassembly, browser
Soundfont Player
Quick soundfont loader and player for browser
Stars: ✭ 313 (+41.63%)
Mutual labels:  player, midi
Nodeplayer.js
Pure JavaScrip HTML5 live stream player
Stars: ✭ 157 (-28.96%)
Mutual labels:  player, browser
Standardized Audio Context
A cross-browser wrapper for the Web Audio API which aims to closely follow the standard.
Stars: ✭ 300 (+35.75%)
Mutual labels:  web-audio, browser
Romplayer
AudioKit Sample Player (ROM Player) - EXS24, Sound Font, Wave Player
Stars: ✭ 445 (+101.36%)
Mutual labels:  player, midi
LabMidi
Midi IN and OUT. Standard midi file parser and player. Midi Softsynth implementation.
Stars: ✭ 38 (-82.81%)
Mutual labels:  player, midi
Webmidi
Tame the Web MIDI API. Send and receive MIDI messages with ease. Control instruments with user-friendly functions (playNote, sendPitchBend, etc.). React to MIDI input with simple event listeners (noteon, pitchbend, controlchange, etc.).
Stars: ✭ 906 (+309.95%)
Mutual labels:  midi, browser
mpe-player
Browser Based Audio Oscillators using MPE devices & MPE.js
Stars: ✭ 16 (-92.76%)
Mutual labels:  player, midi
media-player
An modern, clean media player built using web technologies
Stars: ✭ 44 (-80.09%)
Mutual labels:  player, web-audio
Web Audio Javascript Webassembly Sdk Interactive Audio
🌐 Superpowered Web Audio JavaScript and WebAssembly SDK for modern web browsers. Allows developers to implement low-latency interactive audio features into web sites and web apps with a friendly Javascript API. https://superpowered.com
Stars: ✭ 68 (-69.23%)
Mutual labels:  web-audio, webassembly
Html Midi Player
🎹 Play and display MIDI files on the web
Stars: ✭ 158 (-28.51%)
Mutual labels:  player, midi

timidity

travis npm downloads javascript style guide

Play MIDI files in the browser w/ Web Audio, WebAssembly, and libtimidity

Play MIDI files in a browser with a simple API.

Demo

This package is used on BitMidi.com, the wayback machine for old-school MIDI files! Check out some examples here:

Install

npm install timidity

Features

  • Lightweight – Just 23 KB of JavaScript and 22 KB of lazy-loaded WebAssembly
  • Simple – No bells and whistles. Just what is needed to play MIDI files.
  • Works with the FreePats General MIDI soundset.

Usage

const Timidity = require('timidity')

const player = new Timidity()
player.load('/my-file.mid')
player.play()

player.on('playing', () => {
  console.log(player.duration) // => 351.521
})

Easier Usage

If you just want to play MIDI files in the browser and don't need a JavaScript API interface, consider using the bg-sound package, which supports this much simpler usage:

<script src="bg-sound.min.js"></script>
<bg-sound src="sound.mid"></bg-sound>

API

player = new Timidity([baseUrl])

Create a new MIDI player.

Optionally, provide a baseUrl to customize where the player will look for the lazy-loaded WebAssembly file libtimidity.wasm and the FreePats General MIDI soundset files. The default baseUrl is /.

For example, here is how to mount the necessary files at / with the express server:

const timidityPath = path.dirname(require.resolve('timidity'))
app.use(express.static(timidityPath))

const freepatsPath = path.dirname(require.resolve('freepats'))
app.use(express.static(freepatsPath))

player.load(urlOrBuf)

This function loads the specified MIDI file urlOrBuf, which is a string path to the MIDI file or a Uint8Array which contains the MIDI file data.

This should be the first function called on a new Timidity instance.

player.play()

Plays the currently loaded MIDI file.

player.pause()

Pauses the currently loaded MIDI file.

player.seek(seconds)

Seeks to a specified time in the MIDI file.

If the player is paused when the function is called, it will remain paused. If the function is called from another state (playing, etc.), the player will continue playing.

player.duration

Returns the duration in seconds (number) of the currently playing MIDI file. Note that duration will return 0 until the file is loaded, which normally happens just before the playing event.

player.currentTime

Returns the elapsed time in seconds since the MIDI file started playing.

player.destroy()

Destroys the entire player instance, stops the current MIDI file from playing, cleans up all resources.

Note: It's best to reuse the same player instance for as long as possible. It is not recommended to call player.destroy() to stop or change MIDI files. Rather, just call player.pause() to pause or player.load() to load a new MIDI file.

player.destroyed

Returns true if destroy() has been called on the player. Returns false otherwise.

player.on('error', (err) => {})

This event fires if a fatal error occurs in the player, including if a MIDI file is unable to be played.

player.on('timeupdate', (seconds) => {})

This event fires when the time indicated by the currentTime property has been updated.

player.on('unstarted', () => {})

This event fires when a new MIDI file is being loaded.

player.on('ended', () => {})

This event fires when a MIDI file has played until the end.

player.on('playing', () => {})

This event fires when a MIDI file starts playing.

player.on('paused', () => {})

This event fires when a MIDI file is paused.

player.on('buffering', () => {})

This event fires when a MIDI file is loading.

License

Copyright (c) Feross Aboukhadijeh.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].