equal
deleted
inserted
replaced
26 procedure SoundLoad; |
26 procedure SoundLoad; |
27 procedure PlaySound(snd: TSound; infinite: boolean); |
27 procedure PlaySound(snd: TSound; infinite: boolean); |
28 procedure PlayMusic; |
28 procedure PlayMusic; |
29 procedure StopSound(snd: TSound); |
29 procedure StopSound(snd: TSound); |
30 function ChangeVolume(voldelta: LongInt): LongInt; |
30 function ChangeVolume(voldelta: LongInt): LongInt; |
|
31 procedure InitPlaylistChunk(seed: LongWord); |
31 |
32 |
32 implementation |
33 implementation |
33 uses uMisc, uConsole; |
34 uses uMisc, uConsole; |
|
35 |
|
36 {$INCLUDE playlist.inc} |
|
37 |
34 const chanTPU = 12; |
38 const chanTPU = 12; |
35 var Mus: PMixMusic; |
39 var Mus: PMixMusic = nil; |
|
40 CurrMusic: Longword = 0; |
36 Volume: LongInt; |
41 Volume: LongInt; |
37 |
42 |
38 procedure InitSound; |
43 procedure InitSound; |
39 begin |
44 begin |
40 if not isSoundEnabled then exit; |
45 if not isSoundEnabled then exit; |
72 WriteToConsole(msgLoading + s + ' '); |
77 WriteToConsole(msgLoading + s + ' '); |
73 Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
78 Soundz[i].id:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), 'rb'), 1); |
74 TryDo(Soundz[i].id <> nil, msgFailed, true); |
79 TryDo(Soundz[i].id <> nil, msgFailed, true); |
75 WriteLnToConsole(msgOK); |
80 WriteLnToConsole(msgOK); |
76 end; |
81 end; |
77 |
|
78 s:= PathPrefix + '/Music/kahvi140a_alexander_chereshnev-illusion.ogg'; |
|
79 WriteToConsole(msgLoading + s + ' '); |
|
80 Mus:= Mix_LoadMUS(Str2PChar(s)); |
|
81 TryDo(Mus <> nil, msgFailed, false); |
|
82 WriteLnToConsole(msgOK) |
|
83 end; |
82 end; |
84 |
83 |
85 procedure PlaySound(snd: TSound; infinite: boolean); |
84 procedure PlaySound(snd: TSound; infinite: boolean); |
86 var loops: LongInt; |
85 var loops: LongInt; |
87 begin |
86 begin |
96 if Mix_Playing(Soundz[snd].lastChan) <> 0 then |
95 if Mix_Playing(Soundz[snd].lastChan) <> 0 then |
97 Mix_HaltChannel(Soundz[snd].lastChan) |
96 Mix_HaltChannel(Soundz[snd].lastChan) |
98 end; |
97 end; |
99 |
98 |
100 procedure PlayMusic; |
99 procedure PlayMusic; |
|
100 var s: string; |
101 begin |
101 begin |
|
102 {$IFDEF HAVE_MUSIC} |
102 if not isSoundEnabled then exit; |
103 if not isSoundEnabled then exit; |
103 if Mix_PlayingMusic = 0 then |
104 if Mix_PlayingMusic() <> 0 then exit; |
104 Mix_PlayMusic(Mus, -1) |
105 Mix_FreeMusic(Mus); |
|
106 s:= PathPrefix + '/Music/' + playlist[CurrMusic]; |
|
107 CurrMusic:= playlistchain[CurrMusic]; |
|
108 WriteToConsole(msgLoading + s + ' '); |
|
109 Mus:= Mix_LoadMUS(Str2PChar(s)); |
|
110 TryDo(Mus <> nil, msgFailed, false); |
|
111 WriteLnToConsole(msgOK); |
|
112 |
|
113 Mix_PlayMusic(Mus, 0) |
|
114 {$ENDIF} |
105 end; |
115 end; |
106 |
116 |
107 function ChangeVolume(voldelta: LongInt): LongInt; |
117 function ChangeVolume(voldelta: LongInt): LongInt; |
108 begin |
118 begin |
109 if not isSoundEnabled then |
119 if not isSoundEnabled then |
115 Volume:= Mix_Volume(-1, -1); |
125 Volume:= Mix_Volume(-1, -1); |
116 Mix_VolumeMusic(Volume * 3 div 8); |
126 Mix_VolumeMusic(Volume * 3 div 8); |
117 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
127 ChangeVolume:= Volume * 100 div MIX_MAX_VOLUME |
118 end; |
128 end; |
119 |
129 |
|
130 procedure InitPlaylistChunk(seed: LongWord); |
|
131 var i, t, tmp: Longword; |
|
132 begin |
|
133 {$IFDEF HAVE_MUSIC} |
|
134 for i:= 0 to Pred(cPlayListLength) do |
|
135 playlistchain[i]:= i; |
|
136 |
|
137 for i:= 0 to Pred(cPlayListLength) do |
|
138 begin |
|
139 t:= (i + 1) mod cPlayListLength; |
|
140 tmp:= playlistchain[t]; |
|
141 playlistchain[t]:= playlistchain[i]; |
|
142 playlistchain[i]:= tmp; |
|
143 end |
|
144 {$ENDIF} |
|
145 end; |
|
146 |
120 end. |
147 end. |