Merge pull request #2040 from xexyl/vik2011-try

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-24 09:36:14 -08:00
commit 825d88c169
4 files changed
+87 -7

No files matched your search

+2
View File
@@ -1,6 +1,7 @@
# #
# sort with: sort -d -u # sort with: sort -d -u
audio_file.raw audio_file.raw
*.dSYM *.dSYM
indent indent
indent.c indent.c
@@ -9,3 +10,4 @@ prog.orig
vik vik
vik.alt vik.alt
vik.orig vik.orig
*.wav
+19 -6
View File
@@ -25,21 +25,35 @@ For more detailed information see [2011 vik in bugs.md](/bugs.md#2011-vik).
./vik file.mod > audio_file.raw ./vik file.mod > audio_file.raw
``` ```
If you have `mplayer(1)`:
## Try:
```sh ```sh
./vik randowan.mod | mplayer -demuxer rawaudio - ./vik file.mod | mplayer -demuxer rawaudio -
./vik mad_world.mod | mplayer -demuxer rawaudio -
``` ```
Alternatively, you can use: Alternatively, you can convert the file to a WAV:
```sh ```sh
./vik file.mod > file.raw; ./raw2wav file.raw > file.wav ./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
``` ```
It is possible to download a number of music module files from [The Mod and then play `file.wav` with a program that can play WAV files.
## Try:
```sh
./try.sh
```
The script checks that you have `mplayer(1)` installed and if it is it will pipe
`vik` to `mplayer`. In this case it will also use `raw2wav` to convert the file
to a WAV file. If `mplayer(1)` cannot be found it will just use `raw2wav`. This
way even if one has an `mplayer(1)` that fails or is for some reason not what is
expected they can at least play the WAV file manually.
It is also possible to download a number of music module files from [The Mod
Archive](http://modarchive.org). Archive](http://modarchive.org).
@@ -54,7 +68,6 @@ Assuming that `make` is similar enough try:
```sh ```sh
make alt make alt
``` ```
+63
View File
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2011/vik
#
# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it
# this way allows us to have the user specify a different compiler in an easy
# way.
if [[ -z "$CC" ]]; then
CC="cc"
fi
# in this case we won't fail if we can't compile the code because we can still
# run the supplementary program.
make CC="$CC" all >/dev/null
# clear screen after compilation so that only the entry is shown
clear
# fine mplayer
MPLAYER="$(type -P mplayer)"
raw2wav()
{
if [[ "$#" != 2 ]]; then
echo "$0: raw2wav() expects two args, got: $#" 1>&2
return
fi
read -r -n 1 -p "Press any key to run: ./vik $1 > $2: "
echo 1>&2
./vik "$1" > "$2"
echo 1>&2
read -r -n 1 -p "Press any key to run: ./raw2wav $1 > $2: "
echo 1>&2
./raw2wav "$1" > "$2"
echo 1>&2
echo "Converted $1 to $2." 1>&2
echo 1>&2
}
if [[ -n "$MPLAYER" && -f "$MPLAYER" && -x "$MPLAYER" ]]; then
# If we have mplayer we'll try playing the sounds directly. If however it
# fails for some reason we will run the alternate procedure, creating WAV
# files.
read -r -n 1 -p "Press any key to run: ./vik randowan.mod | $MPLAYER -demuxer rawaudio -: "
echo 1>&2
./vik randowan.mod | mplayer -demuxer rawaudio -
raw2wav randowan.mod randowan.wav
read -r -n 1 -p "Press any key to run: ./vik mad_world.mod | mplayer -demuxer rawaudio -: "
echo 1>&2
./vik mad_world.mod | mplayer -demuxer rawaudio -
raw2wav mad_world.mod mad_world.wav
echo 1>&2
else
raw2wav randowan.mod randowan.wav
[[ -f randowan.wav ]] && echo "Now try playing randowan.wav with a program that can play WAV files." 1>&2
raw2wav mad_world.mod mad_world.wav
[[ -f mad_world.wav ]] && echo "Now try playing mad_world.wav with a program that can play WAV files." 1>&2
fi
+3 -1
View File
@@ -3669,7 +3669,9 @@ controls, width and height.
## <a name="2011_vik"></a>[2011/vik](/2011/vik/vik.c) ([README.md](/2011/vik/README.md])) ## <a name="2011_vik"></a>[2011/vik](/2011/vik/vik.c) ([README.md](/2011/vik/README.md]))
[Cody](#cody) added an [alternate version](/2011/vik/README.md#alternate-code) for Windows [Cody](#cody) added the [try.sh](/2011/vik/try.sh) script.
Cody also added an [alternate version](/2011/vik/README.md#alternate-code) for Windows
based on the author's comments (along with looking up the function for the right based on the author's comments (along with looking up the function for the right
header files). To build try the alt rule of the Makefile. header files). To build try the alt rule of the Makefile.