/[cvs]/rabit/r3/Module_Sound.bas
ViewVC logotype

Contents of /rabit/r3/Module_Sound.bas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (vendor branch)
Tue Mar 12 21:29:11 2002 UTC (22 years, 8 months ago) by cvsrabit
Branch: NFO, MAIN
CVS Tags: v034a, HEAD
Changes since 1.1: +0 -0 lines
Initial project import

1 Attribute VB_Name = "Module_Sound"
2 Option Explicit
3
4 Global clDSPrimaryBuffer As DirectSoundPrimaryBuffer8
5
6 'Global clDSSoundBuffer1 As DirectSoundSecondaryBuffer8
7 'Global clDS3DBuffer1 As DirectSound3DBuffer8
8 '
9 'Global clDSSoundBuffer2 As DirectSoundSecondaryBuffer8
10 'Global clDS3DBuffer2 As DirectSound3DBuffer8
11 '
12 'Global clDSSoundBuffer3 As DirectSoundSecondaryBuffer8
13 'Global clDS3DBuffer3 As DirectSound3DBuffer8
14
15 Global clDSListener As DirectSound3DListener8
16 '
17
18 Public Function RenderSounds() As Boolean
19
20 Dim lPlayerIndex As Long
21
22 Dim dsbc As DSBCAPS
23 Dim sgTireScream As Single
24
25 Dim clPlayer As Class_Player
26
27 Dim sgPlayerVelocityX As Single
28 Dim sgPlayerVelocityZ As Single
29
30 For lPlayerIndex = 1 To clGame.Col_clPlayers.Count
31
32 Set clPlayer = clGame.Col_clPlayers(lPlayerIndex)
33
34 With clPlayer
35
36 ' clDSPrimaryBuffer.SetVolume Form_Start.HScroll_Volume.Value
37
38 ' Set clPlayer = clGame.Col_clPlayers("p" & lLocalPlayerHandle)
39
40 sgPlayerVelocityX = .sgSpeed * Sin(.sgAngleY * Const_sgDeg2Rad)
41 sgPlayerVelocityZ = .sgSpeed * -Cos(.sgAngleY * Const_sgDeg2Rad)
42
43 ' clDS3DBuffer1.SetPosition clPlayer.sgPosX, clPlayer.sgPosY, clPlayer.sgPosZ, DS3D_IMMEDIATE
44 ' clDS3DBuffer1.SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
45 ' clDS3DBuffer2.SetPosition clPlayer.sgPosX, clPlayer.sgPosY, clPlayer.sgPosZ, DS3D_IMMEDIATE
46 ' clDS3DBuffer2.SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
47 ' clDS3DBuffer3.SetPosition clPlayer.sgPosX, clPlayer.sgPosY, clPlayer.sgPosZ, DS3D_IMMEDIATE
48 ' clDS3DBuffer3.SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
49
50 .DS3DBuffer(1).SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
51 .DS3DBuffer(2).SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
52 .DS3DBuffer(3).SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
53
54 'If lCamMode = 4 Then
55 If True Then
56
57 clDSListener.SetVelocity 0, 0, 0, DS3D_IMMEDIATE
58 clDSListener.SetDopplerFactor 0.1, DS3D_IMMEDIATE
59
60 Else
61
62 clDSListener.SetVelocity sgPlayerVelocityX, 0, sgPlayerVelocityZ, DS3D_IMMEDIATE
63 clDSListener.SetDopplerFactor 0, DS3D_IMMEDIATE
64
65 End If
66
67 .DSSoundBuffer(1).Play DSBPLAY_LOOPING
68 .DSSoundBuffer(1).GetCaps dsbc
69
70 If Rnd > (0.96 + 0.015 * .sgSpeedRate) Then
71
72 .DSSoundBuffer(1).SetCurrentPosition CLng(Rnd * dsbc.lBufferBytes)
73
74 End If
75
76 .DSSoundBuffer(1).SetVolume 0.9 * Form_Start.HScroll_Volume.Value - 0.1 * 8192
77 ' clDSSoundBuffer1.SetVolume -512
78 .DSSoundBuffer(1).SetFrequency 22050 + 30000 * Abs(.sgSpeedRate)
79
80 sgTireScream = Abs(.sgSpeedRate) * Abs(.sgSteeringWheelPosition)
81
82 If sgTireScream > 0.01 And Not clPlayer.bOffroad Then
83
84 .DSSoundBuffer(2).SetVolume -8192 + sgTireScream * (8192 + Form_Start.HScroll_Volume.Value)
85 ' clDSSoundBuffer2.SetVolume -8192 + sgTireScream * 7700
86 .DSSoundBuffer(2).Play DSBPLAY_LOOPING
87
88 Else
89
90 .DSSoundBuffer(2).SetVolume -8192
91 .DSSoundBuffer(2).Stop
92
93 End If
94
95 'clDSSoundBuffer3.Stop
96
97 If (.lPlayerControlFlags And ePCF_Horn) = ePCF_Horn Then
98
99 .DSSoundBuffer(3).Play DSBPLAY_DEFAULT
100 'clDSSoundBuffer3.SetCurrentPosition 0
101
102 ' Else
103
104 End If
105
106 .DSSoundBuffer(3).SetVolume 0.95 * Form_Start.HScroll_Volume.Value - 0.05 * 8192
107 ' clDSSoundBuffer3.SetVolume -512
108
109 End With
110
111 Next lPlayerIndex
112
113 End Function
114
115 Public Sub InitialiseSound()
116
117 Dim tpSoundBufferDescription As DSBUFFERDESC
118
119 Dim tpDSBufferDescription As DSBUFFERDESC
120
121 tpDSBufferDescription.lFlags = DSBCAPS_PRIMARYBUFFER Or DSBCAPS_CTRL3D Or DSBCAPS_CTRLVOLUME ' Or DSBCAPS_CTRLFREQUENCY Or DSBCAPS_CTRLPAN
122 Set clDSPrimaryBuffer = clSystem.DS8.CreatePrimarySoundBuffer(tpDSBufferDescription)
123
124 ' clDSPrimaryBuffer.SetVolume Form_Start.HScroll_Volume.Value
125
126 Set clDSListener = clDSPrimaryBuffer.GetDirectSound3DListener
127
128 With clDSListener
129
130 .SetRolloffFactor 0.02, DS3D_IMMEDIATE
131
132 End With
133
134 '' tpSoundBufferDescription.lFlags = DSBCAPS_STATIC Or DSBCAPS_CTRLVOLUME Or DSBCAPS_CTRLFREQUENCY ' Or DSBCAPS_CTRLPAN Or DSBCAPS_LOCSOFTWARE
135 ' tpSoundBufferDescription.lFlags = DSBCAPS_CTRL3D Or DSBCAPS_LOCSOFTWARE Or DSBCAPS_CTRLVOLUME Or DSBCAPS_CTRLFREQUENCY ' Or DSBCAPS_CTRLVOLUME Or DSBCAPS_CTRLPAN
136 ' tpSoundBufferDescription.guid3DAlgorithm = ""
137 ' Set clDSSoundBuffer1 = clSystem.DS8.CreateSoundBufferFromFile(App.Path + "\Audio\motor1.wav", tpSoundBufferDescription)
138 ' Set clDS3DBuffer1 = clDSSoundBuffer1.GetDirectSound3DBuffer
139 '
140 '' tpSoundBufferDescription.lFlags = DSBCAPS_STATIC Or DSBCAPS_CTRLVOLUME
141 ' tpSoundBufferDescription.lFlags = DSBCAPS_CTRL3D Or DSBCAPS_LOCSOFTWARE Or DSBCAPS_CTRLVOLUME
142 ' Set clDSSoundBuffer2 = clSystem.DS8.CreateSoundBufferFromFile(App.Path + "\Audio\brake1.wav", tpSoundBufferDescription)
143 ' Set clDS3DBuffer2 = clDSSoundBuffer2.GetDirectSound3DBuffer
144 ' Set clDSSoundBuffer3 = clSystem.DS8.CreateSoundBufferFromFile(App.Path + "\Audio\horn1.wav", tpSoundBufferDescription)
145 ' Set clDS3DBuffer3 = clDSSoundBuffer3.GetDirectSound3DBuffer
146
147 ' clDSSoundBuffer1.SetVolume -8192
148 ' clDSSoundBuffer2.SetVolume -8192
149 ' clDSSoundBuffer3.SetVolume -8192
150
151 End Sub

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed