]> Shamusworld >> Repos - thunder/blob - test/wav.cpp
Fixes to makefile, file permissions.
[thunder] / test / wav.cpp
1 // WAV file header reader
2 // (Last build: 7/21/1998)
3 //
4 // by James L. Hammons
5 //
6 // (c) 1998 Underground Software
7
8 #include <dos.h>
9 #include <pc.h>
10 #include <go32.h>
11 #include <dpmi.h>
12 #include <conio.h>
13 #include <fstream.h>
14 #include <string.h>
15 #include <iomanip.h>
16 #include <iostream.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <time.h>
20 #include <new.h>
21
22 #define BYTE  unsigned char
23 #define WORD  unsigned short int
24 #define DWORD unsigned long int
25
26 //
27 // Main loop
28 //
29 int main(int argc, char * argv[])
30 {
31   fstream ff;                       // Declare fstream without file hooks...
32   char file[200];
33   BYTE ch;
34
35   strcpy(file, ".\\sounds\\");
36
37   if (argc == 2)
38   {
39     strcat(file, argv[1]);
40   }
41   else
42   {
43     strcat(file, "fm12.wav");
44   }
45   ff.open(file, ios::binary | ios::in);
46
47   cout << "Header: [";
48   for(int i=0; i<4; i++)  { ff.get(ch);  cout << ch; }
49   cout << "]" << endl;
50
51   DWORD len;
52
53   ff.get(ch);  len = (int)ch;
54   ff.get(ch);  len |= (int)ch << 8;
55   ff.get(ch);  len |= (int)ch << 16;
56   ff.get(ch);  len |= (int)ch << 24;
57
58   cout << "Length of header chunk: [" << hex << len << "]" << endl;
59
60   cout << "Header2: [";
61   for(int i=0; i<8; i++)  { ff.get(ch);  cout << ch; }
62   cout << "]" << endl;
63
64   ff.get(ch);  len = (int)ch;
65   ff.get(ch);  len |= (int)ch << 8;
66   ff.get(ch);  len |= (int)ch << 16;
67   ff.get(ch);  len |= (int)ch << 24;
68
69   cout << "Length of header2 chunk: [" << hex << len << "]" << endl;
70
71   for(int i=0; i<(signed)len; i++)
72   {
73     ff.get(ch);  cout << hex << (int)ch << " ";
74   }
75   cout << endl;
76
77   cout << "Header3: [";
78   for(int i=0; i<4; i++)  { ff.get(ch);  cout << ch; }
79   cout << "]" << endl;
80
81   ff.get(ch);  len = (int)ch;
82   ff.get(ch);  len |= (int)ch << 8;
83   ff.get(ch);  len |= (int)ch << 16;
84   ff.get(ch);  len |= (int)ch << 24;
85
86   cout << "Length of header3 chunk: [" << hex << len << "]" << endl;
87
88   for(int i=0; i<(signed)len; i++)
89   {
90     ff.get(ch);  cout << hex << (int)ch << " ";
91   }
92   cout << endl;
93
94   for(int i=0; i<120; i++)
95   {
96     ff.get(ch);  cout << hex << (int)ch << " ";
97   }
98   cout << endl;
99
100   ff.close(); // Close tracelog
101 }