Related to the above, here is something that I wrote in 1999:
#define _POSIX_SOURCE 1 /* Song length: 55 seconds (24 seconds of loop). */
/*/echo "$0 is not an executable but a C source file. Compiling it now..."
n=`basename $0`;gcc -O2 -Wall -W -pedantic -o /tmp/$n "$0";/tmp/$n $*;exit; */
static char*Title="Selfplayer for /dev/audio (8-bit, µ-law)\n"
"This file has been compiled from a file created with intgen.";
typedef unsigned char by;char*A,*tmp="nesmusa.$$$",*a0;
static by*z=(by*)"+l=6*mM*JlmZmom+mom)omm5lm8CoZ@Ig3QCDe^l=B*0Z@mJ+NZK*RJ)OJ+"
"5B*7<N+CNJ4LbZ=NZKRRK)O;+5HHF<n51N20Vb:UFZ^UCAY<U?""=a4doK*bJCe5(*(ToM2*2bZ7"
"FV_5AAd<_?AAedmK5XJ9=Ud<OL@lflK2J*Ae5H*4<oMB60b:=CZK2BK)fJ+5T+(<OM2(Bb:;BZKg"
"X*8=Vd2O8@Tf?Sm)+J+4M>\\Cnfb^[o)7:+4m=BE1NZ(Db:1:*So)^Z<4]=J7GBnl*1fI[m)d8+5"
"J72<B+4NJ7<Ybo+(;K)M`+5^J7<6D1NJ7Z`:\\3d+^bm)Cn55(DM<V[(OROAa*Dnm+ZHH)g=45Bn"
"(^oBAYdS_CAedlKo*A)d3^CBa5PM)<6+6BAm*6:*^ABm5@o(bnN2*XHY]TU)+::@l=^*1N:1BRXY"
"K*ZT0mEL<6*3Ncm:*^*TU)+*DBlenN2*FBYm+fHY)m745fR^<NF\\N:PDbZ>0X+RoF?""=5JdK<^"
"_>N2*DZXYK*:+1m5VE7<R*=Ocm:\\<fKSUK)Pn(5:1UfnUcc:*V:Tm)P]DIL<6*B?`mZ*]ZK6\\*"
">m5>J)<2*7N*V?b*)RZK12I)RJ75L`(fnMZ81bJ+NZ+neJ)+J+5DJ5<N+CNB4Db*?ZZ+KLH)+*+L"
"L<6*;bcm:*:ZUU)+:6Ml=6*66`c:*6;Rm)+*+PL8oJ`cfISU8=VL4o2`;fIRm)+J+5H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Z_7<>N1N2\\Eb:d_Z+@d*A]dT_?AAddo+D2VO1add__AAed\\]OMa4e?\\ANecK7"
"BK)8c(5(K7dO\\aNe`\\gO]aLeo\\ALen\\cOe5(K:*",
s[5][65536],l[299999],sn[32]="Logo by NESMusa";
#include <stdio.h>
#include <unistd.h>
static int S,h,OF,PN,d,p=1,r,k,i,a,c,CO,j,x,T=288,f=8000,LS=0,
P[12],H[99],IL[99];FILE*fo;
static int Out(int v){int e=0,s=1,f=0;if(OF)v=128+v/30;else for((s=(v<0))?v=-v
:0;e<8;e++)if((f=((v+32)>>(e+1))-16)<16)break;return fputc(OF?v:~((s<<7)|(e<<4
)|f),fo);}void gn(void){for(f=0;A[1]>='0'&&A[1]<='9';f=f*10+*++A-'0');}int
G(int n){while((k=1<<n)>p)d+=p*(by)((*z++^134)+84),p*=64;PN=d&(k-1);d/=k,p
/=k;return PN;}int main(int C,char**V){if(V)a0=*V;for(P[CO=i=0]=907;++i<12;P[i
]=P[i-1]*89/84);while(--C)if(*(A=*++V)=='-')while(*A&&A[1])
*++A=='r'?gn(),0:*A=='d'?OF=1:*A=='h'?h=1:0;
fprintf(stderr,"%s\n\nUsage:\t %s [options]\n"
"Example: %s\n\t %s -dr22050|esdcat -b -m -r 22050\nOptions:\n"
"\t -d\tPlay in linear format instead & use /dev/dsp if not piped\n"
"\t -r#\tSelect sampling rate in Hz\n\t -h\tThis help\n\n",Title,a0,a0,a0);
if(h)exit(0);for(r=3220,LS=1810,c=4;c--;)for(a=0;a<r;)if((S=G(7))-7)
l[c+8*a+4]=S,l[c+8*a++]=G(6)^63;else for(i=G(10),S=G(8);S--;a++)
l[a*8+4+c]=l[(a-i)*8+4+c],l[a*8+c]=l[(a-i)*8+c];
for(i=IL[0]=IL[1]=32;--i>=0;s[0][i]=(i&24)?170:20)s[1][i]=16*(i<16?i:31-i);
for(i=IL[2]=999;--i>=0;s[2][i]=(a=a*999+1)%200);
if(isatty(fileno(fo=stdout)))fo=fopen(A=OF?"/dev/dsp":
"/dev/audio","wb");if(!fo){perror(A);exit(-1);}a=c=i=sn[29]=0;
for(fprintf(stderr,"Playing built-in song (%s)...\n",sn);;
i<3?i++:((c?c--^Out(S/9):++a>=r?a=LS:(c=f*5/T)),i=S=0)){
x=l[a*8+4+i],j=i?i-1:0;H[i] += P[x%12]<<x/12;
if(IL[j])S += (s[j][((unsigned)H[i]/f)%IL[j]]-128)*l[a*8+i];}}
And another:
#define _POSIX_SOURCE 1 /* Song length: 94 seconds (89 seconds of loop). */
/* This source was optimized with Findbest of the Bisqwit's Midtools pack */
/*/echo "$0 is not an executable but a C source file. Compiling it now..."
n=`basename $0`;gcc -O2 -Wall -W -pedantic -o /tmp/$n "$0";/tmp/$n $*;exit; */
static char*Title="NES-S3M player for /dev/audio (8-bit, µ-law)\n"
"This file has been compiled from a file created with intgen.";
typedef unsigned char by;char*A,*In,*tmp="nesmusa.$$$",*a0;
static by*z=(by*)"1v;FLTehJaWk1``f2:dwP2J3l>XEAKRn<eAJSl>YECkoF=LdSRWk@ioFXve"
"SdWkHtoF@we3iWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhw"
"e3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFh"
"we3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoFhwe3vWkPwoF"
"hwe3vWkPwoFhwe3vWkPwoFhwe3vWkPw_nLPwLGn30BZWk=`aF=ve3]WkABYlSu0PLjoV1TdCQWk@"
"ioV\\LFuHG08_veO0?kLhoFLve?9=kPwoFuweCW?kdLafwCd_0=kPjoFoveSaDkl_bF=ve3]WkDb"
"aFuYdCQWk@ioFSTd3vWklwGmCZXLAnYwRUNZHow9nCPBZWMGZVLuXjAmgu2\\H_0=nWPRU:d<k9n"
"Cd_HGaveOP2OGfVTuhjamgu2\\H_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fVTuK_2:nwgRU@M3",
o[256],w[256][64],NN[8],s[5][65536],l[299999],
sn[32]="DrWily Alpha by NESMusa";
#include <stdio.h>
#include <unistd.h>
static int ss,m,IN,IV[99],IP[256],PP[100],b,M,I,D[99],Bxx,Cxx,B,Ss,CP,
At[256][64],Np=0,S=SEEK_SET,h,OF,PN,d,p=1,r,k,i,a,c,CO,j,x,T=250,f=8000,LS=0,
P[12],H[99],IL[99];FILE*fo,*fi;
#define rw(a) a=fgetc(fi),a|=fgetc(fi)<<8
static int Out(int v){int e=0,s=1,f=0;if(OF)v=128+v/30;else for((s=(v<0))?v=-v
:0;e<8;e++)if((f=((v+32)>>(e+1))-16)<16)break;return fputc(OF?v:~((s<<7)|(e<<4
)|f),fo);}void gn(void){for(f=0;A[1]>='0'&&A[1]<='9';f=f*10+*++A-'0');}int
G(int n){while((k=1<<n)>p)d+=p*(by)((*z++^4)-52),p*=64;PN=d&(k-1);d/=k,p/=k;
return PN;}int main(int C,char**V){
if(V)fi=stdin,a0=*V;for(P[CO=a=i=C?0:(fseek(fo,0,SEEK_END),r=ftell(fo)/8,rewind(fo),
fread(l,8,r,fo),fclose(fo),remove(tmp),z=(by*)In,main(-1,0))]=907;++i<12;P[i
]=P[i-1]*89/84);if(C<0){if(isatty(fileno(fo=stdout)))fo=fopen(A=OF?"/dev/dsp":
"/dev/audio","wb");if(!fo){perror(A);exit(-1);}a=c=i=sn[29]=0;
for(fprintf(stderr,"Playing %s (%s)...\n",*z-'*'?z:z+1,sn);;
i<3?i++:((c?c--^Out(S/9):++a>=r?a=LS:(c=f*5/T)),i=S=0)){
x=l[a*8+4+i],j=i?i-1:0;H[i] += (D[j]?D[j]*P[x%12]/14500:P[x%12])<<x/12;
if(IL[j])S += (s[j][((unsigned)H[i]/f)%IL[j]]-128)*l[a*8+i];}}
while(--C)if(*(A=*++V)-'-')In=A;else if(A[1])while(*A&&A[1])
*++A=='r'?gn(),0:*A=='d'?OF=1:*A=='h'?h=1:0;else In="*stdin";
if(!In){fprintf(stderr,"%s\n\nUsage:\t %s [options] nesfile.s3m\n"
"Example: %s mman3_d2.s3m\n\t %s -dr22050 cv2b.s3m|esdcat "
"-b -m -r 22050\nOptions:\n"
"\t -d\tPlay in linear format instead & use /dev/dsp if not piped\n"
"\t -r#\tSelect sampling rate in Hz\n\t -h\tThis help\n\n",Title,a0,a0,a0);
if(h)exit(0);for(r=4704,LS=224,c=4;c--;)for(a=0;a<r;)if((S=G(7))-118)
l[c+8*a+4]=S,l[c+8*a++]=G(6)^63;else for(i=G(9),S=G(6);S--;a++)
l[a*8+4+c]=l[(a-i)*8+4+c],l[a*8+c]=l[(a-i)*8+c];
for(i=IL[0]=IL[1]=32;--i>=0;s[0][i]=(i&24)?170:20)s[1][i]=16*(i<16?i:31-i);
for(i=IL[2]=999;--i>=0;s[2][i]=(a=a*999+1)%200);z=(by*)"built-in song";
main(i,0);}if(*In-'*')fi=fopen(In,"rb");if(!fi||!(fo=fopen(tmp,"wb+")))
{perror(fi?tmp:In);return-1;}fread(sn,1,32,fi);rw(m);rw(IN);
rw(PN);fseek(fi,49,S);x=fgetc(fi);T=fgetc(fi)*2;fseek(fi,0x60,S);
fread(o,m,1,fi);for(i=0;i<IN;i++)rw(IP[i]);for(i=0;i<PN;i++)rw(PP[i]);
for(i=0;i<IN;i++)fseek(fi,IP[i]*16+13,S),fgetc(fi),rw(LS),rw(IL[i]),rw(j),
fseek(fi,8,SEEK_CUR),IV[i]=fgetc(fi),fseek(fi,3,SEEK_CUR),
rw(D[i]),fseek(fi,LS*16,S),fread(s[i],1,IL[i],fi);
for(;;){if(CO>=m)main(0,V);if((CP=o[CO])-254){fseek(fi,PP[CP]*16,S);
rw(i);if(!i)PP[CP]=0;if(PP[CP])fread(z=s[4],i-=2,1,fi);for(r=0;r<64;r++){if(!r)ss=1;
a?0:w[CO][r]?(LS=At[CO][r]),main(0,V):(At[CO][r]=ftell(fo)/8,(w[CO][r]=1));
Bxx=Cxx=-1,Ss=ss,j=B=ss=0;if(PP[CP])while((b=*z++)-(M=I=0)){
if(b&32){if(!a){if(*z<254)NN[(b&3)+4]=*z%16+12*(*z/16);else
if(*z==254)NN[b&3]=0;if(z[1]&&*z!=254)NN[b&3]=IV[z[1]-1];}z+=2;}
if(b&64){if(!a)NN[b&3]=*z;z++;}if(b&128){M=*z++;I=*z++;}
if(M==1&&!a)x=I;M==2?Bxx=I:M==3?Cxx=I:M==4?ss=1:0;
if(M==19){if(I/16==11)*((B=I&15)?&ss:&Ss)=1;if(I/16==14)j=I&15;}}if(a)
a--;else{if(Ss)Np=ftell(fo);for(i=(j+1)*x;i;i--)fwrite(NN,1,8,fo);
if(B){c=ftell(fo)-Np;fseek(fo,Np,S);fread(l,1,c,fo);
fseek(fo,Np+c,S);for(i=B;i;i--)fwrite(l,1,c,fo);}
if(Bxx>=0){CO=Bxx-1;if(Cxx<0)break;}
if(Cxx>=0){a=(Cxx&15)+10*(Cxx/16);break;}}}}CO++;}}
Running example:
./program -dr44100|aplay - -fcd -c1 -fU8
Thus the technology improves! :)
I installed them also here:
When I wrote these, I was not aware of the fact that NES has different square wave types. (But iNES didn't write the distinction to its .snd files either.)
These are also weirdly transponed (play at wrong pitch).