diff --git a/2018/algmyr/.gitignore b/2018/algmyr/.gitignore index 818b89eca..f4ce4bc96 100644 --- a/2018/algmyr/.gitignore +++ b/2018/algmyr/.gitignore @@ -9,3 +9,4 @@ prog prog.alt prog.orig spectrogram.png +*.wav diff --git a/2018/algmyr/Makefile b/2018/algmyr/Makefile index 595e9f9ca..377979c86 100644 --- a/2018/algmyr/Makefile +++ b/2018/algmyr/Makefile @@ -207,7 +207,7 @@ clean: clobber: clean ${RM} -f ${TARGET} ${ALT_TARGET} - ${RM} -rf *.dSYM + ${RM} -rf *.dSYM *.wav ${RM} -f out.raw @-if [ -e sandwich ]; then \ ${RM} -f sandwich; \ diff --git a/2018/algmyr/README.md b/2018/algmyr/README.md index b6f28a285..f07a1b6a9 100644 --- a/2018/algmyr/README.md +++ b/2018/algmyr/README.md @@ -6,7 +6,7 @@ make To use this entry requires, in some invocations, a sound processing program. This can be ALSA or SoX but we recommend the latter. See [FAQ 3.10 - How do I -compile and use an IOCCC winner that requires sound?](/faq.md#faq3_10). +compile and use an IOCCC winner that requires sound?](/faq.md#sox). ### Bugs and (Mis)features: @@ -23,9 +23,9 @@ For more detailed information see [2018 algmyr in bugs.md](/bugs.md#2018-algmyr) ## To use: ```sh -cat prog.c | ./prog # Print garbage: might mess up your terminal +./prog < prog.c # Print garbage: might mess up your terminal ./prog > out.raw -./prog -d 2 0 out.raw # Decode the first (0th) channel out of two +./prog -d 2 0 out.raw # Decode the first (0th) channel out of two ``` diff --git a/2018/algmyr/try.sh b/2018/algmyr/try.sh index 4c0f8045a..1c22a0125 100755 --- a/2018/algmyr/try.sh +++ b/2018/algmyr/try.sh @@ -15,46 +15,60 @@ make CC="$CC" all >/dev/null || exit 1 # clear screen after compilation so that only the entry is shown clear -echo "$ ./prog -h | ./prog -d 1 0" 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -h | ./prog -d 1 0: " +echo 1>&2 ./prog -h | ./prog -d 1 0 echo 1>&2 # Who needs cat? Answer: more people than you think. read -r -n 1 -p "Press any key to run: ./prog prog.c | ./prog -d 1 0 (space = next page, q = quit): " echo 1>&2 -./prog prog.c | ./prog -d 1 0 | less -EXF +./prog prog.c | ./prog -d 1 0 | less -rEXFK echo 1>&2 APLAY="$(type -P aplay)" SOX="$(type -P sox)" if [[ -z "$SOX" && -z "$APLAY" ]]; then - echo "Missing both sox and aplay, cannot do this step." + echo "Missing both sox and aplay, cannot do this step." 1>&2 + echo "NOTE: see https://github.com/ioccc-src/temp-test-ioccc/blob/master/faq.md#sox." 1>&2 elif [[ -n "$SOX" ]]; then -echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \ -sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 \ + echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \ +$SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 \ - -n spectrogram -d 10 -X 300" 1>&2 echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |\ - sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300 + $SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 - -n spectrogram -d 10 -X 300 echo "Now open spectrogram.png in an image viewer or editor." 1>&2 + echo 1>&2 read -r -n 1 -p "Press any key to continue: " echo 1>&2 - echo "$ echo "IOCCC 2018" | ./prog | sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav" - echo "IOCCC 2018" | ./prog | sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav + echo "$ echo \"IOCCC 2018\" | ./prog | $SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav" + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + echo "IOCCC 2018" | ./prog | "$SOX" -t raw -c 1 -r 44100 -L -e floating-point -b 32 - ioccc.wav echo "Now listen to ioccc.wav." 1>&2 - else -echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | -./prog | aplay -c1 -fFLOAT_LE -r44100 - echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | - ./prog | aplay -c1 -fFLOAT_LE -r44100 + echo "$ echo \"<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~\" | +./prog | $APLAY -c1 -fFLOAT_LE -r44100" 1>&2 + read -r -n 1 -p "Press any key to continue: " + echo 1>&2 + echo "<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~" | ./prog | "$APLAY" -c1 -fFLOAT_LE -r44100 -echo "Now open spectrogram.png in an image viewer or editor." 1>&2 + echo "Now open spectrogram.png in an image viewer or editor." 1>&2 fi echo 1>&2 -echo "$ echo "IOCCC 2018!" | ./prog | ./prog -d 1 0" 1>&2 +read -r -n 1 -p "Press any key to run: echo \"IOCCC 2018!\" | ./prog | ./prog -d 1 0: " +echo 1>&2 echo "IOCCC 2018!" | ./prog | ./prog -d 1 0 +read -r -n 1 -p "Press any key to run: ./prog README.md prog.c > out.raw: " +echo 1>&2 +./prog README.md prog.c > out.raw +echo 1>&2 +read -r -n 1 -p "Press any key to run: ./prog -d 2 0 out.raw (space = next page, q = quit): " +echo 1>&2 +./prog -d 2 0 out.raw | less -rEXFK +echo 1>&2 diff --git a/faq.md b/faq.md index 164bbeb2b..39ee39604 100644 --- a/faq.md +++ b/faq.md @@ -1249,7 +1249,7 @@ for downloading, installing and using ncurses. We recommend trying a method suitable for your environment first, if possible. -### FAQ 3.10: How do I compile and use an IOCCC winner that requires sound? +### FAQ 3.10: How do I compile and use an IOCCC winner that requires sound? This might depend on the entry but most likely the Swiss Army Knife of sound processing programs, [SoX](https://sox.sourceforge.net), will work. How to