Trouble with sound
Blitz3D Forums/Blitz3D Programming/Trouble with sound
| ||
Hello all. Im having some bother with something that really should not be so hard.. I have a game sound, it needs to be called if an object in the game is destroyed. So im using the folloing code. If ChannelPlaying(line_ch6)=1 Else line_ch6=PlaySound(line_snd) ChannelPitch line_ch6,40000 End If The handle line_ch6, is one of 6 variables, and my code is like above but with all 6 channel handles trapped inside that nested if. so if chan 1 is playing check chan 2 and so on. The thing is Even though im probably never gona play 6 sounds at once before the first stops playing again I still seem to be getting dead air on some object deaths. For an older project I setup a type array to handle channels, and I thought hay Ill try that here. But for some reason I can use an array or a type array to handle these 6 sound channels. I guess im probably doing something wrong, cos I think the logic behind it is sound. so I'm hoping that you fine bunch will point out what im doing wrong. On that note. has anyone come up with a really good way of handling sound channels. ? |
| ||
Personally I wouldn't handle the channels myself, I would let Blitz do that job. Just play the sounds and store the channel as long as it is required. boom=PlaySound(line_snd) ChannelPitch boom,40000 ; won't be used anymore, so let's forget about it if a sound is looped, store it's channel in a permanent global variable, such as "music_channel" or something. Most Soundcards have 16 or 32 Channels, so it happens rarely that there aren't enough channels. |
| ||
Thanks for that jfk. The sounds I was dealing with in the past were all looped so I used a sound system for a bit more control over them... These ones are not looped, I guess I just didnt think about it like that, Ie just play it and forget about it. So thanks for the heads up. |