Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overhaul #23

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/unimidi
Expand Up @@ -7,4 +7,4 @@ opts = ARGV.length > 1 ? ARGV.slice(1, ARGV.length-1) : {}

raise "No command specified" if ARGV.first.nil?

UniMIDI.command(ARGV.first.to_sym, opts)
UniMIDI::CommandLine.execute(ARGV.first.to_sym, opts)
24 changes: 5 additions & 19 deletions lib/unimidi.rb
@@ -1,34 +1,20 @@
# A realtime MIDI interface for Ruby
# (c)2010-2013 Ari Russo and licensed under the Apache 2.0 License
module UniMIDI

VERSION = "0.3.3"

end

# libs
require "forwardable"
require "singleton"

# modules
require "unimidi/command_line"
require "unimidi/congruous_api_adapter"
require "unimidi/type_conversion"

# classes
require "unimidi/platform"

module UniMIDI
extend(Platform.instance.interface)
include(Platform.instance.interface)

def self.command(command, options = {})
if [:l, :list, :list_devices].include?(command)
puts "input:"
Input.list
puts "output:"
Output.list
else
raise "Command #{command.to_s} not found"
end
end
VERSION = "0.3.3"

# load the appropriate platform
include(Platform.adapter_module)
end
6 changes: 3 additions & 3 deletions lib/unimidi/adapter/alsa-rawmidi.rb
Expand Up @@ -4,17 +4,17 @@ module UniMIDI

module AlsaRawMIDIAdapter

class Input < CongruousApiInput
class Input < CongruousApiAdapter::Input
defer_to AlsaRawMIDI::Input
device_class AlsaRawMIDI::Device
end

class Output < CongruousApiOutput
class Output < CongruousApiAdapter::Output
defer_to AlsaRawMIDI::Output
device_class AlsaRawMIDI::Device
end

class Device < CongruousApiDevice
class Device < CongruousApiAdapter::Device
defer_to AlsaRawMIDI::Device
input_class Input
output_class Output
Expand Down
38 changes: 18 additions & 20 deletions lib/unimidi/adapter/ffi-coremidi.rb
Expand Up @@ -3,32 +3,30 @@
module UniMIDI

module CoreMIDIAdapter

class Input < CongruousApiInput
defer_to CoreMIDI::Source
device_class CoreMIDI::Endpoint

CongruousApiAdapter::DeviceCache.source_key = { :input => :source, :output => :destination }

class Input
include CongruousApiAdapter::InputMethods

adapts CoreMIDI::Endpoint
end

class Output < CongruousApiOutput
defer_to CoreMIDI::Destination
device_class CoreMIDI::Endpoint
class Output
include CongruousApiAdapter::OutputMethods

adapts CoreMIDI::Endpoint

end

class Device < CongruousApiDevice
defer_to CoreMIDI::Endpoint

class Device
extend CongruousApiAdapter::DeviceMethods

input_class Input
output_class Output

def self.populate
klass = @deference[self].respond_to?(:all_by_type) ? @deference[self] : @device_class
@devices = {
:input => klass.all_by_type[:source].map { |d| @input_class.new(d) },
:output => klass.all_by_type[:destination].map { |d| @output_class.new(d) }
}
end


end

end

end
6 changes: 3 additions & 3 deletions lib/unimidi/adapter/midi-jruby.rb
Expand Up @@ -4,17 +4,17 @@ module UniMIDI

module MIDIJRubyAdapter

class Input < CongruousApiInput
class Input < CongruousApiAdapter::Input
defer_to MIDIJRuby::Input
device_class MIDIJRuby::Device
end

class Output < CongruousApiOutput
class Output < CongruousApiAdapter::Output
defer_to MIDIJRuby::Output
device_class MIDIJRuby::Device
end

class Device < CongruousApiDevice
class Device < CongruousApiAdapter::Device
defer_to MIDIJRuby::Device
input_class Input
output_class Output
Expand Down
6 changes: 3 additions & 3 deletions lib/unimidi/adapter/midi-winmm.rb
Expand Up @@ -4,17 +4,17 @@ module UniMIDI

module MIDIWinMMAdapter

class Input < CongruousApiInput
class Input < CongruousApiAdapter::Input
defer_to MIDIWinMM::Input
device_class MIDIWinMM::Device
end

class Output < CongruousApiOutput
class Output < CongruousApiAdapter::Output
defer_to MIDIWinMM::Output
device_class MIDIWinMM::Device
end

class Device < CongruousApiDevice
class Device < CongruousApiAdapter::Device
defer_to MIDIWinMM::Device
input_class Input
output_class Output
Expand Down
20 changes: 20 additions & 0 deletions lib/unimidi/command_line.rb
@@ -0,0 +1,20 @@
module UniMIDI

module CommandLine

extend self

def execute(command, options = {})
if [:l, :list, :list_devices].include?(command)
puts "input:"
Input.list
puts "output:"
Output.list
else
raise "Command #{command.to_s} not found"
end
end

end

end