56 |
56 |
57 function ChangeVolume(voldelta: LongInt): LongInt; |
57 function ChangeVolume(voldelta: LongInt): LongInt; |
58 function AskForVoicepack(name: shortstring): PVoicepack; |
58 function AskForVoicepack(name: shortstring): PVoicepack; |
59 function soundFadeOut(snd: TSound; qt: LongInt; voicepack: PVoicepack): LongInt; |
59 function soundFadeOut(snd: TSound; qt: LongInt; voicepack: PVoicepack): LongInt; |
60 |
60 |
61 function oalb_init(const app: PChar; const usehardware: Byte): Byte; cdecl; external OpenALBridge; |
61 |
62 procedure oalb_close; cdecl; external OpenALBridge; |
62 procedure oalb_close; cdecl; external OpenALBridge; |
63 function oalb_loadfile(const filename: PChar): LongInt; cdecl; external OpenALBridge; |
63 function oalb_init (const app: PChar; const usehardware: Byte): Byte; cdecl; external OpenALBridge; |
64 procedure oalb_playsound(const idx: LongInt; const loop: Byte); cdecl; external OpenALBridge; |
64 function oalb_loadfile (const filename: PChar): LongInt; cdecl; external OpenALBridge; |
65 procedure oalb_stopsound(const idx: LongInt); cdecl; external OpenALBridge; |
65 procedure oalb_playsound (const idx: LongInt; const loop: Byte); cdecl; external OpenALBridge; |
66 procedure oalb_pausesound(const idx: LongInt); cdecl; external OpenALBridge; |
66 procedure oalb_stopsound (const idx: LongInt); cdecl; external OpenALBridge; |
67 procedure oalb_continuesound(const idx: LongInt); cdecl; external OpenALBridge; |
67 procedure oalb_pausesound (const idx: LongInt); cdecl; external OpenALBridge; |
68 procedure oalb_setvolume(const idx: LongInt; const percentage: Byte); cdecl; external OpenALBridge; |
68 procedure oalb_continuesound (const idx: LongInt); cdecl; external OpenALBridge; |
69 procedure oalb_setglobalvolume(const percentage: Byte); cdecl; external OpenALBridge; |
69 procedure oalb_setvolume (const idx: LongInt; const percentage: Byte); cdecl; external OpenALBridge; |
|
70 procedure oalb_setglobalvolume (const percentage: Byte); cdecl; external OpenALBridge; |
|
71 procedure oalb_fadein (const idx: LongInt; quantity: Integer); cdecl; external OpenALBridge; |
|
72 procedure oalb_fadeout (const idx: LongInt; quantity: Integer); cdecl; external OpenALBridge; |
70 |
73 |
71 |
74 |
72 var MusicFN: shortstring = ''; |
75 var MusicFN: shortstring = ''; |
73 |
76 |
74 implementation |
77 implementation |
101 if not isSoundEnabled then exit; |
104 if not isSoundEnabled then exit; |
102 {*sound works in ipodtouch only if LAND_WIDTH = 1024; LAND_HEIGHT = 512; |
105 {*sound works in ipodtouch only if LAND_WIDTH = 1024; LAND_HEIGHT = 512; |
103 or if ogg are loaded in stream or if sound is loaded by demand*} |
106 or if ogg are loaded in stream or if sound is loaded by demand*} |
104 WriteToConsole('Init OpenAL sound...'); |
107 WriteToConsole('Init OpenAL sound...'); |
105 |
108 |
106 isSoundEnabled:= oalb_init('hwengine', Byte(isSoundHardware)) = 1; |
109 isSoundEnabled:= oalb_init(str2PChar(ParamStr(0)), Byte(isSoundHardware)) = 1; |
107 if isSoundEnabled then WriteLnToConsole(msgOK) |
110 if isSoundEnabled then WriteLnToConsole(msgOK) |
108 else WriteLnToConsole(msgFailed); |
111 else WriteLnToConsole(msgFailed); |
109 |
112 |
110 Volume:=0; |
113 Volume:=0; |
111 ChangeVolume(cInitVolume); |
114 ChangeVolume(cInitVolume); |
112 end; |
115 end; |
113 |
116 |
114 procedure ReleaseSound; |
117 procedure ReleaseSound; |
115 begin |
118 begin |
116 //if isMusicEnabled then openal_fadeout(Mus, 30); |
119 if isMusicEnabled then oalb_fadeout(Mus, 30); |
117 oalb_close(); |
120 oalb_close(); |
118 end; |
121 end; |
119 |
122 |
120 procedure SoundLoad; |
123 procedure SoundLoad; |
121 var i: TSound; |
124 var i: TSound; |
152 end; |
155 end; |
153 |
156 |
154 function soundFadeOut(snd: TSound; qt: LongInt; voicepack: PVoicepack): LongInt; |
157 function soundFadeOut(snd: TSound; qt: LongInt; voicepack: PVoicepack): LongInt; |
155 begin |
158 begin |
156 if not isSoundEnabled then exit(0); |
159 if not isSoundEnabled then exit(0); |
157 //if (voicepack <> nil) and (voicepack^.chunks[snd] >= 0) then openal_fadeout(defVoicepack^.chunks[snd], qt) |
160 if (voicepack <> nil) and (voicepack^.chunks[snd] >= 0) then oalb_fadeout(defVoicepack^.chunks[snd], qt) |
158 //else if (defVoicepack^.chunks[snd] >= 0) then openal_fadeout(defVoicepack^.chunks[snd], qt); |
161 else if (defVoicepack^.chunks[snd] >= 0) then oalb_fadeout(defVoicepack^.chunks[snd], qt); |
159 end; |
162 end; |
160 |
163 |
161 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
164 procedure PlaySound(snd: TSound; infinite: boolean; voicepack: PVoicepack); |
162 begin |
165 begin |
163 if (not isSoundEnabled) or fastUntilLag then exit; |
166 if (not isSoundEnabled) or fastUntilLag then exit; |
189 |
192 |
190 Mus:= oalb_loadfile(Str2PChar(s)); |
193 Mus:= oalb_loadfile(Str2PChar(s)); |
191 TryDo(Mus >= 0, msgFailed, false); |
194 TryDo(Mus >= 0, msgFailed, false); |
192 WriteLnToConsole(msgOK); |
195 WriteLnToConsole(msgOK); |
193 |
196 |
194 //openal_fadein(Mus, 20); |
|
195 //openal_toggleloop(Mus); |
|
196 oalb_playsound(Mus, 1); |
197 oalb_playsound(Mus, 1); |
|
198 oalb_fadein(Mus, 50); |
197 end; |
199 end; |
198 |
200 |
199 function ChangeVolume(voldelta: LongInt): LongInt; |
201 function ChangeVolume(voldelta: LongInt): LongInt; |
200 begin |
202 begin |
201 if not isSoundEnabled then exit(0); |
203 if not isSoundEnabled then exit(0); |