Hacky hack

See comment in code.
This commit is contained in:
na 2026-09-07 13:16:25 +02:00
commit 777002030d

View file

@ -250,13 +250,22 @@ while keyin<>27
elseif left$(client_cmd, 10) = "SOUNDBANK:" then elseif left$(client_cmd, 10) = "SOUNDBANK:" then
loadsoundbank mid$(client_cmd,11) loadsoundbank mid$(client_cmd,11)
if _SNDPLAYING(musichandle) then if _SNDPLAYING(musichandle) then
oldhandle=musichandle
' a hack to make qb64pe load the midi file that is already loaded.
' qb64 can't open the same file again with a new sound bank for some reason
' so it has to be closed, freed and given a short delay before reloading
' which gives a short break in the playing of music, very annoying.
' this should be reverted if qb64pe ever gets the ability to reload the same
' file more than once.
tmppos=_sndgetpos(musichandle)
_sndstop musichandle
_sndclose musichandle
_delay .1
musichandle=_sndopen(file(i)) musichandle=_sndopen(file(i))
_sndvol musichandle,volume _sndvol musichandle,volume
_sndsetpos musichandle,tmppos
_sndplay musichandle _sndplay musichandle
_sndsetpos musichandle, _sndgetpos(oldhandle)
_sndstop oldhandle
_sndclose oldhandle
end if end if
elseif left$(client_cmd, 4) = "VOL:" then elseif left$(client_cmd, 4) = "VOL:" then
volume = val(mid$(client_cmd, 5)) / 100 volume = val(mid$(client_cmd, 5)) / 100