1 /* NetHack 3.6 cvtsnd.c $NHDT-Date: 1432512794 2015/05/25 00:13:14 $ $NHDT-Branch: master $:$NHDT-Revision: 1.7 $ */
2 /* Copyright (c) 1995, Andrew Church, Olney, Maryland */
3 /* NetHack may be freely redistributed. See license for details. */
12 char misc
[64]; /* rest of MacBinary header */
27 long samples
; /* 'samplesPerHiCycle' in the docs - usually 32, so
30 char octaves
, compress
;
33 long nlen
; /* should be 64; see name[] comment */
34 char name
[64]; /* for simplicity, i.e. just fwrite() entiree header */
39 main(int ac
, char **av
)
44 static char buf
[16384];
48 fprintf(stderr
, "Usage: %s input-file output-file\n", av
[0]);
51 if (!(in
= fopen(av
[1], "r"))) {
52 fprintf(stderr
, "Can't open input file\n");
55 if (!(out
= fopen(av
[2], "w"))) {
56 fprintf(stderr
, "Can't open output file\n");
60 fread(&aiff
, sizeof(aiff
), 1, in
);
61 memcpy(iff
.FORM
, "FORM", 4);
62 iff
.flen
= sizeof(iff
) + aiff
.sndlen
- 8;
63 memcpy(iff
._8SVX
, "8SVX", 4);
64 memcpy(iff
.VHDR
, "VHDR", 4);
66 iff
.oneshot
= aiff
.sndlen
;
73 memcpy(iff
.NAME
, "NAME", 4);
75 strncpy(iff
.name
, aiff
.name
, 62);
76 iff
.name
[aiff
.namelen
] = 0;
77 memcpy(iff
.BODY
, "BODY", 4);
78 iff
.blen
= aiff
.sndlen
;
79 fwrite(&iff
, sizeof(iff
), 1, out
);
82 if (len
>= sizeof(buf
))
83 n
= fread(buf
, 1, sizeof(buf
), in
);
85 n
= fread(buf
, 1, len
, in
);
87 fwrite(buf
, 1, n
, out
);
93 fprintf(stderr
, "Warning: %ld bytes of sample missing\n", len
);