Improve 2018/algmyr/try.sh + update FAQ

The script now does more (another feature of the program).

The FAQ now has a name of 'sox' for FAQ 3.10 which the script refers to
and the README.md file now refers it too (instead of 3.10).

Fix make clobber: rm *.wav.

Update .gitignore.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-31 09:12:10 -08:00
1 parent 485b24beab
commit a4a153cd74
5 files changed
+35 -20

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ prog
prog.alt prog.alt
prog.orig prog.orig
spectrogram.png spectrogram.png
*.wav
+1 -1
View File
@@ -207,7 +207,7 @@ clean:
clobber: clean clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET} ${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM ${RM} -rf *.dSYM *.wav
${RM} -f out.raw ${RM} -f out.raw
@-if [ -e sandwich ]; then \ @-if [ -e sandwich ]; then \
${RM} -f sandwich; \ ${RM} -f sandwich; \
+3 -3
View File
@@ -6,7 +6,7 @@ make
To use this entry requires, in some invocations, a sound processing program. 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 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: ### Bugs and (Mis)features:
@@ -23,9 +23,9 @@ For more detailed information see [2018 algmyr in bugs.md](/bugs.md#2018-algmyr)
## To use: ## To use:
```sh ```sh
cat prog.c | ./prog # Print garbage: might mess up your terminal ./prog < prog.c # Print garbage: might mess up your terminal
./prog <file1> <file2> > out.raw ./prog <file1> <file2> > 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
``` ```
+29 -15
View File
@@ -15,46 +15,60 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown # clear screen after compilation so that only the entry is shown
clear 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 ./prog -h | ./prog -d 1 0
echo 1>&2 echo 1>&2
# Who needs cat? Answer: more people than you think. # 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): " 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 echo 1>&2
./prog prog.c | ./prog -d 1 0 | less -EXF ./prog prog.c | ./prog -d 1 0 | less -rEXFK
echo 1>&2 echo 1>&2
APLAY="$(type -P aplay)" APLAY="$(type -P aplay)"
SOX="$(type -P sox)" SOX="$(type -P sox)"
if [[ -z "$SOX" && -z "$APLAY" ]]; then 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 elif [[ -n "$SOX" ]]; then
echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \ echo "$ echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog | \
sox -t raw -c 1 -r 44100 -L -e floating-point -b 32 \ $SOX -t raw -c 1 -r 44100 -L -e floating-point -b 32 \
- -n spectrogram -d 10 -X 300" 1>&2 - -n spectrogram -d 10 -X 300" 1>&2
echo -n ' MENE MENE TEKEL UPHARSIN ' | ./prog |\ 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 "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: " read -r -n 1 -p "Press any key to continue: "
echo 1>&2 echo 1>&2
echo "$ 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"
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 echo "Now listen to ioccc.wav." 1>&2
else else
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | echo "$ echo \"<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~\" |
./prog | aplay -c1 -fFLOAT_LE -r44100 ./prog | $APLAY -c1 -fFLOAT_LE -r44100" 1>&2
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' | read -r -n 1 -p "Press any key to continue: "
./prog | aplay -c1 -fFLOAT_LE -r44100 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 fi
echo 1>&2 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 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
+1 -1
View File
@@ -1249,7 +1249,7 @@ for downloading, installing and using ncurses.
We recommend trying a method suitable for your environment first, if possible. We recommend trying a method suitable for your environment first, if possible.
### <a name="faq3_10"></a>FAQ 3.10: How do I compile and use an IOCCC winner that requires sound? ### <a name="faq3_10"></a><a name="sox"></a>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 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 processing programs, [SoX](https://sox.sourceforge.net), will work. How to