diff --git a/CMakeLists.txt b/CMakeLists.txt index c8b1f9e..5dd71fd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,7 @@ set(script_files scripts/termux-api-start scripts/termux-api-stop scripts/termux-audio-info + scripts/termux-audio-sco scripts/termux-battery-status scripts/termux-brightness scripts/termux-call-log diff --git a/scripts/termux-audio-sco.in b/scripts/termux-audio-sco.in new file mode 100644 index 0000000..93f3f43 --- /dev/null +++ b/scripts/termux-audio-sco.in @@ -0,0 +1,49 @@ +#!@TERMUX_PREFIX@/bin/bash +set -e -u + +SCRIPTNAME=termux-audio-sco + +show_usage () { + echo "Usage: $SCRIPTNAME [command]" + echo "Manage Bluetooth SCO audio channel for microphone capture." + echo + echo "Commands:" + echo " enable Activate SCO channel and switch to IN_COMMUNICATION mode" + echo " disable Deactivate SCO channel and restore audio mode" + echo " (none) Show current SCO state as JSON" + echo + echo "After 'enable', use termux-microphone-record -s 7 to record from Bluetooth microphone." + echo "Note: SCO audio quality is limited to 8-16 kHz (telephone quality)." + exit 0 +} + +while getopts :h option +do + case "$option" in + h) show_usage;; + ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; + esac +done +shift $((OPTIND-1)) + +if [ $# -gt 1 ]; then + echo "$SCRIPTNAME: too many arguments" + exit 1 +fi + +COMMAND="${1:-}" + +case "$COMMAND" in + enable|disable|"") + if [ -n "$COMMAND" ]; then + @TERMUX_PREFIX@/libexec/termux-api AudioSco --es command "$COMMAND" + else + @TERMUX_PREFIX@/libexec/termux-api AudioSco + fi + ;; + *) + echo "$SCRIPTNAME: unknown command '$COMMAND'" + echo "Valid commands: enable, disable (or no argument for status)" + exit 1 + ;; +esac diff --git a/scripts/termux-microphone-record.in b/scripts/termux-microphone-record.in index 2cb7b39..2558f2a 100644 --- a/scripts/termux-microphone-record.in +++ b/scripts/termux-microphone-record.in @@ -15,6 +15,10 @@ show_usage () { echo "-b Start recording w/ specified bitrate (in kbps)" echo "-r Start recording w/ specified sampling rate (in Hz)" echo "-c Start recording w/ specified channel count (1, 2, ...)" + echo "-s Start recording w/ specified audio source (integer constant):" + echo " 0=DEFAULT 1=MIC (default) 5=CAMCORDER" + echo " 6=VOICE_RECOGNITION 7=VOICE_COMMUNICATION (Bluetooth SCO)" + echo " 9=UNPROCESSED 10=VOICE_PERFORMANCE" echo "-i Get info about current recording" echo "-q Quits recording" } @@ -42,7 +46,7 @@ call_api () { @TERMUX_PREFIX@/libexec/termux-api MicRecorder "$@" } -while getopts h,f:,l:,e:,b:,r:,c:,d,i,q option +while getopts h,f:,l:,e:,b:,r:,c:,s:,d,i,q option do case "$option" in h) sole "$@" @@ -72,6 +76,9 @@ do c) record=yes add_params --ei channels $((OPTARG)) ;; + s) record=yes + add_params --ei source $((OPTARG)) + ;; i) sole "$@" add_params -a info ;;