#!/bin/bash

# Example of relay between Sonobus groups.
# Joins relay_src_group as relay_src_nick
# Repeats relay_src_target
# as relay_dest_nick on relay_dest_group.

# this version re-encodes all content so channels and bitrate can be changed.
# Also shows usage of a sox effect to reduce volume.

relay_src_group=group1
relay_src_nick=nick1
relay_src_target=target
relay_dest_group=group2
relay_dest_nick=nick2
relay_src_channels=2
relay_dest_channels=1
relay_dest_bitrate=48

sb-rec -c $relay_src_channels -n $relay_src_nick \
-N $relay_src_target -g $relay_src_group \
|sox -t raw -r 48000 -e s -b 16 -c $relay_src_channels - \
-t raw -e s -b 16 -c $relay_dest_channels - \
vol 0.7 \
|sb-send -b $relay_dest_bitrate -c $relay_dest_channels \
-a - -g $relay_dest_group -n $relay_dest_nick
