コード例 #1
0
ファイル: fader.js プロジェクト: msfeldstein/WebVRMidi
        constructor(params) {
            if (!params) {
                console.error("Fader needs a params object with the properties type:'note|cc' and note:notenumber")
            }
            super(params)
            this.type = params.type
            this.note = params.note
            this.name = "Fader"
            MIDI.enable((e) => {
                if (e) {
                    alert("No midi available", e)
                }
            })
            // this.midi = new MIDI()
            this.scale.set(0.01, 0.01, 0.01)
            var modelPath = 'assets/fader.obj'

            var mtlLoader = new THREE.MTLLoader()
            mtlLoader.setPath('assets/')
            mtlLoader.load('fader.mtl', (materials) => {
                materials.preload()
                var objLoader = new THREE.OBJLoader()
                objLoader.setMaterials(materials)
                objLoader.setPath('assets/')
                objLoader.load('fader.obj', (object) => {
                    this.slider = object.children.filter((child) => {
                        return child.name == 'Cube.001_Cube.002'
                    })[0]
                    this.slider.grabbable = true
                    this.slider.name = "Slider"
                    this.name = "Fader"
                    this.add(object)
                })
            })

            document.body.addEventListener('keydown', (e) => {

                if (e.keyCode == 38) { // up
                    this.moveSlider(1.5)
                    e.preventDefault()
                } else if (e.keyCode == 40) { //down
                    this.moveSlider(-1.5)
                    e.preventDefault()
                }
            })
        }
コード例 #2
0
ファイル: index.js プロジェクト: zwippie/webvolca
import Rack from './Rack'

// First, let's shim the requestAnimationFrame API, with a setTimeout fallback
window.requestAnimFrame = (function(){
  return  window.requestAnimationFrame ||
  window.webkitRequestAnimationFrame ||
  window.mozRequestAnimationFrame ||
  window.oRequestAnimationFrame ||
  window.msRequestAnimationFrame ||
  function( callback ){
      window.setTimeout(callback, 1000 / 60);
  };
})();

// Test for WebMidi support
WebMidi.enable(onSuccess, onFailure)

function onSuccess() {
  console.log("WebMidi enabled.")
  WebMidi.playNote('C2', 0.5, 100, undefined, 'all')
  WebMidi.playNote('D2', 0.75, 100, undefined, 'all', '+100')
  WebMidi.playNote('E2', 1, 100, undefined, 'all', '+200')
  WebMidi.playNote('C4', 1, 500, undefined, 'all', '+300')

  WebMidi.addListener(
    'noteon',
    function(e){ console.log(e); }
  );

  WebMidi.inputs.map(function(input) {
    console.log(input)