make_patfile.sh 1.2 KB

1234567891011121314151617181920212223242526272829
  1. # Convert the FreePats Drums_000 directory to ITL Chorus drums.tar.bz2
  2. # Note: technically, this must be run in a directory with subdirectories
  3. # starting with a MIDI pitch, and containing a text file with a
  4. # "convert_to_wav:" command that produces a .wav in that working directory.
  5. # sox is required to convert the audio. This handles the dirt-old options
  6. # for sox in the text files explicitly to support the FreePats standard.
  7. # The current version was checked in from the Drums_000 directory to be
  8. # found in the TAR at this URL:
  9. # http://freepats.zenvoid.org/samples/freepats/freepats-raw-samples.tar.bz2
  10. # Thank you again, FreePats!
  11. rm *.wav .wav *.raw .raw
  12. for i in *; do
  13. if [ -d $i ]; then
  14. pushd $i
  15. eval `grep 'convert_to_wav' *.txt | sed -e 's/convert_to_wav: //' -e 's/-w/-b 16/' -e 's/-s/-e signed/' -e 's/-u/-e unsigned/'`
  16. PITCH=`echo "$i" | sed -e 's/^\([0-9]\+\).*$/\1/g'`
  17. # From broadcast.py, eval'd in Python for consistent results
  18. FRQ=`echo $PITCH | python2 -c "print(int(440.0 * 2**((int(raw_input())-69)/12.0)))"`
  19. echo "WRITING $FRQ.wav"
  20. [ -z "$FRQ" ] && echo "!!! EMPTY FILENAME?"
  21. sox *.wav -r 44100 -c 1 -e signed -b 32 -t raw ../$FRQ.raw
  22. popd
  23. fi
  24. done
  25. rm drums.tar.bz2
  26. tar cjf drums.tar.bz2 *.raw