opal-web-midi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +2 -0
- data/LICENSE.md +21 -0
- data/README.md +26 -0
- data/Rakefile +14 -0
- data/lib/opal-web-midi.rb +3 -0
- data/opal-web-midi.gemspec +17 -0
- data/opal/opal-web-midi.rb +1 -0
- data/opal/web-midi.rb +5 -0
- data/opal/web_midi.rb +21 -0
- data/opal/web_midi/access.rb +25 -0
- data/opal/web_midi/input.rb +31 -0
- data/opal/web_midi/message.rb +23 -0
- data/opal/web_midi/output.rb +22 -0
- metadata +84 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2f5fee060fbecb4c1e9f5acf3676a90204369a9b
|
4
|
+
data.tar.gz: c1be40f251cf017fa1206a1f7994755c55c79e15
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f0135a90228a9d61f276628614bce52c926891c258657f8549f80dceb7fde7797b0076cc18041e784c3a615222089f66dd99cc1157cf9bfd08789009c0bdfdcf
|
7
|
+
data.tar.gz: 783187a3b2f4423c557c88dfd76eab13da6d88cd1a54e8eb8b7a698dadcadf38bc73540116c078a60df000d457d47b343e4adaf901b61fe5aff2c648c87e8379
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Michał Kalbarczyk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# opal-web-midi [![Gem Version](https://badge.fury.io/rb/opal-web-midi.svg)](http://badge.fury.io/rb/opal-web-midi) [![Code Climate](https://codeclimate.com/github/fazibear/opal-web-midi/badges/gpa.svg)](https://codeclimate.com/github/fazibear/opal-web-midi)
|
2
|
+
|
3
|
+
Web MIDI wrapper for Opal.
|
4
|
+
|
5
|
+
## usage
|
6
|
+
|
7
|
+
### Server side
|
8
|
+
config.ru, Rakefile, Rails, Sinatra, etc.
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
require 'opal-web-midi'
|
12
|
+
```
|
13
|
+
|
14
|
+
Gemfile
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'opal-web-midi'
|
18
|
+
```
|
19
|
+
|
20
|
+
### Browser side
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
require 'web-midi'
|
24
|
+
|
25
|
+
# TBD
|
26
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
desc 'Update Phoenix JS lib'
|
8
|
+
task :update_js do
|
9
|
+
js_lib_url = 'https://raw.githubusercontent.com/phoenixframework/phoenix/master/priv/static/phoenix.js'
|
10
|
+
js_lib_dest = File.join(File.dirname(__FILE__), './lib/phoenix_js.js')
|
11
|
+
open(js_lib_url) do |f|
|
12
|
+
File.write(js_lib_dest, f.readlines.join)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'opal-web-midi'
|
3
|
+
s.version = '0.0.1'
|
4
|
+
s.authors = ['Michał Kalbarczyk']
|
5
|
+
s.email = 'fazibear@gmail.com'
|
6
|
+
s.homepage = 'http://github.com/fazibear/opal-web-midi'
|
7
|
+
s.summary = 'Web MIDI wrapper for opal'
|
8
|
+
s.description = 'Web MIDI wrapper for opal'
|
9
|
+
|
10
|
+
s.files = `git ls-files`.split("\n")
|
11
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
12
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
|
+
s.require_paths = ['lib']
|
14
|
+
|
15
|
+
s.add_dependency 'opal'
|
16
|
+
s.add_development_dependency 'rake'
|
17
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'web-midi'
|
data/opal/web-midi.rb
ADDED
data/opal/web_midi.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module WebMidi
|
2
|
+
Navigator = Native(`navigator`)
|
3
|
+
|
4
|
+
def self.request_access(options = {}, &block)
|
5
|
+
success = lambda do |access|
|
6
|
+
block.call Access.new(access)
|
7
|
+
end
|
8
|
+
|
9
|
+
failure = lambda do |e|
|
10
|
+
fail e
|
11
|
+
end
|
12
|
+
|
13
|
+
Navigator
|
14
|
+
.requestMIDIAccess(options)
|
15
|
+
.then(success, failure)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.new(options = {}, &block)
|
19
|
+
self.request_access(options, &block)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module WebMidi
|
2
|
+
class Access
|
3
|
+
include Native
|
4
|
+
|
5
|
+
def initialize(access)
|
6
|
+
super(access)
|
7
|
+
end
|
8
|
+
|
9
|
+
def inputs
|
10
|
+
values_from_iterator(Input, `#{@native}.inputs`)
|
11
|
+
end
|
12
|
+
|
13
|
+
def outputs
|
14
|
+
values_from_iterator(Output, `#{@native}.outputs`)
|
15
|
+
end
|
16
|
+
|
17
|
+
def values_from_iterator(clazz, iterator)
|
18
|
+
values = `#{iterator}.values()`
|
19
|
+
size = `#{iterator}.size`
|
20
|
+
size.times.inject([]) do |out, _i|
|
21
|
+
out << clazz.new(`#{values}.next().value`)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module WebMidi
|
2
|
+
class Input
|
3
|
+
include Native
|
4
|
+
|
5
|
+
alias_native :connection
|
6
|
+
alias_native :manufacturer
|
7
|
+
alias_native :name
|
8
|
+
alias_native :state
|
9
|
+
alias_native :type
|
10
|
+
alias_native :version
|
11
|
+
|
12
|
+
def initialize(input)
|
13
|
+
super(input)
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_change_state(&block)
|
17
|
+
`#{@native}.onchangestate = #{block}`
|
18
|
+
end
|
19
|
+
|
20
|
+
def on_message(&block)
|
21
|
+
callback = lambda do |message|
|
22
|
+
block.call Message.new(message)
|
23
|
+
end
|
24
|
+
`#{@native}.onmidimessage = #{callback}`
|
25
|
+
end
|
26
|
+
|
27
|
+
def send(*_args)
|
28
|
+
fail "Can't send messages to Input"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module WebMidi
|
2
|
+
class Message
|
3
|
+
include Native
|
4
|
+
|
5
|
+
alias_native :type
|
6
|
+
|
7
|
+
def initialize(message)
|
8
|
+
super(message)
|
9
|
+
end
|
10
|
+
|
11
|
+
def data
|
12
|
+
`#{@native}.data`
|
13
|
+
end
|
14
|
+
|
15
|
+
def time_stamp
|
16
|
+
`#{@native}.timeStamp`
|
17
|
+
end
|
18
|
+
|
19
|
+
def received_at
|
20
|
+
`#{@native}.receivedTime`
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module WebMidi
|
2
|
+
class Output
|
3
|
+
include Native
|
4
|
+
|
5
|
+
alias_native :connection
|
6
|
+
alias_native :manufacturer
|
7
|
+
alias_native :name
|
8
|
+
alias_native :state
|
9
|
+
alias_native :type
|
10
|
+
alias_native :version
|
11
|
+
|
12
|
+
alias_native :send
|
13
|
+
|
14
|
+
def initialize(output)
|
15
|
+
super(output)
|
16
|
+
end
|
17
|
+
|
18
|
+
def on_change_state(&block)
|
19
|
+
`#{@native}.onchangestate = #{block}`
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal-web-midi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michał Kalbarczyk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Web MIDI wrapper for opal
|
42
|
+
email: fazibear@gmail.com
|
43
|
+
executables: []
|
44
|
+
extensions: []
|
45
|
+
extra_rdoc_files: []
|
46
|
+
files:
|
47
|
+
- ".gitignore"
|
48
|
+
- Gemfile
|
49
|
+
- LICENSE.md
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- lib/opal-web-midi.rb
|
53
|
+
- opal-web-midi.gemspec
|
54
|
+
- opal/opal-web-midi.rb
|
55
|
+
- opal/web-midi.rb
|
56
|
+
- opal/web_midi.rb
|
57
|
+
- opal/web_midi/access.rb
|
58
|
+
- opal/web_midi/input.rb
|
59
|
+
- opal/web_midi/message.rb
|
60
|
+
- opal/web_midi/output.rb
|
61
|
+
homepage: http://github.com/fazibear/opal-web-midi
|
62
|
+
licenses: []
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - ">="
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.5.1
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: Web MIDI wrapper for opal
|
84
|
+
test_files: []
|