Class: ATEM::Switcher::Input::Audio

Inherits:
Object
  • Object
show all
Defined in:
lib/atem/switcher/input/audio.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(switcher, input) ⇒ Audio



20
21
22
23
24
25
26
# File 'lib/atem/switcher/input/audio.rb', line 20

def initialize switcher, input 

  @switcher = switcher
  @input = input
  @level = 0

end

Instance Attribute Details

#balanceObject (readonly)

Returns the value of attribute balance.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def balance
  @balance
end

#gainObject (readonly)

Returns the value of attribute gain.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def gain
  @gain
end

#idObject (readonly)

Returns the value of attribute id.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def id
  @id
end

#inputObject (readonly)

Returns the value of attribute input.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def input
  @input
end

#levelsObject

Returns the value of attribute levels.



10
11
12
# File 'lib/atem/switcher/input/audio.rb', line 10

def levels
  @levels
end

#media_playerObject (readonly)

Returns the value of attribute media_player.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def media_player
  @media_player
end

#mixObject (readonly)

Returns the value of attribute mix.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def mix
  @mix
end

#plugObject (readonly)

Returns the value of attribute plug.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def plug
  @plug
end

#switcherObject (readonly)

Returns the value of attribute switcher.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def switcher
  @switcher
end

#typeObject (readonly)

Returns the value of attribute type.



9
10
11
# File 'lib/atem/switcher/input/audio.rb', line 9

def type
  @type
end

Class Method Details

.from(packet, switcher, input) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/atem/switcher/input/audio.rb', line 12

def self.from packet, switcher, input

  audio = self.new switcher, input
  audio.init_from packet
  audio

end

Instance Method Details

#init_from(packet) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/atem/switcher/input/audio.rb', line 28

def init_from packet 

  @id, @type, @media_player, @plug, @mix, @gain, @balance =
    packet.unpack("S>CxxxCCCxS>s>")

  # Now we have the right data, we can name the input itself
  if @input.quick_init

    values = {
      1001 => ['XLR', 'XLR0'],
      1101 => ['AES/EBU', 'AES3'],
      1201 => ['RCA', 'RCA_'],
    }
    @input.init @input.id, values[@input.id][0], values[@input.id][1]

  end

end

#levelObject



49
50
51
# File 'lib/atem/switcher/input/audio.rb', line 49

def level
  (@levels[:left] + @levels[:right]) / 2
end