midiator 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/chromatic_scale.rb +1 -0
- data/examples/metronome.rb +1 -0
- data/lib/midiator.rb +15 -3
- data/lib/midiator/interface.rb +14 -3
- data/lib/midiator/notes.rb +4 -7
- data/misc/rake/packaging.rb +2 -0
- data/spec/interface_spec.rb +15 -13
- metadata +13 -4
data/examples/chromatic_scale.rb
CHANGED
data/examples/metronome.rb
CHANGED
data/lib/midiator.rb
CHANGED
@@ -13,12 +13,24 @@
|
|
13
13
|
# This code released under the terms of the MIT license.
|
14
14
|
#
|
15
15
|
|
16
|
-
require 'string_extensions'
|
17
|
-
|
18
16
|
module MIDIator
|
19
|
-
VERSION = "0.
|
17
|
+
VERSION = "0.2.0"
|
20
18
|
end
|
21
19
|
|
20
|
+
#####################################################################
|
21
|
+
### E X T E R N A L D E P E N D E N C I E S
|
22
|
+
#####################################################################
|
23
|
+
require 'rubygems'
|
24
|
+
require 'platform'
|
25
|
+
|
26
|
+
#####################################################################
|
27
|
+
### C O R E L I B R A R Y E X T E N S I O N S
|
28
|
+
#####################################################################
|
29
|
+
require 'string_extensions'
|
30
|
+
|
31
|
+
#####################################################################
|
32
|
+
### M I D I A T O R C O R E
|
33
|
+
#####################################################################
|
22
34
|
require 'midiator/driver'
|
23
35
|
require 'midiator/driver_registry'
|
24
36
|
require 'midiator/exceptions'
|
data/lib/midiator/interface.rb
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
#
|
8
8
|
# * Ben Bleything <ben@bleything.net>
|
9
9
|
#
|
10
|
+
# == Contributors
|
11
|
+
#
|
12
|
+
# * Giles Bowkett
|
13
|
+
#
|
10
14
|
# == Copyright
|
11
15
|
#
|
12
16
|
# Copyright (c) 2008 Ben Bleything
|
@@ -21,9 +25,16 @@ class MIDIator::Interface
|
|
21
25
|
|
22
26
|
### Automatically select a driver to use
|
23
27
|
def autodetect_driver
|
24
|
-
|
25
|
-
|
26
|
-
|
28
|
+
driver = case Platform::IMPL
|
29
|
+
when :macosx
|
30
|
+
:core_midi
|
31
|
+
when :mswin
|
32
|
+
:winmm
|
33
|
+
when :linux
|
34
|
+
:alsa
|
35
|
+
end
|
36
|
+
|
37
|
+
self.use(driver)
|
27
38
|
end
|
28
39
|
|
29
40
|
|
data/lib/midiator/notes.rb
CHANGED
@@ -7,6 +7,10 @@
|
|
7
7
|
#
|
8
8
|
# * Ben Bleything <ben@bleything.net>
|
9
9
|
#
|
10
|
+
# == Contributors
|
11
|
+
#
|
12
|
+
# * Xavier Shay
|
13
|
+
#
|
10
14
|
# == Copyright
|
11
15
|
#
|
12
16
|
# Copyright (c) 2008 Ben Bleything
|
@@ -80,13 +84,6 @@ module MIDIator::Notes # this file does not rdoc well, so uhh.... :nodoc:
|
|
80
84
|
As8 = 118 ; Bb8 = 118
|
81
85
|
B8 = 119 ; Cb9 = 119
|
82
86
|
|
83
|
-
# these notes are not valid MIDI notes but they're here to complete the
|
84
|
-
# octave. Use at your own risk?
|
85
|
-
Gs9 = 128 ; Ab9 = 128
|
86
|
-
A9 = 129 ;
|
87
|
-
As9 = 130 ; Bb9 = 130
|
88
|
-
B9 = 131 ; Cb10 = 131
|
89
|
-
|
90
87
|
# Shortcuts!
|
91
88
|
MiddleC = 84
|
92
89
|
|
data/misc/rake/packaging.rb
CHANGED
@@ -39,6 +39,8 @@ gemspec = Gem::Specification.new do |gem|
|
|
39
39
|
collect {|f| f.relative_path_from(BASE_DIR).to_s }
|
40
40
|
gem.test_files = SPEC_FILES.
|
41
41
|
collect {|f| f.relative_path_from(BASE_DIR).to_s }
|
42
|
+
|
43
|
+
gem.add_dependency 'Platform', [">= 0.4.0"]
|
42
44
|
end
|
43
45
|
|
44
46
|
Rake::GemPackageTask.new( gemspec ) do |task|
|
data/spec/interface_spec.rb
CHANGED
@@ -6,6 +6,10 @@
|
|
6
6
|
#
|
7
7
|
# * Ben Bleything <ben@bleything.net>
|
8
8
|
#
|
9
|
+
# == Contributors
|
10
|
+
#
|
11
|
+
# * Giles Bowkett
|
12
|
+
#
|
9
13
|
# == Copyright
|
10
14
|
#
|
11
15
|
# Copyright (c) 2008 Ben Bleything
|
@@ -25,39 +29,37 @@ describe MIDIator::Interface do
|
|
25
29
|
|
26
30
|
describe "auto-detects the correct driver for your platform" do
|
27
31
|
before( :all ) do
|
28
|
-
# remember
|
29
|
-
@ruby_platform =
|
32
|
+
# remember platform so we can reset it later
|
33
|
+
@ruby_platform = Platform::IMPL
|
30
34
|
|
31
|
-
|
32
|
-
|
33
|
-
$stderr.puts "*" * 72
|
35
|
+
# suppress warnings (http://www.ruby-forum.com/topic/127608)
|
36
|
+
$-v = nil
|
34
37
|
end
|
35
38
|
|
36
39
|
after( :all ) do
|
37
|
-
# reset
|
38
|
-
|
40
|
+
# reset platform to whatever is correct for our platform
|
41
|
+
Platform::IMPL = @ruby_platform
|
39
42
|
|
40
|
-
|
41
|
-
|
42
|
-
$stderr.puts "*" * 72
|
43
|
+
# restore warnings (http://www.ruby-forum.com/topic/127608)
|
44
|
+
$-v = false
|
43
45
|
end
|
44
46
|
|
45
47
|
it "selects WinMM for Windows" do
|
46
|
-
|
48
|
+
Platform::IMPL = :mswin
|
47
49
|
@interface.should_receive( :use ).with( :winmm )
|
48
50
|
|
49
51
|
@interface.autodetect_driver
|
50
52
|
end
|
51
53
|
|
52
54
|
it "selects CoreMIDI for OSX" do
|
53
|
-
|
55
|
+
Platform::IMPL = :macosx
|
54
56
|
@interface.should_receive( :use ).with( :core_midi )
|
55
57
|
|
56
58
|
@interface.autodetect_driver
|
57
59
|
end
|
58
60
|
|
59
61
|
it "selects ALSA for Linux" do
|
60
|
-
|
62
|
+
Platform::IMPL = :linux
|
61
63
|
@interface.should_receive( :use ).with( :alsa )
|
62
64
|
|
63
65
|
@interface.autodetect_driver
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midiator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Bleything
|
@@ -9,10 +9,19 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-10-
|
12
|
+
date: 2008-10-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: Platform
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.4.0
|
24
|
+
version:
|
16
25
|
description: MIDIator provides an OS-agnostic way to send live MIDI messages to your machine's MIDI playback system.
|
17
26
|
email: ben@bleything.net
|
18
27
|
executables: []
|