#!/bin/sh if [ -z "$1" -o -z "$2" -o ! -f "$1" -o ! -f "$2" ] then echo "Usage: orc2csd.sh [file.orc] [file.sco] >file.csd" exit 1 fi export sample_filenames="" replace_samples() { tempfile1=$(mktemp -t $$) tempfile2=$(mktemp -t $$) cat "$1" >"$tempfile1" sample_filenames=$(grep "^f[0-9][0-9]*[[:space:]][[:space:]]*0[[:space:]][[:space:]]*0[[:space:]][[:space:]]*1[[:space:]][[:space:]]*\"" "$tempfile1" | sed 's/^[^"]*"\([^"]*\).*/\1/' | sort | uniq) sample_count=1 for sample_filename in $sample_filenames do sed <"$tempfile1" >"$tempfile2" "s/^\(f[0-9][0-9]*[[:space:]][[:space:]]*0[[:space:]][[:space:]]*0[[:space:]][[:space:]]*1[[:space:]][[:space:]]*\"\)$sample_filename\(.*\)/\1soundin.$sample_count\2/g" cat "$tempfile2" >"$tempfile1" sample_count=$(($sample_count + 1)) done cat "$tempfile1" rm -f "$tempfile1" "$tempfile2" } grab_samples() { sample_count=1 for sample_filename in $sample_filenames do echo "" openssl base64 <"$sample_filename" echo "" sample_count=$(($sample_count + 1)) done } echo "" echo "" echo "" echo "" cat "$1" echo "" echo "" echo "" replace_samples "$2" echo "" echo "" grab_samples echo "" echo ""