Load and play MIDI from Hyperdrive over the DAT network using timidity and hyperdrive.
$ npm install hypermidi
const midi = require('hypermidi')('/path/to/storage', 'KEY', opts)
// replicate somehow (discovery-swarm-web works well)
midi.play('/path/to/track.mid') // probably need a user gesture/event
The module expects to load
libtimidity.wasm
and freepats sounds sets over the network so
your web server should be able to serve them.
const hypermidi = require('hyperidi')
const Discovery = require('discovery-swarm-web')
const ram = require('random-access-memory')
const key = '4f25776241c2333fa2cb724aac6fcf4d49f6fa7e243238c589cf021728762695'
const midi = hypermidi(ram, key)
global.midi = midi
midi.ready(() => {
const swarm = new Discovery({
stream: () => midi.replicate()
})
swarm.join(midi.discoveryKey)
const button = document.body.appendChild(document.createElement('button'))
button.innerText = 'play'
button.onclick = () => midi.play('Bean.mid', console.log)
})
Run with budo
$ budo example.js --live --port 3000 --dir node_modules/timidity --dir node_modules/freepats
Visit http:https://localhost:3000
and press play
! Assuming you can connect
to the DAT network and replicate the archive.
Same arguments as Hyperdrive.
Load and play a midi file over the network.
Pause current track.
Seek track to current time in seconds
Destroy the player.
Close and destroy the player
MIT