source: golgotha/src/i4/sound/sound3d.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: 3.1 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 SOUND3D_HH
10#define SOUND3D_HH
11
12#include "sound/sound_types.hh"
13#include "init/init.hh"
14#include "math/vector.hh"
15
16class i4_3d_sound_parameters
17//{{{
18{
19protected:
20  i4_3d_sound_parameters() {}
21public:
22  static i4_3d_vector null;
23
24  i4_frequency frequency;
25  i4_volume volume;
26  i4_3d_vector position, velocity;
27  i4_bool looping, reverb;
28 
29  i4_3d_sound_parameters(i4_frequency freq,
30                         i4_volume vol = I4_SOUND_VOLUME_LEVELS-1,
31                         const i4_3d_vector& pos = null,
32                         const i4_3d_vector& vel = null,
33                         i4_bool looping = i4_F,
34                         i4_bool reverb = i4_F)
35    : frequency(freq),
36      volume(vol),
37      position(pos),
38      velocity(vel),
39      looping(looping),
40      reverb(reverb) {}
41
42  void set(const i4_3d_sound_parameters &param)
43  //{{{
44  {
45    frequency = param.frequency;
46    volume = param.volume;
47    position = param.position;
48    velocity = param.velocity;
49    looping = param.looping;
50    reverb = param.reverb;
51  }
52  //}}}
53};
54//}}}
55
56class i4_3d_voice_class : public i4_3d_sound_parameters
57{
58protected:
59  i4_3d_voice_class() : i4_3d_sound_parameters() {}
60public:
61  i4_3d_voice_class(const i4_3d_sound_parameters &param)
62    : i4_3d_sound_parameters(param.frequency,
63                             param.volume,
64                             param.position,
65                             param.velocity,
66                             param.looping,
67                             param.reverb) {}
68
69  typedef i4_bool (*completion_function_type)(void *_context);
70
71  virtual void set_completer(completion_function_type completer, void *_context) = 0;
72  virtual void play() = 0;
73  virtual void update() = 0;
74};
75
76class i4_3d_sound_manager_class;
77extern i4_3d_sound_manager_class *i4_3d_sound_man;
78
79class i4_3d_sound_manager_class : public i4_init_class
80{
81protected:
82public:
83  virtual void init() { i4_3d_sound_man = this; }
84  virtual void load_sounds(w32 max_sounds) = 0;
85  virtual i4_3d_voice_class *alloc(i4_sound_id sound_id, const i4_3d_sound_parameters& param) = 0;
86  i4_3d_voice_class *play(i4_sound_id sound_id, const i4_3d_sound_parameters& param)
87  //{{{
88  {
89    i4_3d_voice_class *voc = alloc(sound_id,param);
90   
91    if (voc)
92      voc->play();
93
94    return voc;
95  }
96  //}}}
97
98#ifndef I4_RETAIL
99  virtual char *name() const = 0;
100#endif
101};
102
103class i4_null_3d_sound_class;
104extern class i4_null_3d_sound_class i4_null_3d_sound;
105
106#endif
107
108//{{{ Emacs Locals
109// Local Variables:
110// folded-file: t
111// End:
112//}}}
Note: See TracBrowser for help on using the repository browser.