Run子程中:
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 4096);
尝试将4096改成更大的值
如果改善不大再试下面的
声音指针定义改为:
Music: array[0..23] of PMix_music;
ESound: array[0..52] of PMix_Chunk;
ASound: array[0..23] of PMix_Chunk;
增加以下子程:
procedure InitialMusic;
var
i: integer;
str: string;
begin
for i := 0 to 23 do
begin
str := 'music\' + inttostr(i) + '.mp3';
if fileexists(pchar(str)) then
Music[i] := Mix_LoadMUS(pchar(str))
else
Music[i] := nil;
end;
for i := 0 to 52 do
begin
str := formatfloat('sound\e00', i) + '.wav';
if fileexists(pchar(str)) then
ESound[i] := Mix_LoadWav(pchar(str))
else
ESound[i] := nil;
end;
for i := 0 to 23 do
begin
str := formatfloat('sound\atk00', i) + '.wav';
if fileexists(pchar(str)) then
ASound[i] := Mix_LoadWav(pchar(str))
else
ASound[i] := nil;
end;
end;
播放部分进行如下修改:
//播放mp3音乐
procedure PlayMP3(MusicNum, times: integer); overload;
begin
if MusicNum in [Low(Music)..High(Music)] then
if Music[MusicNum] <> nil then
Mix_PlayMusic(Music[MusicNum], times);
end;
procedure PlayMP3(filename: pchar; times: integer); overload;
begin
//if fileexists(filename) then
//begin
//Music := Mix_LoadMUS(filename);
//Mix_volumemusic(MIX_MAX_VOLUME div 3);
//Mix_PlayMusic(music, times);
//end;
end;
//停止当前播放的音乐
procedure StopMP3;
begin
Mix_HaltMusic;
end;
//播放wav音效
procedure PlaySound(SoundNum, times: integer); overload;
begin
if SoundNum in [Low(Esound)..High(Esound)] then
if Esound[SoundNum] <> nil then
Mix_PlayChannel(-1, Esound[SoundNum], times);
end;
procedure PlaySound(SoundNum: integer); overload;
begin
if SoundNum in [Low(Esound)..High(Esound)] then
if Esound[SoundNum] <> nil then
Mix_PlayChannel(-1, Esound[SoundNum], 0);
end;
procedure PlaySound(filename: pchar; times: integer); overload;
begin
{if fileexists(filename) then
begin
Sound := Mix_LoadWav(filename);
Mix_PlayChannel(-1, sound, times);
end;}
end;
[[i] 本帖最后由 weyl 于 2009-6-5 10:52 编辑 [/i]]
[[i] 本帖最后由 weyl 于 2009-6-5 10:57 编辑 [/i]] |