File: mixertest1.py

package info (click to toggle)
python-pyalsa 1.2.12-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 496 kB
  • sloc: ansic: 5,616; python: 1,260; makefile: 4
file content (78 lines) | stat: -rwxr-xr-x 2,645 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- Python -*-

import sys
sys.path.insert(0, '..')
del sys
from alsamemdebug import debuginit, debug, debugdone
from pyalsa import alsamixer

def print_elem(e):
	direction = ["playback", "capture"]

	print("Mixer Element '%s:%i':" % (e.name, e.index))
	print('  is_active: %s' % e.is_active)
	print('  is_enumerated: %s' % e.is_enumerated)
	print('  has_common_volume: %s' % e.has_common_volume)
	print('  has_common_switch: %s' % e.has_common_switch)
	print('  has_capture_switch_exclusive: %s' % e.has_capture_switch_exclusive)
	if e.has_switch(True):
		print('  getCaptureGroup: %s' % e.get_capture_group)
	for capture in [False, True]:
		print('  is_%s_mono: %s' % (direction[capture], e.is_mono(capture)))
		print('  has_%s_volume: %s' % (direction[capture], e.has_volume(capture)))
		if e.has_volume(capture):
			print('  get_%s_volume_range: %s' % (direction[capture], e.get_volume_range(capture)))
			print('  get_%s_volume_range_dB: %s' % (direction[capture], e.get_volume_range_dB(capture)))
			print('  get_%s_volume_tuple: %s' % (direction[capture], e.get_volume_tuple(capture)))
			print('  get_%s_volume_array: %s' % (direction[capture], e.get_volume_array(capture)))
			vrange = e.get_volume_range(capture)
			if vrange:
				for vol in range(vrange[0], vrange[1]+1):
					print('    vol %i == %idB' % (vol, e.ask_volume_dB(vol, capture)))
			dbrange = e.get_volume_range_dB(capture)
			if dbrange:
				for vol in range(dbrange[0], dbrange[1]+1):
					print('    dBvol %i == %i' % (vol, e.ask_dB_volume(vol, -1, capture)))
		print('  has_%s_switch: %s' % (direction[capture], e.has_switch(capture)))
		if e.has_switch(capture):
			print('  get_%s_switch_tuple: %s' % (direction[capture], e.get_switch_tuple(capture)))
		for channel in range(alsamixer.channel_id['LAST']+1):
			if e.has_channel(channel, capture):
				print( '  has_%s_channel%s: %s' % (direction[capture], channel, alsamixer.channel_name[channel]))

debuginit()

print('channel_id:')
print(alsamixer.channel_id)

print('channel_name:')
print(alsamixer.channel_name)

print('regopt_abstracts:')
print(alsamixer.regopt_abstract)

print('event_mask:')
print(alsamixer.event_mask)

print('event_mask_remove:', alsamixer.event_mask_remove)

mixer = alsamixer.Mixer()
mixer.attach()
mixer.load()
print('Element Count:', mixer.count)
print('Elements:')
print(mixer.list())
element = alsamixer.Element(mixer, "PCM")
element.set_volume_array([128, 128])
print_elem(element)
element.set_volume_tuple([127, 127])
print_elem(element)
print_elem(alsamixer.Element(mixer, "Off-hook"))

debug([element])
del element
debug([mixer])
del mixer

debugdone()