Android Binaural player allows to write script files that present to the user a simple configuration menu. For example, the user may select amongst four proposed durations and three starting frequencies. Without dynamic configuration, it would require 4×3=12 different files.
To qualify as a dynamic script, the file must meet the following two conditions:
.sbgx
;#!/bin/sh
.The language used to write dynamic scripts is simply the Unix shell present on all Android devices.
The script is first called with no parameters, and is supposed to
print its configuration menu. The first line of output must be exactly
sbg_script_options
. Then the options, one per line, with
the syntax:
option label v1 v2 ...
The label and values must not contain spaces. The default value can be
set by prefixing it with *
; remember it needs to be
escaped as a shell special character.
When the user has chosen the options, the script is called a second
time, with the options values as parameters, and is supposed to print
the actual SBaGen script. The first line must be exactly
-SE
.
Example: The following script lets the user choose the duration and five beat frequencies. It also illustrate how to format timestamps.
#!/bin/sh if [ $# = 0 ]; then echo sbg_script_options echo option Duration 10 \*20 30 40 60 echo option Frequency_1 20 \*13.5 7.5 6.6 5.5 echo option Frequency_2 \*5.5 4.5 3.5 2.5 0.5 echo option Frequency_3 4.5 \*3.5 2.5 1.5 0.5 echo option Frequency_4 4.5 3.5 \*2.5 1.5 0.5 echo option Frequency_5 4.5 3.5 2.5 \*1.5 0.5 exit fi tline() { local t=$1; shift local h=$((t/3600)) local m=$(((t/60)%60+100)); m=${m#1} local s=$((t%60+100)); s=${s#1} local ts="+$h:$m:$s" [ "$t" = 0 ] && ts=NOW echo "$ts $*" } dur=$1 fa=$2 fb=$3 fc=$4 fd=$5 fe=$6 d=$((12*dur)) echo -SE echo "b_a1_b0: 360+$fa/5 540+$fb/0" echo "b_a0_b1: 360+$fa/0 540+$fb/5" echo "b_c0_b1: 360+$fc/0 540+$fb/5" echo "b_c1_b0: 360+$fc/5 540+$fb/0" echo "b_c1_d0: 360+$fc/5 540+$fd/0" echo "b_c0_d1: 360+$fc/0 540+$fd/5" echo "b_e0_d1: 360+$fe/0 540+$fd/5" echo "b_e1_d0: 360+$fe/5 540+$fd/0" echo "off: -" tline 0 "b_a1_b0 ->" tline $((1*d-30)) "b_a1_b0 ->" tline $((1*d+30)) "b_a0_b1 ->" tline $((2*d-30)) "b_c0_b1 ->" tline $((2*d+30)) "b_c1_b0 ->" tline $((3*d-30)) "b_c1_d0 ->" tline $((3*d+30)) "b_c0_d1 ->" tline $((4*d-30)) "b_e0_d1 ->" tline $((4*d+30)) "b_e1_d0 ->" tline $((5*d-30)) "b_e1_d0 ->" tline $((5*d-00)) "off"