mtk 0.0.3.1 → 0.0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/DEVELOPMENT_NOTES.md +3 -2
- data/README.md +2 -4
- data/lib/mtk/midi/unimidi_output.rb +53 -39
- metadata +1 -1
data/DEVELOPMENT_NOTES.md
CHANGED
@@ -81,10 +81,11 @@ You shouldn't need to worry about the dependencies too much. A Gemfile is provid
|
|
81
81
|
Documentation
|
82
82
|
-------------
|
83
83
|
|
84
|
-
|
84
|
+
Generate with:
|
85
85
|
|
86
|
-
|
86
|
+
bundle exec rake doc
|
87
87
|
|
88
|
+
Or view online @ http://rubydoc.info/github/adamjmurray/mtk/master/frames
|
88
89
|
|
89
90
|
|
90
91
|
Development Notes
|
data/README.md
CHANGED
@@ -19,8 +19,6 @@ Features
|
|
19
19
|
Getting Started
|
20
20
|
---------------
|
21
21
|
|
22
|
-
# NOTE: This project is not ready yet, these instructions will not work! Please check back in a little while once I have mtk version 0.0.3 released to rubygems.org.
|
23
|
-
|
24
22
|
MTK works with Ruby 1.9, Ruby 2.0, and JRuby
|
25
23
|
|
26
24
|
0. Install
|
@@ -35,11 +33,11 @@ MTK works with Ruby 1.9, Ruby 2.0, and JRuby
|
|
35
33
|
|
36
34
|
mtk --help
|
37
35
|
|
38
|
-
0. Learn the MTK syntax: TODO... documentation forthcoming. In the meantime, see the unit tests @ https://github.com/adamjmurray/mtk/blob/master/spec/mtk/lang/
|
36
|
+
0. Learn the MTK syntax: TODO... documentation forthcoming. In the meantime, see the unit tests @ https://github.com/adamjmurray/mtk/blob/master/spec/mtk/lang/parser_spec.rb
|
39
37
|
|
40
38
|
0. Check out examples: https://github.com/adamjmurray/mtk/tree/master/examples
|
41
39
|
|
42
|
-
0. Read the [MTK Ruby library documentation](http://
|
40
|
+
0. Read the [MTK Ruby library documentation](http://rubydoc.info/github/adamjmurray/mtk/master/frames)
|
43
41
|
|
44
42
|
|
45
43
|
About this project
|
@@ -66,56 +66,70 @@ end
|
|
66
66
|
# MONKEY PATCHING for https://github.com/arirusso/ffi-coremidi/pull/2
|
67
67
|
# This can be removed once that pull request is released.
|
68
68
|
|
69
|
-
|
70
|
-
|
71
|
-
class Device
|
72
|
-
def initialize(id, device_pointer, options = {})
|
73
|
-
include_if_offline = options[:include_offline] || false
|
74
|
-
@id = id
|
75
|
-
@resource = device_pointer
|
76
|
-
@entities = []
|
77
|
-
|
78
|
-
prop = Map::CF.CFStringCreateWithCString( nil, "name", 0 )
|
79
|
-
begin
|
80
|
-
name_ptr = FFI::MemoryPointer.new(:pointer)
|
81
|
-
Map::MIDIObjectGetStringProperty(@resource, prop, name_ptr)
|
82
|
-
name = name_ptr.read_pointer
|
83
|
-
len = Map::CF.CFStringGetMaximumSizeForEncoding(Map::CF.CFStringGetLength(name), :kCFStringEncodingUTF8)
|
84
|
-
bytes = FFI::MemoryPointer.new(len + 1)
|
85
|
-
raise RuntimeError.new("CFStringGetCString") unless Map::CF.CFStringGetCString(name, bytes, len, :kCFStringEncodingUTF8)
|
86
|
-
@name = bytes.read_string
|
87
|
-
ensure
|
88
|
-
Map::CF.CFRelease(name) unless name.nil? || name.null?
|
89
|
-
Map::CF.CFRelease(prop) unless prop.null?
|
90
|
-
end
|
91
|
-
populate_entities(:include_offline => include_if_offline)
|
92
|
-
end
|
69
|
+
if RbConfig::CONFIG['host_os'] =~ /darwin/
|
70
|
+
# We're running on OS X
|
93
71
|
|
72
|
+
begin
|
73
|
+
ffi_coremidi_exists = !CoreMIDI::Map::CF.nil?
|
74
|
+
rescue NameError
|
75
|
+
ffi_coremidi_exists = false
|
94
76
|
end
|
95
77
|
|
96
|
-
|
97
|
-
|
78
|
+
if ffi_coremidi_exists
|
79
|
+
|
80
|
+
# @private
|
81
|
+
module CoreMIDI
|
82
|
+
class Device
|
83
|
+
def initialize(id, device_pointer, options = {})
|
84
|
+
include_if_offline = options[:include_offline] || false
|
85
|
+
@id = id
|
86
|
+
@resource = device_pointer
|
87
|
+
@entities = []
|
88
|
+
|
89
|
+
prop = Map::CF.CFStringCreateWithCString( nil, "name", 0 )
|
90
|
+
begin
|
91
|
+
name_ptr = FFI::MemoryPointer.new(:pointer)
|
92
|
+
Map::MIDIObjectGetStringProperty(@resource, prop, name_ptr)
|
93
|
+
name = name_ptr.read_pointer
|
94
|
+
len = Map::CF.CFStringGetMaximumSizeForEncoding(Map::CF.CFStringGetLength(name), :kCFStringEncodingUTF8)
|
95
|
+
bytes = FFI::MemoryPointer.new(len + 1)
|
96
|
+
raise RuntimeError.new("CFStringGetCString") unless Map::CF.CFStringGetCString(name, bytes, len, :kCFStringEncodingUTF8)
|
97
|
+
@name = bytes.read_string
|
98
|
+
ensure
|
99
|
+
Map::CF.CFRelease(name) unless name.nil? || name.null?
|
100
|
+
Map::CF.CFRelease(prop) unless prop.null?
|
101
|
+
end
|
102
|
+
populate_entities(:include_offline => include_if_offline)
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
98
106
|
|
99
|
-
|
100
|
-
|
107
|
+
module Map
|
108
|
+
module CF
|
101
109
|
|
102
|
-
|
103
|
-
|
104
|
-
enum :CFStringEncoding, [ :kCFStringEncodingUTF8, 0x08000100 ]
|
110
|
+
extend FFI::Library
|
111
|
+
ffi_lib '/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/CoreFoundation'
|
105
112
|
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
attach_function :CFStringGetCStringPtr, [:pointer, :int], :pointer
|
113
|
+
typedef :pointer, :CFStringRef
|
114
|
+
typedef :long, :CFIndex
|
115
|
+
enum :CFStringEncoding, [ :kCFStringEncodingUTF8, 0x08000100 ]
|
110
116
|
|
111
|
-
|
117
|
+
# CFString* CFStringCreateWithCString( ?, CString, encoding)
|
118
|
+
attach_function :CFStringCreateWithCString, [:pointer, :string, :int], :pointer
|
119
|
+
# CString* CFStringGetCStringPtr(CFString*, encoding)
|
120
|
+
attach_function :CFStringGetCStringPtr, [:pointer, :int], :pointer
|
112
121
|
|
113
|
-
|
122
|
+
attach_function :CFStringGetLength, [ :CFStringRef ], :CFIndex
|
114
123
|
|
115
|
-
|
124
|
+
attach_function :CFStringGetMaximumSizeForEncoding, [ :CFIndex, :CFStringEncoding ], :long
|
116
125
|
|
117
|
-
|
126
|
+
attach_function :CFStringGetCString, [ :CFStringRef, :pointer, :CFIndex, :CFStringEncoding ], :bool
|
118
127
|
|
128
|
+
attach_function :CFRelease, [ :pointer ], :void
|
129
|
+
|
130
|
+
end
|
131
|
+
end
|
119
132
|
end
|
133
|
+
|
120
134
|
end
|
121
135
|
end
|