#!/bin/bash
#
#******************************************************************************
# recordpa
#------------------------------------------------------------------------------
##
# \file           recordpa
# \library        Any project
# \author         Chris Ahlstrom
# \date           2022-09-14
# \update         2022-09-24
# \version        $Revision$
# \license        $XPC_SUITE_GPL_LICENSE$
#
#     The above is modified by the following to remove even the mild GPL
#     restrictions:
#
#     Use this script in any manner whatsoever.  You don't even need to give
#     me any credit.  However, keep in mind the value of the GPL in keeping
#     software and its descendant modifications available to the community
#     for all time.
#
#     Simply records the output of our USB audio device as received through
#     PulseAudio.
#
#     parecord is equivalent to "pacat -r --file-format".  Refer to the pacat(1)
#     man page for pacat's flags. To get the sources for audio record.
#
#     $ pactl list sources short
#
#      The following two lines produce the same result.
#
#      $ parecord -d alsa_input.pci-0000_00_1f.3.analog-stereo speech.flac
#      $ parecord -d 1 speech.flac
#
#------------------------------------------------------------------------------

if [ "$1" == "--list" ] ; then
   pactl list sources short
elif [ "$1" == "--help" ] ; then
   cat << E_O_F
Usage:
   recordpa --help
   recordpa --list
   recordpa x.wav
   record <device ID or name> x.wav
E_O_F
elif [ "$2" == "" ] ; then
   parecord --channels=1 --record --device=alsa_output.usb-Burr-Brown_from_TI_USB_Audio_CODEC-00.analog-stereo.monitor $1
else
   parecord --channels=1 --record --device=$1 $2
fi

#******************************************************************************
# recordpa
#------------------------------------------------------------------------------
# vim: ts=3 sw=3 et ft=sh
#------------------------------------------------------------------------------
