#!/bin/sh

#
# (note) wavetable base freq is 21.53Hz (44100/2048), ~F-0 (oct -2)
#

IFS=§

function Usage {
  echo "Usage: ./wavetable.sh <path_to_wav_recording> <output_prefix> [<extra sxt args>..]"
  exit
}

if [ -z "$1" ]; then
  Usage
fi

if [ -z "$2" ]; then
  Usage
fi

SAMPLE_NAME="$1"
OUTPUT_NAME="$2"

echo "OUTPUT_NAME=${OUTPUT_NAME}";

shift
shift

OW_ARG1=
OW_ARG2=

if [ -d "`dirname ${OUTPUT_NAME}`/samples" ]; then
  OW_ARG1=-ow
  OW_ARG2=\*samples
fi

#tks sxt -a "$SAMPLE_NAME" -pnf -wt -o "$OUTPUT_NAME" -p -pn 5 $OW_ARG1 "$OW_ARG2" $*
#tks sxt -a "$SAMPLE_NAME" -pnf -wt -o "$OUTPUT_NAME" -p -pn 29 $OW_ARG1 "$OW_ARG2" $*
tks sxt -a "$SAMPLE_NAME" -pnf -wt -o "$OUTPUT_NAME" -p -pn 41 $OW_ARG1 "$OW_ARG2" $*

unset IFS
