fix .gitignore, Makefile and README.md for 2018/algmyr
This commit is contained in:
1 parent
6086d9ad80
commit
3c29fb76dd
3 files changed
+51
-47
No files matched your search
@@ -1 +1,2 @@
|
||||
out.raw
|
||||
prog
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env make
|
||||
#
|
||||
# IOCCC 2018 winning entry - algmyr
|
||||
# IOCCC 2015 winning entry - algmyr
|
||||
|
||||
################################################################################
|
||||
#
|
||||
@@ -76,7 +76,7 @@ CWARN= -Wall -Wextra -pedantic ${CSILENCE}
|
||||
#
|
||||
#CSTD=
|
||||
#CSTD= -ansi
|
||||
CSTD= -std=gnu17
|
||||
CSTD= -std=gnu11
|
||||
|
||||
# Compiler bit architecture
|
||||
#
|
||||
@@ -101,8 +101,8 @@ CINCLUDE=
|
||||
#CINCLUDE= -include stdlib.h
|
||||
#CINCLUDE= -include stdio.h
|
||||
#CINCLUDE= -include stdlib.h -include stdio.h
|
||||
#CINCLUDE= -I ${X11_INCDIR}
|
||||
#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2
|
||||
#CINCLUDE= -I ${X11_INCDIR} -I ${X11_INCDIR}/X11
|
||||
#CINCLUDE= `${SDL2_CONFIG} --cflags`
|
||||
|
||||
# Optimization
|
||||
#
|
||||
@@ -126,7 +126,7 @@ CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
||||
LIBS=
|
||||
#LIBS= -lm
|
||||
#LIBS= -L ${X11_LIBDIR} -lX11
|
||||
#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL
|
||||
#LIBS= `${SDL2_CONFIG} --libs`
|
||||
|
||||
# C compiler to use
|
||||
#
|
||||
@@ -166,6 +166,7 @@ ENTRY= algmyr
|
||||
PROG= prog
|
||||
#
|
||||
OBJ= ${PROG}.o
|
||||
CSRC= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
@@ -215,6 +216,7 @@ clean:
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -f out.raw
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
|
||||
+43
-42
@@ -1,34 +1,40 @@
|
||||
# Most cacophonic
|
||||
|
||||
Anton Älgmyr
|
||||
Twitter: @aalgmyr
|
||||
Anton Älgmyr
|
||||
Twitter: @aalgmyr
|
||||
|
||||
## To build:
|
||||
# To build:
|
||||
|
||||
make all
|
||||
```sh
|
||||
make
|
||||
```
|
||||
|
||||
### To run
|
||||
### To run:
|
||||
|
||||
cat prog.c | ./prog # Printing garbage might break your font
|
||||
./prog <file1> <file2> > out.raw
|
||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
||||
```sh
|
||||
cat prog.c | ./prog # Printing garbage might break your font
|
||||
./prog <file1> <file2> > out.raw
|
||||
./prog -d 2 0 out.raw # Decode the first (0th) channel out of two
|
||||
```
|
||||
|
||||
### Try:
|
||||
|
||||
./prog -h | ./prog -d 1 0
|
||||
```sh
|
||||
./prog -h | ./prog -d 1 0
|
||||
|
||||
# Who needs cat?
|
||||
./prog prog.c | ./prog -d 1 0
|
||||
# Who needs cat?
|
||||
./prog prog.c | ./prog -d 1 0
|
||||
|
||||
# Assuming ALSA
|
||||
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' |
|
||||
./prog | aplay -c1 -fFLOAT_LE -r44100
|
||||
# Assuming ALSA
|
||||
echo '<<<<<< /\_/\_/\ _-_-_-_ !!!!! :.:.:.: >>>>>> ****** ~~~~~~~' |
|
||||
./prog | aplay -c1 -fFLOAT_LE -r44100
|
||||
|
||||
# Assuming sox
|
||||
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
|
||||
# Assuming sox
|
||||
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
|
||||
```
|
||||
|
||||
### Selected Judges Remarks:
|
||||
## Judges' comments:
|
||||
|
||||
Be warned, this is not your garden variety text-to-speech program! Earplugs are advised,
|
||||
or at least a handy and well-tested volume knob.
|
||||
@@ -38,15 +44,14 @@ and the message can be displayed in fiery letters, but don't be alarmed.
|
||||
|
||||
How does decoding of the waveform work? Can you encode an arbitrary text in a sound sample?
|
||||
|
||||
|
||||
## Author's comments:
|
||||
|
||||
What is this?
|
||||
=============
|
||||
### What is this?
|
||||
|
||||
To put it brief, this entry is akin to a sound based cat. It takes characters as input and outputs them into frequency space as audio. The entry also supports decoding the produced waveforms using the `-d` flag. Usage instructions is output if run with the `-h` flag, albeit not in an immediately legible format.
|
||||
|
||||
Details
|
||||
-------
|
||||
### Details
|
||||
|
||||
In normal operation, the entry reads characters from one or more sources. If the `-h` flag is given, usage instructions is used as a source. Else if file paths are present as arguments those will be used. Else stdin is used.
|
||||
|
||||
If a character is part of the supported subset of ASCII `{10, 32-126}` then that character is output into frequency space of an audio signal (44.1 kHz single precision float, endianness should depend on system endianness) through stdout. Any other character will be interpreted and outputted as a space.
|
||||
@@ -59,8 +64,8 @@ Interestingly, with training you might actually be able to tell characters just
|
||||
|
||||
See image spoiler.png for an example spectrogram.
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
### Limitations
|
||||
|
||||
There is no error checking done when opening files, so expect segfaults if you provide the wrong path to a file.
|
||||
|
||||
This program is bound to misbehave if int is less than 32 bits.
|
||||
@@ -69,11 +74,10 @@ Flags will only be interpreted correctly if they are the first argument. Reading
|
||||
|
||||
Providing invalid/unexpected arguments to the decode flag will result in odd behavior. Some erroneous arguments cause segfaults (negative number of channels, channel id outside valid range). One argument in particular causes an infinite loop printing whitespace.
|
||||
|
||||
Techniques
|
||||
==========
|
||||
### Techniques
|
||||
|
||||
### Obfuscation
|
||||
|
||||
Obfuscation
|
||||
-----------
|
||||
A lot of the obfuscations done came naturally from trying to appease the size tool. To name some:
|
||||
|
||||
* One character names
|
||||
@@ -87,25 +91,24 @@ Some additional obfuscation was done to mathematical formulas. Somewhat known ex
|
||||
|
||||
I have tried to avoid intentional red herrings in the code, although fishy statements are plentiful.
|
||||
|
||||
### Data encoding
|
||||
|
||||
Data encoding
|
||||
-------------
|
||||
The large string in the beginning of the source file contains font data, encoded in base64 using characters in the range `' '` to `'_'`. The space was chosen as the zero because the data contains a lot of zeroes, and quite helpfully the size tool ignores whitespace even in strings. Without this fact the program would have been too large and the decoding feature would have had to go. Fortunately this hole in the size spec was readily available. :)
|
||||
|
||||
Characters in the font (5x8 pixels, 40 bits) is packed into 7 base64 digits (which was a pain to decode in minimal code).
|
||||
|
||||
Math
|
||||
----
|
||||
### Math
|
||||
|
||||
Note that even though floats are used for the waveforms, the standard math library is not used at all! Most arithmetic is done purely on integers. The only major exception is generating a table of sine values which are interpolated to give high resolution waveforms. Can you see when the generation is triggered, and how it is done?
|
||||
|
||||
A critical issue encountered was that having abrupt starts and ends of signals cause a lot of problems with spectral leakage which makes spectrograms hard to read and audio painful to listen to. To reduce spectral leakage a windowing function was used. Although the one used is quite well known, it is not in a form that should be familiar to anyone. What looks like a polynomial and quacks like a polynomial might not actually be a polynomial, at least not deep inside.
|
||||
|
||||
Printing a string
|
||||
-----------------
|
||||
### Printing a string
|
||||
|
||||
The program was written to deal exclusively with file descriptors, so how would one go about printing a char array not from a file descriptor without adding additional logic? Answer: `ungetc` into stdin, one char at a time (to be standards compliant). This is used to print the usage instructions.
|
||||
|
||||
Compilation warnings
|
||||
====================
|
||||
### Compilation warnings
|
||||
|
||||
Compiling using
|
||||
|
||||
gcc -Wall -Wextra -pedantic
|
||||
@@ -120,16 +123,14 @@ is a bit more pessimistic and gives `-Wempty-body` (I like loops without bodies)
|
||||
|
||||
produces a few pagefuls of warnings and makes me feel generally bad about myself. :(
|
||||
|
||||
Misc
|
||||
====
|
||||
### Misc
|
||||
|
||||
The reported size of the source code using the size tool is very intentionally 2018.
|
||||
|
||||
## Copyright:
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
<!--
|
||||
(c) Copyright 1984-2018, [Leo Broukhis, Simon Cooper, Landon Curt Noll][judges] - All rights reserved
|
||||
This work is licensed under a [Creative Commons Attribution-ShareAlike 3.0 Unported License][cc].
|
||||
|
||||
[judges]: http://www.ioccc.org/judges.html
|
||||
[cc]: http://creativecommons.org/licenses/by-sa/3.0/
|
||||
-->
|
||||
Reference in new issue
Block a user