I`ll try what you said before to check what happens.Do you know why
Sound Playing works but
Music Playing doesn`t?Is it related to dbpro, or it`s my fault?
EDIT: If i use sounds instead of musics anything i add to play array restart other sounds and they all play at the same time.There is no sounds stucked, but this is irrelevant now.
EDIT2: I managed the problem from EDIT1 with altering the code a bit.Now i use UDT array with custom playing_state and there is no more sound restarts when new sound is added in the array.There is the code:
sync on:sync rate 60
type sounds
ID as integer
playing_state as boolean
endtype
dim sound(99) as sounds
do
cls
text 0,60,"FreeSoundID: "+str$(FreeSoundID)
for x = 0 to 9
text 0,80+(x*20),"sounds("+str$(x)+") = "+str$(sound(x).ID)
if sound(x).ID>0
text 100,80+(x*20)," sound playing: "+str$(sound playing(sound(x).ID))+" sound playing state: "+str$(sound(x).playing_state)
endif
next x
if mouseclick()=1 and press = 0
press = 1
play_sound()
endif
if mouseclick()=0 then press = 0
delete_sound()
sync
loop
function play_sound()
FreeSoundID = find free sound()
load sound "Media/Sounds/death"+str$(rnd(4))+".ogg",FreeSoundID
if FreeSoundID => sound(99).ID
sound(99).ID = FreeSoundID
sort array sound().ID,-1
endif
for ID = 0 to 99
if sound(ID).ID > 0
if sound(ID).playing_state = 0
play sound sound(ID).ID
sound(ID).playing_state = 1
endif
endif
next ID
endfunction
function delete_sound()
for ID = 0 to 99
if sound(ID).ID>0
if sound exist(sound(ID).ID) = 1
if sound playing (sound(ID).ID) = 0
sound(ID).playing_state = 0
endif
endif
endif
next ID
for ID = 0 to 99
if sound(ID).ID>0
if sound exist(sound(ID).ID) = 1
if sound playing (sound(ID).ID) = 0 and sound(ID).playing_state = 0
delete sound sound(ID).ID
sound(ID).ID = 0
endif
endif
endif
next ID
endfunction
My next problem is that
delete sound command doesn`t free up virtual memory.I load really small sounds, max 3 sec each.Loading them again and again arround 100 times makes used virtual memory arround 100k.What could cause this?Before when i used music commands
delete music do the cleaning of vmemory.
Where there is a will, there is a way.
I often edit my posts, that`s who i am
