Page 1 of 1

error while play multiple samples

Posted: Fri Mar 27, 2015 12:37 am
by xabierpayet
problems using playsample function, please try this code Andreas, this is working fine, but when i remove the
wait command, the program crash, any idea about how to solve the problem? i have a lot of sprites with sounds in the screen, i tried also with @MUSIC command, but slow down my system a lot

@SAMPLE 100,"sons/cometa.wav"
For a=1 To 20
CopySample(100,a)
Next

Repeat
For a=1 To 20
Wait(20); using the wait command work, but is not useful the delay in a shootemup game
play=IsSamplePlaying(a)
If play=True
StopSample(a)
EndIf
PlaySample(a)
next
Forever

Re: error while play multiple samples

Posted: Sat Mar 28, 2015 11:56 am
by airsoftsoftwair
What platform did you test this on?

Re: error while play multiple samples

Posted: Sat Mar 28, 2015 1:10 pm
by xabierpayet
uae and windows, in both i have the saame error

Re: error while play multiple samples

Posted: Sat Mar 28, 2015 4:56 pm
by airsoftsoftwair
Um, what do you mean by the program "crashes"? Do you get an error saying that there was a problem allocating an audio channel? This is normal and not a "crash"... Hollywood uses 8 channels by default. Thus, if you try to play more than 8 sounds at a time, you'll get an error. Starting with Hollywood 6.0 this limit can be raised by setting the NUMCHANNELS console argument but this is probably not needed here.

Re: error while play multiple samples

Posted: Sun Mar 29, 2015 12:10 pm
by xabierpayet
ok, i understand it, but, is possible know if is possible play a sample before of use the playsample function? an attribute will be a good solution for example, or... is possible bypass the "allocating an audio channel error" ?

Re: error while play multiple samples

Posted: Sun Mar 29, 2015 12:19 pm
by airsoftsoftwair
Currently not, you have to keep track of this yourself. But I think it would be a good idea to have some functions that give the programmer fine-tuned control over the individual audio channels, like HaveFreeChannel(), IsChannelPlaying() and StopChannel(). I think it would make sense to add such functions because IsSamplePlaying() and IsMusicPlaying() aren't enough because a single sample could be playing on multiple channels. Shouldn't be much work so you can expect some improvements here for the next update...

Re: error while play multiple samples

Posted: Sun Mar 29, 2015 10:31 pm
by xabierpayet
nice xD, thank you