-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
797 changed files
with
74,544 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
/* | ||
adv2wav | ||
(c)2001 BERO | ||
http://www.geocities.co.jp/Playtown/2004/ | ||
[email protected] | ||
adx info from: http://ku-www.ss.titech.ac.jp/~yatsushi/adx.html | ||
*/ | ||
|
||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
#include <fcntl.h> | ||
|
||
long read_long(unsigned char *p) | ||
{ | ||
return (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3]; | ||
} | ||
|
||
int read_word(unsigned char *p) | ||
{ | ||
return (p[0]<<8)|p[1]; | ||
} | ||
|
||
typedef struct { | ||
int s1,s2; | ||
} PREV; | ||
|
||
//#define BASEVOL 0x11e0 | ||
#define BASEVOL 0x4000 | ||
|
||
int convert(short *out,unsigned char *in,PREV *prev) | ||
{ | ||
int scale = ((in[0]<<8)|(in[1])); | ||
int i; | ||
int s0,s1,s2,d; | ||
// int over=0; | ||
|
||
in+=2; | ||
s1 = prev->s1; | ||
s2 = prev->s2; | ||
for(i=0;i<16;i++) { | ||
d = in[i]>>4; | ||
if (d&8) d-=16; | ||
s0 = (BASEVOL*d*scale + 0x7298*s1 - 0x3350*s2)>>14; | ||
// if (abs(s0)>32767) over=1; | ||
if (s0>32767) s0=32767; | ||
else if (s0<-32768) s0=-32768; | ||
*out++=s0; | ||
s2 = s1; | ||
s1 = s0; | ||
|
||
d = in[i]&15; | ||
if (d&8) d-=16; | ||
s0 = (BASEVOL*d*scale + 0x7298*s1 - 0x3350*s2)>>14; | ||
// if (abs(s0)>32767) over=1; | ||
if (s0>32767) s0=32767; | ||
else if (s0<-32768) s0=-32768; | ||
*out++=s0; | ||
s2 = s1; | ||
s1 = s0; | ||
} | ||
prev->s1 = s1; | ||
prev->s2 = s2; | ||
|
||
// if (over) putchar('.'); | ||
} | ||
|
||
int adx2wav(char *infile,char *outfile) | ||
{ | ||
FILE *in,*out; | ||
unsigned char buf[18*2]; | ||
short outbuf[32*2]; | ||
int offset; | ||
int channel,freq,size,wsize; | ||
PREV prev[2]; | ||
|
||
static struct { | ||
char hdr1[4]; | ||
long totalsize; | ||
|
||
char hdr2[8]; | ||
long hdrsize; | ||
short format; | ||
short channel; | ||
long freq; | ||
long byte_per_sec; | ||
short blocksize; | ||
short bits; | ||
|
||
char hdr3[4]; | ||
long datasize; | ||
} wavhdr = { | ||
"RIFF",0, | ||
"WAVEfmt ",0x10,1/* PCM */,2,44100,44100*2*2,2*2,16, | ||
"data" | ||
}; | ||
|
||
if (strcmp(infile,"-")==0) | ||
in = stdin; | ||
else | ||
in = fopen(infile,"rb"); | ||
if (in==NULL) { | ||
printf("can't open infile %s\n",outfile); | ||
return -1; | ||
} | ||
|
||
fread(buf,1,16,in); | ||
|
||
channel = buf[7]; | ||
freq = read_long(buf+8); | ||
size = read_long(buf+12); | ||
|
||
offset = read_word(buf+2)-2; | ||
fseek(in,offset,SEEK_SET); | ||
fread(buf+1,1,6,in); | ||
|
||
if (buf[0]!=0x80 || memcmp(buf+1,"(c)CRI",6)) { | ||
puts("not adx!"); | ||
return -1; | ||
} | ||
|
||
wavhdr.channel = channel; | ||
wavhdr.freq = freq; | ||
wavhdr.blocksize = channel*sizeof(short); | ||
wavhdr.byte_per_sec = freq*wavhdr.blocksize; | ||
wavhdr.datasize = size*wavhdr.blocksize; | ||
wavhdr.totalsize = wavhdr.datasize + sizeof(wavhdr)-8; | ||
|
||
if (strcmp(outfile,"-")==0) | ||
out = stdout; | ||
else | ||
out = fopen(outfile,"wb"); | ||
if (out==NULL) { | ||
printf("can't open outfile %s\n",outfile); | ||
return -1; | ||
} | ||
|
||
fwrite(&wavhdr,1,sizeof(wavhdr),out); | ||
|
||
prev[0].s1 = 0; | ||
prev[0].s2 = 0; | ||
prev[1].s1 = 0; | ||
prev[1].s2 = 0; | ||
|
||
|
||
if (channel==1) | ||
while(size) { | ||
fread(buf,1,18,in); | ||
convert(outbuf,buf,prev); | ||
if (size>32) wsize=32; else wsize = size; | ||
size-=wsize; | ||
fwrite(outbuf,1,wsize*2,out); | ||
} | ||
else if (channel==2) | ||
while(size) { | ||
short tmpbuf[32*2]; | ||
int i; | ||
|
||
fread(buf,1,18*2,in); | ||
convert(tmpbuf,buf,prev); | ||
convert(tmpbuf+32,buf+18,prev+1); | ||
for(i=0;i<32;i++) { | ||
outbuf[i*2] = tmpbuf[i]; | ||
outbuf[i*2+1] = tmpbuf[i+32]; | ||
} | ||
if (size>32) wsize=32; else wsize = size; | ||
size-=wsize; | ||
fwrite(outbuf,1,wsize*2*2,out); | ||
} | ||
fclose(in); | ||
fclose(out); | ||
|
||
return 0; | ||
} | ||
|
||
int main(int argc,char**argv) | ||
{ | ||
int i; | ||
if (argc<2) { | ||
puts("DC/SS adx to wav converter by bero\n adx2wav <infile>\n http://www.geocities.co.jp/Playtown/2004/"); | ||
return -1; | ||
} | ||
|
||
// _fmode = O_BINARY; | ||
|
||
for(i=1;i<argc;i++) { | ||
char *infile = argv[i]; | ||
char *p,outfile[256]; | ||
|
||
p = strrchr(infile,'\\'); | ||
if (p) p++; else p=infile; | ||
strcpy(outfile,p); | ||
|
||
p = strrchr(outfile,'.'); | ||
if (!p) p = outfile+strlen(outfile); | ||
strcpy(p,".wav"); | ||
|
||
printf("%s -> %s\n",infile,outfile); | ||
|
||
adx2wav(infile,outfile); | ||
} | ||
return 0; | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
adx2wav : DreamCast ADX->WAV converter | ||
|
||
http://www.geocities.co.jp/Playtown/2004/ | ||
[email protected] | ||
|
||
This software convert DreamCast ADX ADPCM sound (.adx) to Windows WAVE file (.wav). | ||
|
||
adx2wav <adx_file> | ||
|
||
convert .adx to .wav | ||
|
||
afs_extract <afs_file> | ||
|
||
extract packed .AFS file to each .adx file. | ||
|
||
IMPORTANT: | ||
don't distruibute converted data follows copyright law in your country. | ||
at least Japanese law, "personal use" only. "personal use" means yourself, your family, and so on. | ||
|
||
|
||
DC��ADX�����t�@�C��(.ADX)��Windows WAVE�`��(.WAV)�ɕϊ����܂��B | ||
|
||
adx2wav <adx_file> | ||
|
||
.adx �� .wav �ɕϊ����܂� | ||
|
||
afs_extract <afs_file> | ||
|
||
�����̃t�@�C�����܂Ƃ߂�ꂽ.AFS�t�@�C�����X��adx�t�@�C���ɕ������܂��B | ||
afs�̒���adx�Ƃ͌���܂���B | ||
|
||
�d�v: | ||
�ϊ������f�[�^��s���葽���ɔz�z���Ȃ��ł��������B | ||
���Ȃ��Ƃ����{�̖@���ł́A"���I���p"�Ɍ����܂��B | ||
"���I���p"�Ƃ́A�����A�Ƒ������w���܂��B | ||
|
||
0.2 change adx check / volume | ||
first release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* | ||
afxcut | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
int afs_extract(char *name) | ||
{ | ||
FILE *fp,*out; | ||
int i,n; | ||
char buf[0x8000]; | ||
|
||
struct { | ||
char id[4]; | ||
long num; | ||
} hdr; | ||
|
||
struct { | ||
long offset; | ||
long size; | ||
} *idx; | ||
|
||
char basename[256],*p; | ||
strcpy(basename,name); | ||
|
||
p = strrchr(basename,'.'); | ||
if (p) *p=0; | ||
|
||
fp = fopen(name,"rb"); | ||
if (fp==NULL) return -1; | ||
|
||
fread(&hdr,1,8,fp); | ||
if (memcmp(hdr.id,"AFS",4)) { | ||
fclose(fp); | ||
printf("not AFS\n"); | ||
return -1; | ||
} | ||
n = hdr.num; | ||
|
||
printf("%s - %d\n",name,n); | ||
|
||
idx = malloc(sizeof(*idx)*n); | ||
|
||
fread(idx,8,n,fp); | ||
for(i=0;i<n;i++) { | ||
int size; | ||
char outfile[256]; | ||
sprintf(outfile,"%s_%02d.adx",basename,i); | ||
|
||
out = fopen(outfile,"wb"); | ||
|
||
fseek(fp,idx[i].offset,SEEK_SET); | ||
size = idx[i].size; | ||
|
||
printf("%s %08x %08x\n",outfile,idx[i].offset,size); | ||
|
||
while(size) { | ||
int rsize = size<sizeof(buf)?size:sizeof(buf); | ||
rsize = fread(buf,1,rsize,fp); | ||
fwrite(buf,1,rsize,out); | ||
size-=rsize; | ||
} | ||
|
||
fclose(out); | ||
// putchar('.'); | ||
} | ||
|
||
free(idx); | ||
|
||
fclose(fp); | ||
|
||
return -1; | ||
} | ||
|
||
int main(int argc,char **argv) | ||
{ | ||
int i; | ||
|
||
if (argc<2) { | ||
printf("DreamCast AFS extract ADX\n"); | ||
return -1; | ||
} | ||
|
||
for(i=1;i<argc;i++) | ||
afs_extract(argv[i]); | ||
return 0; | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.