error while play multiple samples

Discuss any general programming issues here
Post Reply
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

error while play multiple samples

Post 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
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: error while play multiple samples

Post by airsoftsoftwair »

What platform did you test this on?
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: error while play multiple samples

Post by xabierpayet »

uae and windows, in both i have the saame error
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: error while play multiple samples

Post 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.
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: error while play multiple samples

Post 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" ?
User avatar
airsoftsoftwair
Posts: 5443
Joined: Fri Feb 12, 2010 2:33 pm
Location: Germany
Contact:

Re: error while play multiple samples

Post 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...
xabierpayet
Posts: 267
Joined: Fri Feb 24, 2012 9:34 am

Re: error while play multiple samples

Post by xabierpayet »

nice xD, thank you
Post Reply