Audio.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <dsound.h>
  2. #ifdef _AUDIO_
  3. #define _SOUND_H_
  4. #else
  5. #define _SOUND_H_ extern
  6. #endif
  7. #define MAX_SOUND_DEVICE 16
  8. #define MAX_VOICE 1024
  9. #define MAX_CHANNEL 16
  10. #define MAX_SB_LENGTH 1024 // number of shorts of the buffer
  11. #define MAX_BUFFER_LENGTH MAX_SB_LENGTH*4 // real lenght of buffer in bytes
  12. #define LEFT_LOW 32
  13. #define LEFT_MIDDLE 88
  14. #define LEFT_HIGH 144
  15. #define RIGHT_LOW 144
  16. #define RIGHT_MIDDLE 200
  17. #define RIGHT_HIGH 256
  18. #define MAX_RADIUS 6000
  19. #define MIN_RADIUS 512
  20. typedef struct tagSOUNDDEVICEDESC {
  21. GUID Guid;
  22. char* lpstrDescription;
  23. char* lpstrModule;
  24. DSCAPS DSC;
  25. int status;
  26. } SOUNDDEVICEDESC;
  27. typedef struct tagCHANNEL {
  28. int status; // 0 means that channel is free
  29. int iLength; // filled when appropriate voice is assigned to the channel
  30. int iPosition; // position of next portion to read
  31. short int* lpData;
  32. int x, y, z; // coords of the voice
  33. int volume; // for aligning
  34. } CHANNEL;
  35. typedef struct tagAMBIENT {
  36. int iLength;
  37. short int* lpData; // voice this channel is referenced to
  38. int iPosition; // position of next portion to read
  39. int volume, avolume;
  40. } AMBIENT;
  41. typedef struct tagMAMBIENT {
  42. int iLength;
  43. short int* lpData; // voice this channel is referenced to
  44. int iPosition; // position of next portion to read
  45. float x,y,z;
  46. } MAMBIENT;
  47. void AddVoice(int, short int*);
  48. void AddVoicev(int, short int*);
  49. void AddVoice3d(int, short int*, float, float, float);
  50. void AddVoice3dv(int, short int*, float, float, float, int);
  51. void SetAmbient(int, short int*, int);
  52. void SetAmbient3d(int, short int*, float, float, float);
  53. void SetAmbient3d(int, short int*, float, float, float, int);
  54. void InitAudioSystem(HWND);
  55. int ProcessAudio( void );
  56. void AudioSetCameraPosition( float, float, float, float, float);
  57. void AudioStop();
  58. _SOUND_H_ SOUNDDEVICEDESC sdd[MAX_SOUND_DEVICE];
  59. _SOUND_H_ int iTotalSoundDevices;
  60. _SOUND_H_ int iTotal16SD;
  61. _SOUND_H_ int iCurrentDriver;
  62. _SOUND_H_ int iBufferLength;
  63. _SOUND_H_ int iSoundActive; // prevent playing voices on not ready device
  64. _SOUND_H_ int iNeedNextWritePosition; // is set to 1 when first voice is added
  65. _SOUND_H_ DWORD dwPlayPos;
  66. _SOUND_H_ DWORD dwWritePos;
  67. _SOUND_H_ char _SoundBufferData[1024*16];
  68. _SOUND_H_ char* lpSoundBuffer;
  69. _SOUND_H_ LPDIRECTSOUND lpDS;
  70. _SOUND_H_ WAVEFORMATEX WaveFormat;
  71. _SOUND_H_ LPDIRECTSOUNDBUFFER lpdsPrimary, lpdsSecondary, lpdsWork;
  72. _SOUND_H_ BOOL PrimaryMode;
  73. _SOUND_H_ CHANNEL channel[ MAX_CHANNEL ];
  74. _SOUND_H_ AMBIENT ambient, ambient2;
  75. _SOUND_H_ MAMBIENT mambient;
  76. _SOUND_H_ int xCamera, yCamera, zCamera;
  77. _SOUND_H_ float alphaCamera, cosa, sina;