1 /* ResidualVM - A 3D game interpreter
2  *
3  * ResidualVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the AUTHORS
5  * file distributed with this source distribution.
6  *
7  * Additional copyright for this file:
8  * Copyright (C) 1999-2000 Revolution Software Ltd.
9  * This code is based on source code created by Revolution Software,
10  * used with permission.
11  *
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25  *
26  */
27 
28 #ifndef ICB_PX_SFX_DESCRIPTION_H
29 #define ICB_PX_SFX_DESCRIPTION_H
30 
31 namespace ICB {
32 
33 // versions...
34 // 100 initial
35 // 101 rearanged
36 // 105 added also to sfxdesc files to be checked by converter
37 //
38 #define SFX_VERSION 105
39 
40 #define NO_LOOPING 0x00
41 #define WAV_LOOPING_FLAG 0x01
42 #define SFX_LOOPING_FLAG 0x02
43 
44 // this class contains an envelope of the form y=ax^3+bx^2+cx+d
45 class CEnvelope {
46 public:
47 	int32 a;
48 	int32 b;
49 	int32 c;
50 	int32 d;
51 	int8 div; // dividing value on the time scale
CEnvelope()52 	CEnvelope() { Reset(); }
Reset()53 	void Reset() {
54 		a = b = c = d = 0;
55 		div = 1;
56 	}
57 };
58 
59 // this class contains a single sfx ready to be saved out. This will go in it's own file eventually...
60 class CSfx {
61 public:
CSfx()62 	CSfx() { Reset(); }
63 
64 	CEnvelope m_volume; // volume where v<=0 => none >=128 => max
65 	CEnvelope m_pitch;  // pitch addition to base pitch (in PSX pitch units where 0x1000=44100hz, etc)
66 
67 	int32 m_duration;   // duration in 128th of second
68 	int32 m_rand_pitch; // random value to add to pitch at start (in PSX pitch units where 0x1000=44100hz, etc)
69 
70 	int32 m_min_distance; // in cm
71 	int32 m_max_distance; // in cm
72 
73 	int8 m_sampleNameOffset; // offset into structure of sampleName...
74 	int8 m_descOffset;       // generally this will be 0 when outputing for the engine since the engine will not need descriptions
75 
76 	int8 m_looping; // BIT 0 is hardware flag, bit 1 is software flag.
77 
78 	int8 m_rand_mode; // mode=0 is normal, choose a random value at startup, mode>0 is some divider of the envelope
79 
Reset()80 	void Reset() {
81 		m_volume.Reset();
82 		m_pitch.Reset();
83 		m_duration = 0;
84 		m_looping = 0;
85 		m_rand_pitch = 0;
86 		m_rand_mode = 0;
87 		m_sampleNameOffset = 0;
88 		m_descOffset = 0;
89 		m_min_distance = 0;
90 		m_max_distance = 0;
91 	}
92 
GetSampleName()93 	const char *GetSampleName() { return (const char *) this + m_sampleNameOffset; }
94 };
95 
96 } // End of namespace ICB
97 
98 #endif
99