source: golgotha/src/i4/sound/dsound/direct_sound.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.3 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 DIRECT_SOUND_HH
10#define DIRECT_SOUND_HH
11
12#include "sound/sound.hh"
13#include "math/transform.hh"
14#include <dsound.h>
15#include "sound/dsound/ia3d.h"
16
17class dsound_buffer_class : public i4_voice_class
18{
19public:
20  DWORD flags;
21  IDirectSoundBuffer   *pDSB;
22  IDirectSound3DBuffer *p3DSB; 
23  IDirectSoundNotify   *pNotify;
24  i4_stream_wav_player *stream_man;
25  float                 hearable_distance;
26
27  i4_stream_wav_player *stream_manager() { return stream_man; }
28  void set_stream_manager(i4_stream_wav_player *s) { stream_man = s; }
29
30  dsound_buffer_class(IDirectSoundBuffer *_pDSB,
31                      DWORD _flags, w32 _buffer_size);
32 
33  ~dsound_buffer_class();
34 
35  virtual void stop();
36  virtual void play();
37  virtual void set_frequency(i4_frequency freq);
38  virtual void set_volume(i4_volume vol);
39  virtual void set_pan(i4_pan pan);
40  virtual void set_looping(i4_bool yes_no);
41  virtual void set_3d_position(i4_float x, i4_float y, i4_float z, i4_bool immediately);
42  virtual void set_3d_velocity(i4_float x,i4_float y,i4_float z, i4_bool immediately);
43
44  virtual void lock(w32 start_position, w32 size,
45                    void *&block1, w32 &block1_size,
46                    void *&block2, w32 &block2_size);
47
48  virtual void unlock(void *block1, w32 block1_size,
49                      void *block2, w32 block2_size);
50
51  //returns whether or not the sound is playing
52  virtual i4_bool is_playing();
53
54
55  i4_frequency get_frequency(); 
56
57  i4_volume get_volume();
58
59  i4_pan get_pan();
60
61
62  virtual w32 get_sound_position();  // current position of the sound
63  virtual void set_sound_position(w32 pos);
64
65  virtual void set_hearable_distance(float x) { hearable_distance=x; }
66  virtual float get_hearable_distance() { return hearable_distance; }
67};
68
69class direct_sound_class : public i4_sound_manager_class
70{
71protected:
72  LPDIRECTSOUND lpDirectSound;
73  IA3d *lpA3D;
74  IDirectSoundBuffer *lpPrimary; 
75
76  void init();
77  void uninit();
78
79  i4_bool initialized;
80  i4_bool setup(); 
81
82
83public:
84  i4_bool use_3d_sound;
85
86  i4_3d_vector listener_position;
87  i4_transform_class listener_transform;
88
89  IDirectSound3DListener *lpListener;
90
91  direct_sound_class()
92  {
93    initialized=i4_F;
94  }
95
96  I4_SOUND_NAME("DirectSound");
97 
98  void set_listener_velocity(i4_float x,i4_float y,i4_float z);
99  void set_listener_position(i4_float x,i4_float y,i4_float z);
100
101  i4_voice_class *alloc(w32 buffer_size, sound_parameters &description);
102 
103  i4_voice_class *duplicate_2d(i4_voice_class *voice);
104  i4_voice_class *duplicate_3d(i4_voice_class *voice);
105 
106  void set_listener_orientation(i4_float f_x,i4_float f_y,i4_float f_z,
107                                i4_float u_x,i4_float u_y,i4_float u_z);
108
109  void commit_3d_changes();
110
111  void free_voice(i4_voice_class *voice);
112
113};
114
115extern direct_sound_class direct_sound;
116
117#endif
Note: See TracBrowser for help on using the repository browser.