1 /******************************************************************
2 * CopyPolicy: GNU Public License 2 applies
3 * Copyright (C) 1998 Monty xiphmont@mit.edu
4 * and Heiko Eissfeldt heiko@escape.colossus.de
6 * Writes wav and aifc headers
8 ******************************************************************/
15 static void PutNum(long num
,int f
,int endianness
,int bytes
){
25 if(write(f
,&c
,1)==-1){
26 perror("Could not write to output.");
36 void WriteWav(int f
,long bytes
){
39 write(f
,"RIFF",4); /* 0-3 */
40 PutNum(bytes
+44-8,f
,0,4); /* 4-7 */
41 write(f
,"WAVEfmt ",8); /* 8-15 */
42 PutNum(16,f
,0,4); /* 16-19 */
43 PutNum(1,f
,0,2); /* 20-21 */
44 PutNum(2,f
,0,2); /* 22-23 */
45 PutNum(44100,f
,0,4); /* 24-27 */
46 PutNum(44100*2*2,f
,0,4); /* 28-31 */
47 PutNum(4,f
,0,2); /* 32-33 */
48 PutNum(16,f
,0,2); /* 34-35 */
49 write(f
,"data",4); /* 36-39 */
50 PutNum(bytes
,f
,0,4); /* 40-43 */
53 void WriteAiff(int f
,long bytes
){
57 /* Again, quick and dirty */
59 write(f
,"FORM",4); /* 4 */
60 PutNum(size
-8,f
,1,4); /* 8 */
61 write(f
,"AIFF",4); /* 12 */
63 write(f
,"COMM",4); /* 16 */
64 PutNum(18,f
,1,4); /* 20 */
65 PutNum(2,f
,1,2); /* 22 */
66 PutNum(frames
,f
,1,4); /* 26 */
67 PutNum(16,f
,1,2); /* 28 */
68 write(f
,"@\016\254D\0\0\0\0\0\0",10); /* 38 (44.100 as a float) */
70 write(f
,"SSND",4); /* 42 */
71 PutNum(bytes
+8,f
,1,4); /* 46 */
72 PutNum(0,f
,1,4); /* 50 */
73 PutNum(0,f
,1,4); /* 54 */
77 void WriteAifc(int f
,long bytes
){
81 /* Again, quick and dirty */
83 write(f
,"FORM",4); /* 4 */
84 PutNum(size
-8,f
,1,4); /* 8 */
85 write(f
,"AIFC",4); /* 12 */
86 write(f
,"FVER",4); /* 16 */
87 PutNum(4,f
,1,4); /* 20 */
88 PutNum(2726318400UL,f
,1,4); /* 24 */
90 write(f
,"COMM",4); /* 28 */
91 PutNum(38,f
,1,4); /* 32 */
92 PutNum(2,f
,1,2); /* 34 */
93 PutNum(frames
,f
,1,4); /* 38 */
94 PutNum(16,f
,1,2); /* 40 */
95 write(f
,"@\016\254D\0\0\0\0\0\0",10); /* 50 (44.100 as a float) */
97 write(f
,"NONE",4); /* 54 */
98 PutNum(14,f
,1,1); /* 55 */
99 write(f
,"not compressed",14); /* 69 */
100 PutNum(0,f
,1,1); /* 70 */
102 write(f
,"SSND",4); /* 74 */
103 PutNum(bytes
+8,f
,1,4); /* 78 */
104 PutNum(0,f
,1,4); /* 82 */
105 PutNum(0,f
,1,4); /* 86 */