source: golgotha/src/i4/sound/sfx_id.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 11 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 2.8 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef S1_SFX_ID_HH
10#define S1_SFX_ID_HH
11
12#include "arch.hh"
13#include "math/vector.hh"
14
15class i4_voice_class;
16class i4_transform_class;
17class i4_file_class;
18
19enum
20{
21  S1_STREAMED=1,
22  S1_3D=2
23};
24
25       
26class s1_sfx_ref;
27class s1_sound_handle;
28
29// the sound manager will call a callback when a looping 3d sound
30// enters hearing distance and is to be played.  The callback should
31// return it's current velocity.
32typedef void (*s1_3d_sound_callback)(s1_sound_handle *handle,
33                                     float &xv, float &yv, float &zv,
34                                     float &frequency_scale);
35
36class s1_sound_handle
37{
38public:
39  float x, y,z, xv, yv, zv;         // current position of source
40  float frequency_scale;
41
42
43  void setup(float _x, float _y, float _z,
44             float _xv, float _yv, float _zv,
45             float _frequency_scale=1.0)
46  { x=_x; y=_y;  z=_z;  xv=_xv; yv=_yv; zv=_zv; frequency_scale=_frequency_scale; }
47
48
49  // don't change these directly!
50  s1_sfx_ref *originator;     
51  float dist_sqrd;
52  s1_sound_handle *next;
53  static s1_sound_handle *first;
54  sw16 channel_on;
55  i4_bool playing;
56 
57  s1_sound_handle();
58  ~s1_sound_handle();
59};
60
61
62class s1_sfx_ref
63{
64public:
65  static s1_sfx_ref *first;
66  s1_sfx_ref        *next;
67  w8                 flags;
68  w16                id;
69  w8                 priority;
70  char              *name;
71  char              *file_defined_in;
72  int                line_defined_on;
73  i4_voice_class    *base_sfx;
74  float              hearable_distance_sqrd;
75
76  s1_sfx_ref(char *filename, w8 flags, w8 priority, float dist, char *file, int line);
77  ~s1_sfx_ref();
78
79  // for playing static (non-looping/moving) 3d sound
80  void play(float x=0, float y=0, float z=0);
81
82  void play_looping(s1_sound_handle &handle);
83};
84
85void s1_end_looping(s1_sound_handle &handle);
86
87
88void s1_load();      // load all the referenced static & dynamic sounds
89void s1_unload();
90void s1_get_camera_pos(i4_3d_vector &pos);
91void s1_set_camera_pos(i4_transform_class &new_cam_transform);
92char *s1_get_sfx_path();
93void s1_save_sfx_list(i4_file_class *fp);
94
95
96#define S1_SFX(name, filename, type, priority) \
97  static s1_sfx_ref name(filename, type, priority, 20, __FILE__,__LINE__)
98
99#define S1_SFX_DISTANCE(name, filename, type, priority, distance) \
100  static s1_sfx_ref name(filename, type, priority, distance,  __FILE__,__LINE__)
101
102#endif
103
Note: See TracBrowser for help on using the repository browser.