Giter Club home page Giter Club logo

midi-visualizer's Introduction

<midi-visualizer>

This is a web component that shows a visualization for a midi file, and can play audio while updating the visualization. The audio playing works best with Piano midi files at the moment, but some multi-instrument midi files will work too.

demo of using the midi-visualizer

Sample use

<html>
  <head>
    <!-- Web components polyfill, so this works on all browsers -->
  <script src="https://unpkg.com/@webcomponents/webcomponentsjs@^2.0.0/webcomponents-loader.js"></script>

  <!-- Load magenta.js, which is needed by the element. -->
  <script src="https://unpkg.com/@magenta/[email protected]/dist/magentamusic.js"></script>

  <!-- Load the web component itself -->
  <script src="midi-visualizer.js"></script>
  </head>
  <body>

  <!-- Use the web component! -->
  <midi-visualizer
  id="visualizer"
  url="https://cdn.glitch.com/3312a3b4-6418-4bed-a0bd-3a0ca4dfa2fb%2Fchopin.mid?1534369337985">
  </midi-visualizer>
  </body>
</html>

Configuring the visualizer

Properties and attributes

The <midi-visualizer> has the following properties you can use:

  • the tempo, at which the player is playing the midi. You can use this either as a property in JavaScript (eg. aVisualizer.tempo = 500) or as attribute in HTML (eg. <midi-visualizer tempo="200"></midi-visualizer>)
  • the url of a midi file to be visualized. You can use this either as a property in JavaScript (eg. aVisualizer.url = "https://example.com/foo.mid") or as attribute in HTML (eg. <midi-visualizer url="https://example.com/foo.mid"></midi-visualizer>)
  • noteSequence: a magenta.js NoteSequence object. You can only set this as a JavaScript property (eg. aVisualizer.noteSequence = new mm.NoteSequence())

Methods

The <midi-visualizer> has the following methods you can call:

  • start(), to start playing the midi
  • stop(), to stop playing the midi
  • loadFile(blob), to load a midi file contents. This is useful if you want to allow the user to upload a midi, rather than pointing to a specific file url. See the demo for an example.

midi-visualizer's People

Contributors

notwaldorf avatar

Watchers

Antonio Molinari avatar James Cloos 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.