summaryrefslogtreecommitdiff
path: root/3dc/win95/SNDCHUNK.HPP
blob: 86483e5d5a136cfd28ccb536bc7da2dcab58f12d (plain)
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#ifndef _sndchunk_hpp
#define _sndchunk_hpp 1
#include "chnktype.hpp"

#define SoundObjectFlag_NotPlayingAtStart 0x00000001
#define SoundObjectFlag_NoLoop			  0x00000002
	 
class Object_Alternate_Locations_Chunk;
class Sound_Object_Extra_Data_Chunk;

class Sound_Object_Chunk : public Chunk
{
public:
	
	Sound_Object_Chunk (Chunk_With_Children * parent, 
											ChunkVectorInt & pos,
											const char * name
											);
	// constructor from buffer
	Sound_Object_Chunk (Chunk_With_Children * parent, const char * sdata, size_t /*ssize*/);

	~Sound_Object_Chunk ();
	
	ChunkVectorInt position;

	unsigned long inner_range; //millimetres
	unsigned long outer_range; //millimetres
	int max_volume; //from 0 to 127
	int	pitch;	   //pitch shift in 1/1536ths of an actave
	
	int flags;
	int probability;
	int pad3;
	
	char * snd_name;
	char * wav_name;
	
	size_t size_chunk ()
	{
		chunk_size = 12 + 3*4 + 7*4 + strlen(snd_name) + 1;
		if (wav_name)
		{
			chunk_size += strlen (wav_name);
		}
		else
		{
			chunk_size += 1;
		}
		
		chunk_size +=  4 - chunk_size%4;
		return (chunk_size);
	}
	
	void fill_data_block (char *);
	
	ObjectID CalculateID();

	Sound_Object_Extra_Data_Chunk* get_extra_data_chunk();
	Sound_Object_Extra_Data_Chunk* create_extra_data_chunk(); //gets chunk if it exists , otherwise creates a new one

	Object_Alternate_Locations_Chunk* get_alternate_locations_chunk();
	Object_Alternate_Locations_Chunk* create_alternate_locations_chunk(); //gets chunk if it exists , otherwise creates a new one

private:

	friend class Special_Objects_Chunk;


	
};

//For attaching extra data to the sound objects
class Sound_Object_Extra_Data_Chunk : public Chunk_With_Children
{
public:
	Sound_Object_Extra_Data_Chunk (Chunk_With_Children * const parent,const char *, size_t const);
	Sound_Object_Extra_Data_Chunk (Chunk_With_Children * parent,Sound_Object_Chunk*);
	
	Sound_Object_Chunk* get_sound_chunk();
};
	
//Needed so I can match the extra data chunk with the appropriate sound chunk
class Sound_Object_Extra_Name_Chunk : public Chunk
{
public :	
	Sound_Object_Extra_Name_Chunk(Chunk_With_Children* parent,const char*,size_t);
	Sound_Object_Extra_Name_Chunk(Chunk_With_Children* parent,const char* _name);
	~Sound_Object_Extra_Name_Chunk();
	
	char* name;

	
	virtual size_t size_chunk();
	virtual void fill_data_block(char* data_start);
};



#define IndexedSoundFlag_Loop 0x00000001
class Indexed_Sound_Chunk : public Chunk
{
public :

	Indexed_Sound_Chunk(Chunk_With_Children* parent,const char*,const size_t);
	Indexed_Sound_Chunk(Chunk_With_Children* parent);
	~Indexed_Sound_Chunk();

	size_t size_chunk();
	void fill_data_block(char*);

	int index;
	char* wav_name;
	unsigned long inner_range; //millimetres
	unsigned long outer_range; //millimetres
	int max_volume; //from 0 to 127
	int	pitch; //pitch shift in 1/1536ths of an actave
	int flags;
	
	int num_extra_data;
	int* extra_data;
};



/*
struct ChunkSoundWeighting
{
	int index;
	int weighting;
};

//a collection of indeces of possible sounds to play
class Sound_Collection_Chunk : public Chunk
{
public :

	Sound_Collection_Chunk(Chunk_With_Children* parent,const char*,const size_t);
	Sound_Collection_Chunk(Chunk_With_Children* parent);
	~Sound_Collection_Chunk();

	size_t size_chunk();
	void fill_data_block(char*);

	int index;
	
	int num_sounds;
	ChunkSoundWeighting* sounds;

	int spare;

	
};
*/


#endif