midi-events 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +1 -6
- data/README.md +19 -18
- data/Rakefile +3 -0
- data/lib/midi-events/constant.rb +27 -45
- data/lib/midi-events.rb +1 -1
- data/midi-events.gemspec +6 -2
- metadata +63 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82ba2c51e9befc6c456bcb3d16a467a89d10b9d4e4c85331fbf2b6194f41abc9
|
4
|
+
data.tar.gz: 0a5f5e2ee32d85f5dba7e0bd3039502ab763259fa36f8f740f5927dc0cfb1ef1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7ab224cfdbd77e43bf886808f21283b249f36821f3fd5e84d54f44bd77ebf02a5afe804b02f9e196c3eadc2f6112d64fe23b6b34fbea389c185b414ef0c5ea0
|
7
|
+
data.tar.gz: 6d844c549b9dbcfa1132f050748e4dbf7972ed9152a1c1d72126af537c7fcd344918c811b4f4ffb2f3a15ec27298c987fe8a381531fdeb18ba5ce4739ef376fc
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -114,32 +114,33 @@ One way or another, you will wind up with a pair of objects like this:
|
|
114
114
|
|
115
115
|
## Then, why does exist this library if it is mostly a clone of another library?
|
116
116
|
|
117
|
-
The author has been developing since 2016 a Ruby project called
|
118
|
-
[Musa DSL](https://github.com/javier-sy/musa-dsl) that needs a way
|
119
|
-
of representing MIDI Events and a way of communicating with
|
117
|
+
The author has been developing since 2016 a Ruby project called
|
118
|
+
[Musa DSL](https://github.com/javier-sy/musa-dsl) that needs a way
|
119
|
+
of representing MIDI Events and a way of communicating with
|
120
120
|
MIDI Instruments and MIDI Control Surfaces.
|
121
121
|
|
122
|
-
[Ari Russo](https://github.com/arirusso) has done a great job creating
|
123
|
-
several interdependent Ruby libraries that allow
|
124
|
-
MIDI Events representation ([MIDI Message](https://github.com/arirusso/midi-message)
|
125
|
-
and [Nibbler](https://github.com/arirusso/nibbler))
|
126
|
-
and communication with MIDI Instruments and MIDI Control Surfaces
|
127
|
-
([unimidi](https://github.com/arirusso/unimidi),
|
128
|
-
[ffi-coremidi](https://github.com/arirusso/ffi-coremidi) and others)
|
122
|
+
[Ari Russo](https://github.com/arirusso) has done a great job creating
|
123
|
+
several interdependent Ruby libraries that allow
|
124
|
+
MIDI Events representation ([MIDI Message](https://github.com/arirusso/midi-message)
|
125
|
+
and [Nibbler](https://github.com/arirusso/nibbler))
|
126
|
+
and communication with MIDI Instruments and MIDI Control Surfaces
|
127
|
+
([unimidi](https://github.com/arirusso/unimidi),
|
128
|
+
[ffi-coremidi](https://github.com/arirusso/ffi-coremidi) and others)
|
129
129
|
that, **with some modifications**, I've been using in MusaDSL.
|
130
130
|
|
131
|
-
After thinking about the best approach to publish MusaDSL
|
131
|
+
After thinking about the best approach to publish MusaDSL
|
132
132
|
I've decided to publish my own renamed version of the modified dependencies because:
|
133
133
|
|
134
|
+
* The original libraries have features
|
135
|
+
(buffering, very detailed logging and processing history information, not locking behaviour when waiting input midi messages)
|
136
|
+
that are not needed in MusaDSL and, in fact,
|
137
|
+
can degrade the performance on some use cases in MusaDSL.
|
138
|
+
* The requirements for **Musa DSL** users probably will evolve in time, so it will be easier to maintain an independent source code base.
|
134
139
|
* Some differences on the approach of the modifications vs the original library doesn't allow to merge the modifications on the original libraries.
|
135
140
|
* Then the renaming of the libraries is needed to avoid confusing existent users of the original libraries.
|
136
|
-
* Due to some of the interdependencies of Ari Russo libraries,
|
141
|
+
* Due to some of the interdependencies of Ari Russo libraries,
|
137
142
|
the modification and renaming on some of the low level libraries (ffi-coremidi, etc.)
|
138
143
|
forces to modify and rename unimidi library.
|
139
|
-
* The original libraries have features
|
140
|
-
(very detailed logging and processing history information, not locking behaviour when waiting input midi messages)
|
141
|
-
that are not needed in MusaDSL and, in fact,
|
142
|
-
can degrade the performance on some use case scenarios in MusaDSL.
|
143
144
|
|
144
145
|
All in all I have decided to publish a suite of libraries optimized for MusaDSL use case that also can be used by other people in their projects.
|
145
146
|
|
@@ -147,8 +148,8 @@ All in all I have decided to publish a suite of libraries optimized for MusaDSL
|
|
147
148
|
| --- | --- | --- | --- |
|
148
149
|
| MIDI Events representation | [MIDI Events](https://github.com/javier-sy/midi-events) | [MIDI Message](https://github.com/arirusso/midi-message) | removed parsing, small improvements |
|
149
150
|
| MIDI Data parsing | [MIDI Parser](https://github.com/javier-sy/midi-parser) | [Nibbler](https://github.com/arirusso/nibbler) | removed process history information, minor optimizations |
|
150
|
-
| MIDI communication with Instruments and Control Surfaces | [MIDI Communications](https://github.com/javier-sy/midi-communications) | [unimidi](https://github.com/arirusso/unimidi) | use of [MIDI Communications MacOS Layer](https://github.com/javier-sy/midi-communications-macos)
|
151
|
-
| Low level MIDI interface to MacOS | [MIDI Communications MacOS Layer](https://github.com/javier-sy/midi-communications-macos) | [ffi-coremidi](https://github.com/arirusso/ffi-coremidi) | removed process history information, locking behaviour when waiting midi events, improved midi devices name detection, minor optimizations |
|
151
|
+
| MIDI communication with Instruments and Control Surfaces | [MIDI Communications](https://github.com/javier-sy/midi-communications) | [unimidi](https://github.com/arirusso/unimidi) | use of [MIDI Communications MacOS Layer](https://github.com/javier-sy/midi-communications-macos, removed process history information, removed buffering, removed command line script)
|
152
|
+
| Low level MIDI interface to MacOS | [MIDI Communications MacOS Layer](https://github.com/javier-sy/midi-communications-macos) | [ffi-coremidi](https://github.com/arirusso/ffi-coremidi) | removed buffering and process history information, locking behaviour when waiting midi events, improved midi devices name detection, minor optimizations |
|
152
153
|
| Low level MIDI interface to Linux | **TO DO** | | |
|
153
154
|
| Low level MIDI interface to JRuby | **TO DO** | | |
|
154
155
|
| Low level MIDI interface to Windows | **TO DO** | | |
|
data/Rakefile
CHANGED
data/lib/midi-events/constant.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
module MIDIEvents
|
2
|
-
|
3
2
|
# Refer to a MIDI message by its usage
|
4
3
|
# eg *C4* for MIDI note *60* or *Bank Select* for MIDI control change *0*
|
5
4
|
module Constant
|
6
|
-
|
7
5
|
# Get a Mapping object for the specified constant
|
8
6
|
# @param [Symbol, String] group_name
|
9
7
|
# @param [String] const_name
|
@@ -23,14 +21,13 @@ module MIDIEvents
|
|
23
21
|
end
|
24
22
|
|
25
23
|
module Name
|
26
|
-
|
27
24
|
extend self
|
28
25
|
|
29
26
|
# eg "Control Change" -> "control_change"
|
30
27
|
# @param [Symbol, String] string
|
31
28
|
# @return [String]
|
32
29
|
def underscore(string)
|
33
|
-
string.to_s.downcase.gsub(/(\ )+/,
|
30
|
+
string.to_s.downcase.gsub(/(\ )+/, '_')
|
34
31
|
end
|
35
32
|
|
36
33
|
# @param [Symbol, String] key
|
@@ -40,12 +37,10 @@ module MIDIEvents
|
|
40
37
|
match_key = key.to_s.downcase
|
41
38
|
[match_key, Name.underscore(match_key)].include?(other.to_s.downcase)
|
42
39
|
end
|
43
|
-
|
44
40
|
end
|
45
41
|
|
46
42
|
# MIDI Constant container
|
47
43
|
class Group
|
48
|
-
|
49
44
|
attr_reader :constants, :key
|
50
45
|
|
51
46
|
# @param [String] key
|
@@ -70,7 +65,6 @@ module MIDIEvents
|
|
70
65
|
end
|
71
66
|
|
72
67
|
class << self
|
73
|
-
|
74
68
|
# All constant groups
|
75
69
|
# @return [Array<ConstantGroup>]
|
76
70
|
def all
|
@@ -85,7 +79,7 @@ module MIDIEvents
|
|
85
79
|
ensure_initialized
|
86
80
|
@groups.find { |group| Name.match?(group.key, key) }
|
87
81
|
end
|
88
|
-
|
82
|
+
alias [] find
|
89
83
|
|
90
84
|
private
|
91
85
|
|
@@ -98,21 +92,21 @@ module MIDIEvents
|
|
98
92
|
# Populate the dictionary of constants
|
99
93
|
# @return [Boolean]
|
100
94
|
def populate_dictionary
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
95
|
+
return unless @dict.nil?
|
96
|
+
|
97
|
+
file = File.expand_path('../midi.yml', __dir__)
|
98
|
+
@dict = YAML.load_file(file)
|
99
|
+
@dict.freeze
|
100
|
+
true
|
107
101
|
end
|
108
102
|
|
109
103
|
# Populate the constant groups using the dictionary
|
110
104
|
# @return [Boolean]
|
111
105
|
def populate_groups
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
106
|
+
return unless @groups.nil? && !@dict.nil?
|
107
|
+
|
108
|
+
@groups = @dict.map { |k, v| new(k, v) }
|
109
|
+
true
|
116
110
|
end
|
117
111
|
|
118
112
|
end
|
@@ -121,7 +115,6 @@ module MIDIEvents
|
|
121
115
|
|
122
116
|
# The mapping of a constant key to its value eg "Note On" => 0x9
|
123
117
|
class Map
|
124
|
-
|
125
118
|
attr_reader :key, :value
|
126
119
|
|
127
120
|
# @param [String] key
|
@@ -130,11 +123,9 @@ module MIDIEvents
|
|
130
123
|
@key = key
|
131
124
|
@value = value
|
132
125
|
end
|
133
|
-
|
134
126
|
end
|
135
127
|
|
136
128
|
class MessageBuilder
|
137
|
-
|
138
129
|
# @param [MIDIEvents] klass The message class to build
|
139
130
|
# @param [MIDIEvents::Constant::Map] const The constant to build the message with
|
140
131
|
def initialize(klass, const)
|
@@ -146,31 +137,27 @@ module MIDIEvents
|
|
146
137
|
# @return [Message]
|
147
138
|
def new(*args)
|
148
139
|
args = args.dup
|
149
|
-
args.last.
|
140
|
+
args.last.is_a?(Hash) ? args.last[:const] = @const : args.push(const: @const)
|
150
141
|
@klass.new(*args)
|
151
142
|
end
|
152
|
-
|
153
143
|
end
|
154
144
|
|
155
145
|
# Shortcuts for dealing with message status
|
156
146
|
module Status
|
157
|
-
|
158
147
|
extend self
|
159
148
|
|
160
149
|
# The value of the Status constant with the name status_name
|
161
150
|
# @param [String] status_name The key to use to look up a constant value
|
162
151
|
# @return [String] The constant value that was looked up
|
163
152
|
def find(status_name)
|
164
|
-
const = Constant.find(
|
165
|
-
const
|
153
|
+
const = Constant.find('Status', status_name)
|
154
|
+
const&.value
|
166
155
|
end
|
167
|
-
|
168
|
-
|
156
|
+
alias [] find
|
169
157
|
end
|
170
158
|
|
171
159
|
# Loading constants from the spec file into messages
|
172
160
|
module Loader
|
173
|
-
|
174
161
|
extend self
|
175
162
|
|
176
163
|
# Get the index of the constant from the given message's type
|
@@ -194,9 +181,9 @@ module MIDIEvents
|
|
194
181
|
unless group.nil?
|
195
182
|
unless (const = group.find_by_value(value)).nil?
|
196
183
|
{
|
197
|
-
:
|
198
|
-
:
|
199
|
-
:
|
184
|
+
const: const,
|
185
|
+
name: const.key,
|
186
|
+
verbose_name: "#{message.class.display_name}: #{const.key}"
|
200
187
|
}
|
201
188
|
end
|
202
189
|
end
|
@@ -204,31 +191,30 @@ module MIDIEvents
|
|
204
191
|
|
205
192
|
# DSL type class methods for loading constants into messages
|
206
193
|
module DSL
|
207
|
-
|
208
194
|
# Find a constant value in this class's group for the passed in key
|
209
195
|
# @param [String] name The constant key
|
210
196
|
# @return [String] The constant value
|
211
197
|
def get_constant(name)
|
212
198
|
key = constant_name || display_name
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
199
|
+
return if key.nil?
|
200
|
+
|
201
|
+
group = Group[key]
|
202
|
+
group.find(name)
|
217
203
|
end
|
218
204
|
|
219
205
|
# @return [String]
|
220
206
|
def display_name
|
221
|
-
const_get(
|
207
|
+
const_get('DISPLAY_NAME') if const_defined?('DISPLAY_NAME')
|
222
208
|
end
|
223
209
|
|
224
210
|
# @return [Hash]
|
225
211
|
def constant_map
|
226
|
-
const_get(
|
212
|
+
const_get('CONSTANT') if const_defined?('CONSTANT')
|
227
213
|
end
|
228
214
|
|
229
215
|
# @return [String]
|
230
216
|
def constant_name
|
231
|
-
constant_map
|
217
|
+
constant_map&.keys&.first
|
232
218
|
end
|
233
219
|
|
234
220
|
# @return [Symbol]
|
@@ -249,12 +235,8 @@ module MIDIEvents
|
|
249
235
|
const = get_constant(const_name.to_s)
|
250
236
|
MessageBuilder.new(self, const) unless const.nil?
|
251
237
|
end
|
252
|
-
|
253
|
-
|
238
|
+
alias [] find
|
254
239
|
end
|
255
|
-
|
256
240
|
end
|
257
|
-
|
258
241
|
end
|
259
|
-
|
260
242
|
end
|
data/lib/midi-events.rb
CHANGED
data/midi-events.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'midi-events'
|
3
|
-
s.version = '0.5.
|
4
|
-
s.date = '2021-11-
|
3
|
+
s.version = '0.5.1'
|
4
|
+
s.date = '2021-11-19'
|
5
5
|
s.summary = 'A Ruby simple library for creating MIDI Event Messages'
|
6
6
|
s.description = 'MIDI Events is a library for creating MIDI Event Messages that can be sent to MIDI Instruments through other libraries such as midi-communications or unimidi'
|
7
7
|
s.authors = ['Javier Sánchez Yeste']
|
@@ -19,4 +19,8 @@ Gem::Specification.new do |s|
|
|
19
19
|
# "documentation_uri" => "",
|
20
20
|
# "changelog_uri" => ""
|
21
21
|
#}
|
22
|
+
|
23
|
+
s.add_development_dependency 'minitest', '~> 5.14', '>= 5.14.4'
|
24
|
+
s.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
|
25
|
+
s.add_development_dependency 'shoulda-context', '~> 2.0', '>= 2.0.0'
|
22
26
|
end
|
metadata
CHANGED
@@ -1,15 +1,75 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: midi-events
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javier Sánchez Yeste
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-11-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: minitest
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '5.14'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 5.14.4
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '5.14'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 5.14.4
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '13.0'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 13.0.6
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '13.0'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 13.0.6
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: shoulda-context
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '2.0'
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 2.0.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2.0'
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.0.0
|
13
73
|
description: MIDI Events is a library for creating MIDI Event Messages that can be
|
14
74
|
sent to MIDI Instruments through other libraries such as midi-communications or
|
15
75
|
unimidi
|