Sha256: 87d606e687e175bf417c58721c95d502f6b910b803e84fdb08fa72cd67e62335

Contents?: true

Size: 836 Bytes

Versions: 1

Compression:

Stored size: 836 Bytes

Contents

require 'rawmidi/api'
require 'rawmidi/input'
require 'rawmidi/output'

module RawMIDI
  class Card
    attr_reader :id, :name

    def self.all
      API::Card.each_id.map { |id| new(id) }
    end

    def initialize(id)
      @id = id
      @name = API::Card.get_name(id)
    end

    def handle_name
      "hw:#{@id}"
    end

    def inputs
      API::Device.each(@id).select { |_, info| info[:input] }.map do |id, info|
        Input.new(self, id, name: info[:name])
      end
    end

    def outputs
      API::Device.each(@id).select { |_, info| info[:output] }.map do |id, info|
        Output.new(self, id, name: info[:name])
      end
    end

    def longname
      API::Card.get_longname(@id)
    end

    def inspect
      "#<#{self.class.name}:#{"0x%014x" % object_id} #{handle_name} #{@name.inspect}>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rawmidi-0.1.0 lib/rawmidi/card.rb