Class: JACK::Port

Inherits:
Object
  • Object
show all
Extended by:
FFI::Library
Defined in:
lib/jack/port.rb

Constant Summary collapse

FLAGS_IS_INPUT =
0x1
FLAGS_IS_OUTPUT =
0x2
FLAGS_IS_PHYSICAL =
0x4
FLAGS_CAN_MONITOR =
0x8
FLAGS_IS_TERMINAL =
0x10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pointer, client) ⇒ Port

Returns a new instance of Port.



31
32
33
# File 'lib/jack/port.rb', line 31

def initialize(pointer, client)
  @pointer, @client = pointer, client
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



23
24
25
# File 'lib/jack/port.rb', line 23

def client
  @client
end

#pointerObject (readonly)

Returns the value of attribute pointer.



23
24
25
# File 'lib/jack/port.rb', line 23

def pointer
  @pointer
end

Instance Method Details

#can_monitor?Boolean

Returns:

  • (Boolean)


69
70
71
# File 'lib/jack/port.rb', line 69

def can_monitor?
  flags & FLAGS_CAN_MONITOR != 0
end

#connect(destination) ⇒ Object

Raises:

  • (ArgumentError)


43
44
45
46
47
48
# File 'lib/jack/port.rb', line 43

def connect(destination)
  raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.connect" if not destination.is_a? Port and not destination.is_a? String
  destination = client.port_by_name(destination) if destination.is_a? String
  
  client.connect self, destination
end

#disconnect(destination) ⇒ Object

Raises:

  • (ArgumentError)


50
51
52
53
54
55
# File 'lib/jack/port.rb', line 50

def disconnect(destination)
  raise ArgumentError, "You must pass JACK::Port or String to JACK::Port.disconnect" if not destination.is_a? Port and not destination.is_a? String
  destination = client.port_by_name(destination) if destination.is_a? String
  
  client.disconnect self, destination
end

#flagsObject



39
40
41
# File 'lib/jack/port.rb', line 39

def flags
  jack_port_flags @pointer
end

#inspectObject



81
82
83
# File 'lib/jack/port.rb', line 81

def inspect
  "#<#{self.class} name=#{name}>"
end

#is_input?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/jack/port.rb', line 57

def is_input?
  flags & FLAGS_IS_INPUT != 0
end

#is_output?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/jack/port.rb', line 61

def is_output?
  flags & FLAGS_IS_OUTPUT != 0
end

#is_physical?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/jack/port.rb', line 65

def is_physical?
  flags & FLAGS_IS_PHYSICAL != 0
end

#is_terminal?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/jack/port.rb', line 73

def is_terminal?
  flags & FLAGS_IS_TERMINAL != 0
end

#nameObject



35
36
37
# File 'lib/jack/port.rb', line 35

def name
  jack_port_name @pointer
end

#to_sObject



77
78
79
# File 'lib/jack/port.rb', line 77

def to_s
  name
end