Class: Volay::Mixer::Alsa
Overview
Alsa class for playing with amixer
Constant Summary
collapse
- DEFAULT_VALUE =
2
Instance Method Summary
collapse
Methods inherited from Default
#max_value, #muted?, #percent, #value
Instance Method Details
#current ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/volay/mixer/alsa.rb', line 25
def current
result = command('get Master')
max_value = result.match(/ 0 - (\d+)/)[1].to_i
current_percent = result.match(/\[([0-9]+)%\]\s+\[o(?:n|ff)\]/)[1].to_i
current_value = ((current_percent * max_value) / 100).to_i
current_state = result.match(/\[([a-z]+)\]/)[1].to_s
{ value: current_value,
max_value: max_value,
percent: current_percent,
muted: current_state == 'on' ? false : true }
end
|
#down(value = DEFAULT_VALUE) ⇒ Object
13
14
15
|
# File 'lib/volay/mixer/alsa.rb', line 13
def down(value = DEFAULT_VALUE)
command("-q set Master #{value}%-")
end
|
#toggle ⇒ Object
21
22
23
|
# File 'lib/volay/mixer/alsa.rb', line 21
def toggle
command('-q set Master toggle')
end
|
#up(value = DEFAULT_VALUE) ⇒ Object
9
10
11
|
# File 'lib/volay/mixer/alsa.rb', line 9
def up(value = DEFAULT_VALUE)
command("-q set Master #{value}%+")
end
|
#value=(value) ⇒ Object
17
18
19
|
# File 'lib/volay/mixer/alsa.rb', line 17
def value=(value)
command("-q set Master #{value}%")
end
|