-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundHeader.h
142 lines (115 loc) · 4.89 KB
/
SoundHeader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
//
// Programmer: Craig Stuart Sapp <[email protected]>
// Creation Date: Fri May 23 21:40:12 GMT-0800 1997
// Last Modified: Fri May 23 21:40:12 GMT-0800 1997
// Filename: ...sig/maint/code/base/SoundHeader/SoundHeader.h
// Web Address: http://sig.sapp.org/include/sigBase/SoundHeader.h
// Documentation: http://sig.sapp.org/doc/classes/SoundHeader
// Syntax: C++
//
#ifndef _SOUNDHEADER_H_INCLUDED
#define _SOUNDHEADER_H_INCLUDED
#include "FileIO.h"
#ifndef OLDCPP
#include <iostream>
using namespace std;
#else
#include <iostream.h>
#endif
// define recognized NeXT/Sun soundfile formats
#ifndef SND_FORMAT_UNSPECIFIED
#define SND_FORMAT_UNSPECIFIED (0)
#define SND_FORMAT_MULAW_8 (1)
#define SND_FORMAT_LINEAR_8 (2)
#define SND_FORMAT_LINEAR_16 (3)
#define SND_FORMAT_LINEAR_24 (4)
#define SND_FORMAT_LINEAR_32 (5)
#define SND_FORMAT_FLOAT (6)
#define SND_FORMAT_DOUBLE (7)
#endif
// internal Soundheader format types.
#define FORMAT_NONE (0)
#define FORMAT_SND_LINEAR_16 (1)
#define FORMAT_AU_LINEAR_16 (1)
#define FORMAT_SND_MULAW_8 (2)
#define FORMAT_AU_MULAW_8 (2)
#define FORMAT_SND_LINEAR_8 (3)
#define FORMAT_AU_LINEAR_8 (3)
#define FORMAT_SND_LINEAR_24 (4)
#define FORMAT_AU_LINEAR_24 (4)
#define FORMAT_SND_LINEAR_32 (5)
#define FORMAT_AU_LINEAR_32 (5)
#define FORMAT_SND_FLOAT (6)
#define FORMAT_AU_FLOAT (6)
#define FORMAT_SND_DOUBLE (7)
#define FORMAT_AU_DOUBLE (7)
#define FORMAT_WAV_LINEAR_8 (8)
#define FORMAT_WAV_LINEAR_16 (9)
#define FORMAT_WAV_LINEAR_24 (10)
#define FORMAT_WAV_LINEAR_32 (11)
#define FORMAT_TXT (12)
#define FORMAT_DEFAULT (1)
// sound file types that are recognized by the SoundHeader Class
#define TYPE_NONE (0)
#define TYPE_SND (1)
#define TYPE_WAV (2)
#define TYPE_WAV_PCM (2)
#define TYPE_TEXT (3)
#define TYPE_DEFAULT (4)
class SoundHeader {
public:
SoundHeader (void);
SoundHeader (char* aFilename);
SoundHeader (SoundHeader& aHeader);
~SoundHeader ();
int getBitsPerSample () const;
int getBlockAlign () const;
int getBytesPerSample () const;
int getChannels () const;
const char* getComment () const;
int getCommentSize () const;
int getDataByteOffset (int aType = TYPE_NONE) const;
int getDataByteSize (void) const;
int getInputType (void) const;
int getNextFormat (void) const;
int getOutputType (void) const;
int getSamples (void) const;
int getSrate (void) const;
void modifyFormat (const char* filename);
SoundHeader& operator= (const SoundHeader& h);
void setChannels (int numChannels);
void setComment (const char* aString);
void setHeader (char *filename);
void setHighMono (char* comment = "");
void setHighStereo (char* comment = "");
void setNextFormat (int format = SND_FORMAT_LINEAR_16);
int setOutputType (int format = TYPE_DEFAULT);
void setSamples (int numSamples);
void setSrate (int aSrate);
void print (void);
protected:
int bitsPerSample; // needed for WAVE files mostly
int channels; // number of channels
int commentLength; // length of comment string
char* commentString; // comment string (not for WAVE format)
int NeXT_DataFormat; // needed for NeXT/Sun files
int samples; // number of samples in the data (per channel)
int samplingRate; // (rounded) samping rate
int inputType; // header type that was read in.
int outputType; // format for operator<<
// derived data variables:
int blockAlign; // bitspersample/8*channels
int sampleBytes; // bytes per sample
// private functions:
int getFormat(const char *filename);
void guessNextFormat(void);
void processInSndFormat(const char* filename);
void processInWavFormat(const char* filename);
void updateDerivedVariables(void);
};
ostream& operator<<(ostream& output, SoundHeader& aSoundHeader);
FileIO& operator<<(FileIO& output, SoundHeader& aSoundHeader);
#define SIG_LITTLE_ENDIAN (0)
#define SIG_BIG_ENDIAN (1)
#endif /* _SOUNDHEADER_H_INCLUDED */
// md5sum: b6f79e8be91b24265324e6c7d8dd44c5 SoundHeader.h [20010708]