Format fix README.md + add alt code to 2011/vik
The alternate code is based on the author's statements on how to get it to work for Windows. I then looked at MS docs to find out what header files are needed. The only reason I did this is because the purpose of the issue #1 is to get the entries to compile under as many systems as possible and since the author gave instructions ... Obviously I didn't test this as I have no way to do so. It's 'as is'. In the famous words of Douglas Adams: 'Don't share and don't enjoy! :-)' Updated bugs.md with INABIAF noted by the author. Format fix README.md.
This commit is contained in:
1 parent
33d160019d
commit
ba108e1f65
5 files changed
+197
-63
No files matched your search
@@ -1 +1,3 @@
|
||||
vik
|
||||
audio_file.raw
|
||||
vik.alt
|
||||
+2
-2
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
|
||||
DATA= mad_world.mod randowan.mod raw2wav
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
ALT_TARGET=
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
|
||||
+92
-61
@@ -1,10 +1,8 @@
|
||||
# Most sound
|
||||
|
||||
Daniel Vik
|
||||
802 Durshire Way
|
||||
Sunnyvale, Ca 94087
|
||||
<daniel@vik.cc>
|
||||
<http://www.danielvik.com>
|
||||
Daniel Vik
|
||||
<daniel@vik.cc>
|
||||
<http://www.danielvik.com>
|
||||
|
||||
## To build:
|
||||
|
||||
@@ -18,6 +16,15 @@ make
|
||||
./vik file.mod > audio_file.raw
|
||||
```
|
||||
|
||||
An alternate version for Windows is available. See the Alternate code section
|
||||
below.
|
||||
|
||||
### INABIAF - it's not a bug it's a feature! :-)
|
||||
|
||||
The author stated that the program will crash if no argument is passed tot he
|
||||
program though we note that your computer might also [halt and catch
|
||||
fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-)
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
@@ -31,22 +38,31 @@ Alternatively, you can use:
|
||||
./vik file.mod > file.raw; ./raw2wav file.raw > file.wav
|
||||
```
|
||||
|
||||
It is possible to download a number of Mod files from [The Mod Archive](http://modarchive.org).
|
||||
It is possible to download a number of Mod files from [The Mod
|
||||
Archive](http://modarchive.org).
|
||||
|
||||
### Alternate code:
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson), though he feels
|
||||
slightly sick :-), added a version for Windows based on the author's comments
|
||||
(along with looking up the function for the right header file). To build try the
|
||||
alt rule of the Makefile. Assuming that `make` is similar enough try:
|
||||
|
||||
```sh
|
||||
make alt
|
||||
|
||||
```
|
||||
|
||||
Use `vik.alt` as you would `vik` above.
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
The randowan.mod and mad_world.mod files were created by
|
||||
[Henrik Bertilsson](http://www.translucentboy.com) and
|
||||
are included with his permission.
|
||||
|
||||
### Selected Judges Remarks:
|
||||
|
||||
This entry converts .MOD audio files to a playable stream
|
||||
in a most pleasing manner if you don't like tremolo or vibrato.
|
||||
|
||||
Also it abuses the C compiler and/or assembler with a partially
|
||||
initialized 32 MByte array. Can you tell what is that partial
|
||||
initilzation for?
|
||||
initialized 32MB array. Can you tell what that partial
|
||||
initialization for?
|
||||
|
||||
Does it take your system a long time to compile? You may want to do try:
|
||||
|
||||
@@ -55,100 +71,115 @@ cc -S vik.c
|
||||
```
|
||||
|
||||
and to examine the resulting assembly file vik.s. On some platforms
|
||||
the assembly file is about 128 MBytes in size!
|
||||
the assembly file is about 128MB in size!
|
||||
|
||||
NOTE: The [randowan.mod](randowan.mod) and [mad_world.mod](mad_world.mod) files were
|
||||
created by [Henrik Bertilsson](http://www.translucentboy.com) and are included
|
||||
with his permission.
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
### Introduction
|
||||
|
||||
In 1987, Karsten Obarski changed the way music was handled in games and
|
||||
demos with the introducton of the MOD file format on Commodore Amiga.
|
||||
In 1987, [Karsten
|
||||
Obarski](http://www.vgmpf.com/Wiki/index.php?title=Karsten_Obarski) [changed the
|
||||
way](https://en.wikipedia.org/wiki/Ultimate_Soundtracker) music was handled in games and
|
||||
demos with the introduction of the MOD file format on [Commodore
|
||||
Amiga](https://en.wikipedia.org/wiki/Amiga)
|
||||
|
||||
A MOD file contains a set of samples, a number of patterns indicating
|
||||
how and when the samples are to be played, a list of what patterns to
|
||||
play in what order, and a number of effects.
|
||||
A MOD file contains a set of samples, a number of patterns indicating how and
|
||||
when the samples are to be played, a list of what patterns to play in what
|
||||
order, and a number of effects.
|
||||
|
||||
### Features
|
||||
|
||||
This program converts MOD files created with the standard trackers for
|
||||
Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit
|
||||
44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8
|
||||
This program converts MOD files created with the standard trackers for
|
||||
Amiga, e.g. Pro Tracker, Noise Tracker and Sound Tracker to raw 16 bit
|
||||
44.1kHz stereo audio. The program supports MOD music with 4, 6, and 8
|
||||
channels MOD files with up to 31 samples.
|
||||
|
||||
The MOD format includes many effects for each audio channel and this
|
||||
The MOD format includes many effects for each audio channel and this
|
||||
program supports most of them, including:
|
||||
|
||||
* Arpeggio
|
||||
* Slide and fine slide up/down/to note
|
||||
* Set sample offset
|
||||
* Volume slide
|
||||
* Pattern break
|
||||
* Filter on/off
|
||||
* Set volume
|
||||
* Cut sample
|
||||
* Delay sample
|
||||
* Delay pattern
|
||||
* Set speed
|
||||
* Arpeggio
|
||||
* Slide and fine slide up/down/to note
|
||||
* Set sample offset
|
||||
* Volume slide
|
||||
* Pattern break
|
||||
* Filter on/off
|
||||
* Set volume
|
||||
* Cut sample
|
||||
* Delay sample
|
||||
* Delay pattern
|
||||
* Set speed
|
||||
|
||||
Due to size constraints tremolo and vibrato is not supported. Also, to
|
||||
Due to size constraints tremolo and vibrato is not supported. Also, to
|
||||
avoid infinite long songs, the position jump feature is ignored.
|
||||
|
||||
### Songs
|
||||
|
||||
With his permission, the package incldues two songs composed by Henrik
|
||||
With his permission, the package includes two songs composed by Henrik
|
||||
Bertilsson, also known as Deelite:
|
||||
|
||||
1. Mad World
|
||||
2. Randowan
|
||||
1. Mad World
|
||||
2. Randowan
|
||||
|
||||
|
||||
### Build
|
||||
|
||||
Compiling for *nix systems (including cygwin) is straight forward:
|
||||
Compiling for Unix systems (including cygwin) is straight forward:
|
||||
|
||||
$ gcc -o vik vik.c
|
||||
```sh
|
||||
gcc -o vik vik.c
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
### Convert MOD file to raw 44.1kHz stereo audio file
|
||||
|
||||
$ ./vik mad_world.mod > audio_file.raw
|
||||
```sh
|
||||
./vik mad_world.mod > audio_file.raw
|
||||
```
|
||||
|
||||
### Listen to the MOD file (streaming to mplayer)
|
||||
|
||||
$ ./vik randowan.mod | mplayer -demuxer rawaudio -
|
||||
```sh
|
||||
./vik randowan.mod | mplayer -demuxer rawaudio -
|
||||
```
|
||||
|
||||
(Don't forget the last '-' as it makes mplayer read from stdin.)
|
||||
(Don't forget the last `-` as it makes mplayer read from stdin.)
|
||||
|
||||
### Obfuscation
|
||||
|
||||
The IOCCC rules did not put a limit on the entropy of the source code,
|
||||
and it appears that the general entropy rules doesn't apply. An estimate
|
||||
is that the code density entropy of this entry is ~1.2 which means that
|
||||
The IOCCC rules did not put a limit on the entropy of the source code,
|
||||
and it appears that the general entropy rules don't apply. An estimate
|
||||
is that the code density entropy of this entry is `~1.2` which means that
|
||||
there are around 2500 characters of code carrying information, yet there
|
||||
are only 2037 IOCCC characters of actual code. Most of the additional
|
||||
characters are encoded with non-counting characters in the frequency
|
||||
table. But there are also ~50 or so white space characters spread out
|
||||
are only 2037 IOCCC characters of actual code. Most of the additional
|
||||
characters are encoded with non-counting characters in the frequency
|
||||
table. But there are also `~50` or so white space characters spread out
|
||||
through the source code that carry information.
|
||||
|
||||
The use of macros certainly adds to the obfuscation but the reason for
|
||||
The use of macros certainly adds to the obfuscation but the reason for
|
||||
using them is mainly to fit as many features as possible within the size
|
||||
limits. So please excuse the use of them.
|
||||
|
||||
Once the preprocessor is run, the code gets more interesting. The MOD
|
||||
player is basically a register based state machine and all the magic is
|
||||
hidden in a fog of short statements. Many of the register updates are
|
||||
conditional and the program uses the ? operator (sigh) mainly to save
|
||||
space, but also to leverage the comma operator and precedence more
|
||||
efficiently.
|
||||
Once the preprocessor is run, the code gets more interesting. The MOD player is
|
||||
basically a register based [state
|
||||
machine](https://en.wikipedia.org/wiki/Finite-state_machine) and all the
|
||||
[magic][] is hidden in a fog of short statements. Many of the register updates
|
||||
are conditional and the program uses the `?:` operator (sigh) mainly to save
|
||||
space, but also to leverage the comma operator and precedence more efficiently.
|
||||
|
||||
[magic]: https://en.wikipedia.org/wiki/Magic_(programming)#Variants
|
||||
|
||||
### Portability
|
||||
|
||||
The progam is portable to most platforms. The only system dependency is
|
||||
The program is portable to most platforms. The only system dependency is
|
||||
that the program relies on writing binary data to stdout.
|
||||
|
||||
Microsoft compilers adds a carriges return to newlines, and to compile
|
||||
the program with this platform, the following line can be added after
|
||||
Microsoft compilers adds a carriage return to newlines, and to compile
|
||||
the program with this platform, the following line can be added after
|
||||
the main declaration in order for the program to run correctly:
|
||||
|
||||
```c
|
||||
@@ -157,7 +188,7 @@ _setmode(_fileno(stdout), 0x8000);
|
||||
|
||||
### Limitations
|
||||
|
||||
The program only runs when a valid MOD file is passed as argument. If
|
||||
The program only runs when a valid MOD file is passed as argument. If
|
||||
no argument is passed, the program crashes.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <io.h>
|
||||
|
||||
char E[1<<25]=" ; } } { { } { { ; ; { } } { { ; { { { { { } ; } { { ; { { { ; { } ; ; ; { ; ; ; } } ; } { { ; } } ; } } ; ; } { ; } } { } } } } } ; { { } } } ; } } } { } ; ; ; { } ; { { { ; { ; } } { { { } { { ; ; { { } } { { ; { { { { { } ; } { { ; { { { ; { } ; ; ; ; ; } } ; } { { ; } } ; } ; ; } { ; } } } } } } } ; { { } ; ; } ; { } ; ; ; { } ; { { ; { ; } } { { { } { ; ; { { } } { { { { { { { { ; { ; { { ; { { ; ; { } ; ",
|
||||
*a[40],*q=E+20,*T=E+1080;
|
||||
int i=1,j,k,l,u,w,I,J,K,h,H,G,R=4,U,e[999],*p=e+5,*r,*s,*v,b[999],L[1<<16],
|
||||
F=882,n[99];
|
||||
FILE*f;
|
||||
|
||||
#define Y(a,b) (a)<(b)?(a):(b)
|
||||
#define Z(a,b) (a)>(b)?(a):(b)
|
||||
#define X(x,a,b)Z(a,Y(b,x))
|
||||
#define O [s]
|
||||
#define N [v]
|
||||
#define M [r]
|
||||
#define C ++
|
||||
#define m :0
|
||||
#define g m,
|
||||
#define d u==
|
||||
#define z(o) 32 O?n[X(32 O+o+(35 O-24)/256,0,59)]m
|
||||
#define y(o) 32 O?8 O=z(o)m
|
||||
#define x (p=e+5*34 O,2 M-3 && 2 M-5?y(0),l=p[4],a[i]=a[8+34 O],3 N=l>1?\
|
||||
2*(p[3]+l):2*p[0],4 N=l>1?2*l:1,0 N=Y(2 M-9?0:9 O<<8,3 N-1) m)
|
||||
#define W(t,i) (u=t[i]>>4,w=t[i]&15),
|
||||
#define Q(e) ((1 N+=13200)>=5 N?1 N-=5 N, C 0 N>=3 N?0 N-=4 N m g e*6 N*q[0\
|
||||
N]/34)+
|
||||
#define D(b,i) T[i]==*#b&&T[i+2]==#b[1]
|
||||
#define A ((unsigned char*)q)
|
||||
#define V *p C=
|
||||
#define S(a) V(A[a]<<8)|A[a+1],
|
||||
#define P 2 M==
|
||||
#define B ,putchar
|
||||
#define o for(
|
||||
|
||||
int main(int t,char**c)
|
||||
{
|
||||
_setmode(_fileno(stdout), 0x8000);
|
||||
o; w=E[u]; C u)n[u/10]+=(w-59?w-125?w-32?1 m:2:3)<<u%10;
|
||||
o t=fread(E,i,1<<24,f=fopen(c[i],"rb")),
|
||||
t=D(FT,0)?R=T[3]-48,32:D(CN,1)?R=*T-48,32:D(MK,0)?32:16;
|
||||
i C<t;
|
||||
S(0)V(A[2]&7)-2*(A[2]&8),V A[3],S(4)S(6)q+=8) q+=22;
|
||||
o H=*A,T=q+=2,q+=t>15?132:128;
|
||||
k<128;
|
||||
k C) G=X(G,T[k]+1,128);
|
||||
o p=L; j C<R*64*G; q+=4)
|
||||
o W(A,2)V*A&240|u,V i=0,V w,V A[3],k=((*A&15)<<8)|A[1],l=9<<19;
|
||||
k&&i C<60;
|
||||
u=k-n[i],u*u<l?p[-3]=i,l=u*u:l);
|
||||
o i=1; i<t; a[8+i]=q,q+=2*e[5*i C]);
|
||||
o t=6; !U; ) {
|
||||
o i=0; i<R;
|
||||
v=b+7*i,r=L+4*(R*(64*T[K]+J)+i),s=e+200+50*i,j=3 M&15,
|
||||
I?
|
||||
W(s,2 M)P 5||P 6||P 10?0 O =u?Y(0 O+u,64):Z(0 O-w,0) g
|
||||
P 0?W(r,3)(u|w)?y((I%3-1?I%3-2?0:w:u)) m g
|
||||
8 O=P 1?Z(113,8 O-1 O):P 2?Y(856,8 O+2 O):8 O,
|
||||
P 5||P 3?l=z(0),8 O>l?8 O=Z(8 O-3 O,l):8 O<l?Y(8 O+3 O,l) m g
|
||||
U|=P 11&&I==t-1,
|
||||
P 13&&I==t-1?W(r,3)K C,J=10*u+w-1 g
|
||||
P 14?
|
||||
W(r,3)
|
||||
d 6?j?I==t-1?38 O=38 O<j?J=37 O-1,38 O+1 m m:(37 O=J) g
|
||||
d 9&&C 39 O==25 O?39 O=0,x g
|
||||
d 12&&I==28 O?0 O=0 g
|
||||
d 13&&I==e[29]?x m
|
||||
m
|
||||
:(
|
||||
0 M?34 O=0 M,p=e+5*34 O,35 O=p[1],0 O=p[2] g
|
||||
3 M?2 M O=3 M g
|
||||
1 M&&(2 M-14||((3 M>>4)-13))?32 O=1 M,x g
|
||||
0 O=P 12?X(3 M,0,64) m O ,
|
||||
P 15?(l=3 M)?l<33?t=l:(F=110250/l) m g
|
||||
P 14?
|
||||
W(r,3)
|
||||
j?(16+u) O=j g
|
||||
8 O=d 1?Z(113,8 O-17 O):d 2?Y(856,8 O+18 O):8 O,
|
||||
d 5?35 O=(j&7)-2*(j&8) g
|
||||
d 9?39 O=25 O&&!1 M?x,0 m g
|
||||
0 O=d 10?Y(0 O+26 O,64):d 11?Z(0 O-27 O,0):0 O,
|
||||
d 14?h=30 O m m),
|
||||
6 N =X(0 O,0,64),
|
||||
5 N =999*8 O,
|
||||
i C);
|
||||
o C I>=t+t*h?I=h=0,C J>=64?J=0,U|=C K>=H m g j=F; j--; 0
|
||||
B(u)B(u>>8)B(w)B(w>>8))
|
||||
o i=u=w=0; i<R;
|
||||
v=b+7*i,q=a[i C],q?l=Q(1)Q(4)Q(12)Q(12)Q(4)Q(1)0,
|
||||
k=1<<(i&2),u+=l/k,w+=l/(k^5) m);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1977,6 +1977,14 @@ where `o` is a `void`.
|
||||
|
||||
Do you have a fix? We welcome it!
|
||||
|
||||
## [2011/vik](2012/vik/vik.c) ([README.md](2012/vik/README.md))
|
||||
## STATUS: INABIAF - please **DO NOT** fix
|
||||
|
||||
The author stated that the program will crash if no argument is passed tot he
|
||||
program though we note that your computer might also [halt and catch
|
||||
fire](https://en.wikipedia.org/wiki/Halt_and_Catch_Fire_(computing)) :-)
|
||||
|
||||
|
||||
# 2012
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user