-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.js
64 lines (50 loc) · 1.3 KB
/
host.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* copyright 2015 James Ingram
* http://james-ingram-act-two.de/
*
* Code licensed under MIT
*/
/*jslint bitwise: false, nomen: true, plusplus: true, white: true */
/*global WebMIDI: false, WebMIDISynth: false, window: false, document: false, performance: false, console: false, alert: false, XMLHttpRequest: false */
WebMIDI.namespace('WebMIDI.host');
WebMIDI.host = (function()
{
"use strict";
var
synth = new WebMIDI.cwMIDISynth.CWMIDISynth(),
gitHubButtonClick = function()
{
var
win = window.open("https://github.com/notator/SimpleMIDISynthHost", "_blank");
win.focus();
},
doMouseOver = function(e)
{
var NOTE_ON = WebMIDI.constants.COMMAND.NOTE_ON,
channel = 0,
key = parseInt(e.target.id),
velocity = 100,
status = NOTE_ON + channel,
message = new Uint8Array([status, key, velocity]);
synth.send(message, performance.now());
},
doMouseOut = function(e)
{
var
NOTE_OFF = WebMIDI.constants.COMMAND.NOTE_OFF,
channel = 0,
key = parseInt(e.target.id),
velocity = 100,
status = NOTE_OFF + channel,
message = new Uint8Array([status, key, velocity]);
synth.send(message, performance.now());
},
publicAPI =
{
gitHubButtonClick: gitHubButtonClick,
doMouseOver: doMouseOver,
doMouseOut: doMouseOut
};
synth.init();
return publicAPI;
}());