Add alt code to 2014/vik

This is based on the author's remarks and it theoretically will work
with Microsoft Windows compilers (assuming that anything works with
Windows, of course :-) ). It's not been tested because I'm blessed
enough to not have a way to test it but it should be fine unless
something has changed since 2014.

As I was updating the thanks file I made a simple clarification for
another entry as well but it has no relation to this commit - it's just
in the way because I saw it and wanted to fix it and since it's not
anything other than slight rewording I don't see that it needs a
separate commit.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-15 08:35:14 -07:00
1 parent d1134b23d9
commit 6f54faeb4b
5 files changed
+60 -6

No files matched your search

+1
View File
@@ -1,4 +1,5 @@
audio_file.raw
prog
prog.alt
prog.raw
prog.orig
+2 -2
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
#################
+18 -2
View File
@@ -13,13 +13,15 @@ US
make
```
## To run:
```sh
./prog > foo.c
```
There is an alternate version that will theoretically work with Windows
compilers (if anything in Windows works :-) ). See the [Alternate
code](#alternate-code) section below.
## Try:
@@ -29,6 +31,18 @@ echo 'Want to hear me beep?' | ./prog > audio_file.raw
echo 'No. I want chocolate!' | ./prog | mplayer -demuxer rawaudio -
```
### Alternate code:
The alternate code, [prog.alt.c](prog.alt.c), is based on the author's
instructions on how to get it to work with Windows. This has not been tested but
in order to use it you can do:
```sh
make alt
```
Use `prog.alt` as you would `prog` above as well as below.
## Judges' remarks:
@@ -59,7 +73,7 @@ I can tell, there are at least six chocolate references in this program.
This program can convert text to Morse to a raw 44.1kHz stereo audio file.
Via streaming to mplayer, you can listen to the Morse audio.
Don't forget the last '-' as it makes mplayer read from stdin.
Don't forget the last '`-`' as it makes mplayer read from stdin.
## Convert audio file with Morse signals to text
@@ -86,6 +100,8 @@ declaration in order for the program to run correctly:
_setmode(_fileno(stdout), 0x8000);
```
NOTE: see the [alternate code](prog.alt.c) for this.
### Known Issues
The program uses a quite simple algorithm for detecting tone on and off events
+31
View File
@@ -0,0 +1,31 @@
#include <stdio.h>
#include <string.h>
#include <io.h>
char X[] =
" ETIANMSURWDKGOHVF:L:PJBXCYZQ::54:3:::2&:+::::16=/:::(:7:::8:90"
"::::::::::::?_::::\"::.::::@:::'::-::::::::;!:):::::,:::::";
int j,w,h,f,u,d,g,e,n,i,l,a,r,p,c,m,o,t,s,Q=32,T[32],W[32],I=13000;
int main(int v, char** b) {
_setmode(_fileno(stdout), 0x8000);
for (i=0;v>0&&v<5&&(v*=t=fread(X,1,1,stdin));)
for (v-1&&101==*1[b]?++g%1500?u+=(g&1^1)*(*X<0?-*X:*X):(f=e,e=w,w=d,d=u,
m=(1 - h%2* 2 )*(d -f)/ (d<f ?d|1 : 1|f) > 5?T[ h%Q] =o+l , l=W[
h++%Q]=o,o=0:m,o++,u=main(0,b)):(c=strrchr(X,~(Q&*X&*X/2)&*X)-X,j=255);
v==1&&(c*j||main(*X-Q?8:24,b));j/=2)c<j?0:main(9+(c-j)/(j/2+1)%2*10,b);
for (a=u=0;i<=Q*Q&&!v;j>7&&j<13?s=c*s+T[i/Q]/2,s/=++c:0)
!(i++%Q)?a=c>a?u=s,c:a,c=s=0:0,j=T[i%Q],j=j?T[i/Q]*10/j:0,j*=(j<5)*2+1;
for (r+=(h-r)/Q*Q;i<v/4*I;putchar((i/I<v%4)*i%2*85<<(i%176/88)),i++);
for (g*=!!v;r+t!=h+1&&h>5&&!v;r+t!=h+1?(W[r%Q]>2*u||r==h?p=n=n>6?0:
putchar(X[p-1+(1<<n)])&0:0,W[r++%Q]>6*u?putchar(Q):0):0)
*X=Q,p=r%2?++n,2*p+(W[r++%Q]>2*u):p;
return 0;
}
+8 -2
View File
@@ -1790,12 +1790,18 @@ implicitly (linux doesn't seem to but macOS does).
Cody fixed the build for this entry: it does not require SDL2 but SDL1 so there
were linking errors.
## [2014/vik](2014/vik/prog.c) ([README.md](2014/vik/README.md))
Cody added an alternate version that is based on the author's remarks that will
theoretically work for Microsoft Windows compilers (if anything works in Windows
:-) ). We have no way of testing this and if anything has changed since 2014
that would break it we do not know.
## [2015/endoh3](2015/endoh3/prog.c) ([README.md](2015/endoh3/README.md]))
Cody fixed this to compile with linux which was having a problem with duplicate
symbols of `main()`. The fix is through the option `-fcommon` which will let it
compile like it does with macOS.
symbols of `main()`. The fix is through the compiler option `-fcommon` which
will let it compile like it does with macOS.
Cody also made it easier to enjoy the theme of [Back to the
Future](https://en.wikipedia.org/wiki/Back_to_the_Future) using this entry by