Git Product home page Git Product logo

Comments (2)

walmik avatar walmik commented on July 25, 2024

You cannot do this without some additional workarounds.

If all you want to do is to play MIDI in the browser, then you can directly use the Web MIDI API (on Chrome) to do so. But if you want to play MIDI in the browser or create a MIDI file in the browser and then have it saved as a .mid file using jsmidgen, then you ll have to do a bit of work. jsmidgen works is a Node.js module and outputs binary data that you can hand write to a MIDI file.

To have it do this in the browser, I d imagine you'd need to

  • Use something like browserify to first make jsmidgen run in the browser
  • parse the incoming MIDI messages from the Web MIDI API to jsmidgen's noteOn noteOff messages on the Track object
  • Use the DOM File API (on Chrome) to construct files from bytes returned by jsmidgen

For instance, if you 'listen' to incoming MIDI data using the Web MIDI API, you ll get something like [144, 60, 127] for pressing the C4 (60) note at the highest velocity (127). In there, 144 signifies noteOn. So you ll need to convert each such message (made up of a status byte and upto 2 data bytes) into something like,

track.addNote(0, 'c4', <derive duration>);

Once you chain all the noteOn and noteOff events, you can use the getBytes method in jsdmidgen (on the File object) and use that alongside DOM File API of the (Chrome) browser to save a file to the user's disc.

from jsmidgen.

sksar avatar sksar commented on July 25, 2024

it works perfectly fine with filesaver.js
I have tested myself and its working just fine.

from jsmidgen.

Related Issues (20)

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.