blob: 3e8a605396b329add3ea722a63833037dfc40e3f (
plain)
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
79
|
#!/bin/bash
## This script will print an asoundrc stream which add virtual boards from one physical board.
## Output must be directed into a file to be stored
### FUNCTIONS ###
user_manual() {
echo "Required Parameters
1. Phy board id like "hw:CARD=Alp882e,DEV=0"
2. Phy board channels quantity
3. Virtual boards base name like : \"Emulated analog Alp222\"
4. Virtual boards channels quantities (2: stéréo, ...)" >&2
}
build_phy_node() {
node_type=$1
card_id=$2
channels_qty=$3
echo -e "pcm_slave.$node_type { \n pcm \"$card_id\"\n channels $channels_qty\n }\n"
}
build_virtual_node() {
node_alias=$1
node_type=$2
node_id=$3
ipc_key=$4
phy_name=$5
phy_channels_base=$6
phy_channels_qty=$7
description=$8
direction=$9
echo -e "pcm.$node_alias$node_id {
type $node_type
ipc_key $ipc_key
ipc_key_add_uid true
slave $phy_name"
for channel_id in $(seq 0 "$(($phy_channels_qty-1))")
do
echo -e "\tbindings.$channel_id $(($channel_id+$phy_channels_base))"
done
echo -e "\thint.description" \"$description \#$node_id $direction\"
echo -e "}\n"
}
### MAIN ###
[ "$#" -ne "4" ] && user_manual && exit 1
ipc_key=$(date +%N)
card_id=$1
channels_qty=$2
virtual_basename=$3
stream_width=$4
virt_qty=$(($channels_qty / $stream_width))
echo "#Building Alsa sound RC file for $virt_qty virtual boards of $stream_width channels from physical board $card_id with $channels_qty."
##Build the entries first
build_phy_node "ins" "$card_id" "$channels_qty"
for entry_idx in $(seq 0 $(($virt_qty-1)))
do
build_virtual_node "mic" "dsnoop" "$entry_idx" "$ipc_key" "ins" "$(($stream_width * $entry_idx))" "$stream_width" "virtual Alp-$stream_width" "in"
done
##Now the outpus
build_phy_node "outs" "$card_id" "$channels_qty"
ipc_key=$(date +%N)
for entry_idx in $(seq 0 $(($virt_qty-1)))
do
build_virtual_node "out" "dshare" "$entry_idx" "$ipc_key" "outs" "$(($stream_width * $entry_idx))" "$stream_width" "virtual Alp-$stream_width" "out"
done
|