tommadams / Open-Web-Piano

Virtual piano based on Web Audio API and Web MIDI API

Home Page:http://ibundin.github.io/Open-Web-Piano

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lightweight virtual web piano. There is only one sample per octave, however samples are mixed with each other for realistic sound with correct full-length sustain. Lowpass filters are used to emulate dynamics. This instrument works well with sustain pedal.

Installation

Simply copy openWebPiano.js and audio folder. See index.html for the example.

API

  1. init(context) - load all samples and start;
  2. noteOn(note 21 - 105, velocity 0 - 127 ) - start a note with a particular velocity level in standard MIDI format;
  3. noteOff(note) - stop a note;
  4. sustain(value) - any value higher then 0 switches sustain on, 0 value switches sustain off.

Example

<script type="module">
  import * as owp from './OpenWebPiano.js';

  await owp.init(new AudioContext());

  //on event(note,velocity) ->
  openWebPiano.noteOn(note, velocity);
</script>

License

MIT

About

Virtual piano based on Web Audio API and Web MIDI API

http://ibundin.github.io/Open-Web-Piano


Languages

Language:JavaScript 79.7%Language:HTML 20.3%