Skip to content

Commit

Permalink
add script for generating strudel.json from large sample sets
Browse files Browse the repository at this point in the history
  • Loading branch information
cleary committed Apr 27, 2024
1 parent dc05763 commit 56c2f84
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions global/generateStrudelJSON.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#/bin/sh

#
# Generate a strudel.json file suitable for use with https://strudel.cc
# This script expects a number of subdirs containing .wav files
#
# Copyright (c) 2024 by Bernard Gray <[email protected]>
# based on generateAudioResources.sh from the estuary project by David Ogborn
# https://github.com/dktr0/estuary
#
# License: GPLv3 https://www.gnu.org/licenses/gpl-3.0.html

BASE="https://samples.grbt.com.au/"

printf "{\n"
printf "\"_base\": \"%s\",\n" "${BASE}"
dircount=0
find $1 -mindepth 1 -maxdepth 1 -type d | sort | while read d; do
dirname=`basename $d`
# testing
if [[ $dircount -ne 0 ]]; then
printf ",\n"
fi
printf "\"%s\": [" "$dirname"
search2=$searchRoot/$dirname/*.WAV
filecount=0
find "$d" -iname "*.wav" | sort | while read f; do
# for f in $search2; do
if [[ $filecount -ne 0 ]]; then
printf ","
fi
filename=$(printf %q "$f")
basename=${f##*/}
if [[ ${basename:0:1} != "." ]]; then
printf "\"%s/%s\"" "$dirname" "$basename"
(( filecount++ ))
fi
done
printf "]" "$dirname"
(( dircount++ ))
done
printf "\n}\n"

0 comments on commit 56c2f84

Please sign in to comment.