diff --git a/addon/tools/wav2c.sh b/addon/tools/wav2c.sh index 719de7d..23e21d2 100755 --- a/addon/tools/wav2c.sh +++ b/addon/tools/wav2c.sh @@ -3,15 +3,19 @@ # Converter for WAV to C Header # Used for MicroDexed sampler # -# (C)2021 Holger Wirtz +# (C)2021-2022 Holger Wirtz # + SOX=`which sox` XXD=`which xxd` TMP="/tmp/wav2c" AUDIO_BLOCK_SIZE=128 DRUMSET_H="drumset.h" DRUMS_H="${TMP}/drums.h" +MAX_NUM_DRUMSET_CONFIG=71 # ARDUINO_TEENSY41 +#MAX_NUM_DRUMSET_CONFIG=40 # ARDUINO_TEENSY40 +#MAX_NUM_DRUMSET_CONFIG=19 # ... function cleanexit() { @@ -48,6 +52,11 @@ while [[ $# -gt 0 ]]; do shift # past argument shift # past value ;; + -n|--num) + MAX_NUM_DRUMSET_CONFIG="$2" + shift # past argument + shift # past value + ;; # -t|--test) # TEST="true" # shift # past argument @@ -120,6 +129,11 @@ do if [ -f "${WAV_DIR}/${sample['filename']}" ] then + if [ ${NUM_DRUMSET_CONFIG} -gt ${MAX_NUM_DRUMSET_CONFIG} ] + then + echo "/*" >> "${DRUMSET_H}" + fi + file "${WAV_DIR}/${sample['filename']}" | grep -i -q "WAVE audio" if [ "${?}" == 0 ] then @@ -167,6 +181,10 @@ do fi # Generate drums.h + if [ ${NUM_DRUMSET_CONFIG} -gt ${MAX_NUM_DRUMSET_CONFIG} ] + then + echo "/*" >> "${DRUMS_H}" + fi cat >> "${DRUMS_H}" << EOF { ${sample[class]}, @@ -184,7 +202,14 @@ do ${sample[reverb_send]} }, EOF + if [ ${NUM_DRUMSET_CONFIG} -gt ${MAX_NUM_DRUMSET_CONFIG} ] + then + echo "*/" >> "${DRUMS_H}" + echo "*/" >> "${DRUMSET_H}" + fi NUM_DRUMSET_CONFIG=`expr "${NUM_DRUMSET_CONFIG}" + 1` + else + echo "File ${WAV_DIR}/${sample['filename']} is not a WAV audio file" fi else echo "File \'${WAV_DIR}/${sample['filename']}\' does not exits." >&2