Sound FX Woes
Blitz3D Forums/Blitz3D Beginners Area/Sound FX Woes
| ||
Some strange problems I have observed. Some .wav sounds loop automatically when I play them. Some do not. Some sounds play hundreds of times per second. I find that loading the background music is best done outside the game loop. Does anyone have solutions to these problems or know where to look for the answers? PS: If at all possible, please do not answer to comlicatedly as I have trouble understanding some of the more complex stuff. If this is not possible, I understand. Thanks in advance! |
| ||
code examples ? |
| ||
Code example would be good yeah. When you have .wav loops that do not loop, you should assign a channel upon playing the sound, look for the channel commands in the manual, then check to see if the channel is still playing. TBH though, you don't have the greatest control over sounds in blitz basic. |
| ||
Ok, I'll get some examples. It may take a day, though. |
| ||
I find that loading the background music is best done outside the game loop. Maybe that's your problem. You don't load anything at the game loop - you load it once, and just play/emit the sounds during the game loop; after it's finished you free them, and that's it. |
| ||
The music is the only thing I emit from outside the game loop. If I use it inside, it just repeats numerous times per second. I would do the same thing with the sounds but If... Then statements do not work too well out side the game loop. I'm guessing that channels might solve this problem but I don't know how to use them too well. Ok. I guess it didn't take a whole day. Here is an example of a sound that repeats numerous times per second: Global thrust=LoadSound("Escaping The Atmosphere.wav") Graphics3D 1024,764 SetBuffer BackBuffer() While Not KeyDown(1) ;Run gauge If fin=0 Then Color 255,255,255 Rect 90,155,run#,20,1 If MouseDown(2) And KeyDown(200=True Then run#=run# -.8 thrustchn=PlaySound(thrust) Else run#=run# +.3 EndIf EndIf RenderWorld Flip Wend End My guess is that this is because of the MouseDOWN command. Though, I can't get the result I want with the gauge with a MouseDown command. Here is an example of a sound that repeats automatically: Global die=LoadSound("Screams Male 03.wav") Graphics3D 1024,764 SetBuffer BackBuffer() While Not KeyDown(1) targethealth(ammo.bullet,foe.target) RenderWorld Flip Wend End Function targethealth(ammo.bullet,foe.target) If CountCollisions(ammo\shape)>0 entity=EntityCollided(ammo\shape,type_target) If entity>0 foe.target=Object.target(EntityName(entity)) foe\health=foe\health-1 If foe<>Null And foe\health=0 HideEntity foe\shape HideEntity ammo\shape dascore#=dascore#+1 foesleft=foesleft-1 PlaySound(die) EndIf EndIf EndIf End Function Behold my barbaric coding! If you have any channel advice for this, it would help, I'm sure. PS: Sorry if I am being a pest asking all these questions. But I do appriciate the help. |
| ||
In the first example the sound keeps restarting as long as the mouse button is depressed try thisIf Not ChannelPlaying(thrustchn) thrustchn=PlaySound(thrust) End if In the second example you are not deleting the type so it never equals null and the condition If foe<>Null And foe\health=0 is always true |
| ||
Hmm... Ok, I'll give it a go. Thanks! |
| ||
Unfortunately, your first suggestion didn't work and I couldn't figure out how to apply the second. |
| ||
this didn't work, i don't know how you didn't get an error with your initial code anyway as it was lacking the closing parenthesis on KeyDown(200 lolIf MouseDown(2) And KeyDown(200)=True run#=run# -.8 If Not ChannelPlaying(thrustchn) thrustchn=PlaySound(thrust) End if Else run#=run# +.3 EndIf in the second example you never delete the type so the condition remains true and the sound will continue to be played forever ie foe will NEVER be null |
| ||
The KeyDown(200 was actually a typo. I'll try the new code example. When I tried to delete the type, it pointed to "foe\health=foe\health-1" and said entity does not exist. A code example for this would be quite helpful, as I am new to types. |
| ||
Aha! The Thrust code worked! It started to loop automatically so I put in a StopChannel command. Thanks! Still need help with the types though. |
| ||
Ace Killjoy, have you seen my website (programming tutorial) with its explanation of Types. I don't know how much of it you might find useful but it might be worth taking a look. Also, checking out how Types are used in some of the code examples on my website might help as well. Link is in my signature... |
| ||
Wow, that's handy. I may have to reffer to that later. I'm still not sure how to solve my problem. I'll try messing around with the conditions. EDIT: I'm going to need more help on this one. I can't figure out how to Null it after the sound plays. |
| ||
delete foe.target you should also free any entities accoiated with the type before you delete it |
| ||
So, just to clarify, I delete foe.target after the PlaySound command and free the entities in between the Wend and End? I'll try fiddling about with it though. EDIT: I'm going to need the know pretty much exactly what to do because I can't seem to figure it out on my own. |
| ||
Hi, the problem with looping sounds is the SMPT chuck inside of the samples, look in BlitzBassStudio. In STUFF you will find a wav.bb to fix this samples. With this code you can also create "perfekt" autoloops. bye Edit :SMPL not SMPT |
| ||
I'm sorry. I haven't been coding for more than a few years. What is an SMPT chuck and BlitzBassStudio? |
| ||
see my signature. BlitzBassStudio is an audio engine from un4seen with includes and decls for blitzbasic. But for wav.bb you dont need to use bass. bye |
| ||
wav files can contain a marker which tells DirectX to automatically loop the sound. If you have such a wav file, you will have to load and save in a wav editor to remove the marker. For intentional looping have you tried LoopSound()? |
| ||
That is not true. directsound only supports the officiel Microsoft Chunks (RIFF FMT DATA). Blitzbasic dont use directsound but fmod 3.x. This engine supports the SMPL chuck and only open an output stream to directsound...nothing more. to remove the SMPL you can also only use an editor who ignore that. As i now AUDACITY also ignore SMPL. bye |
| ||
I was thinking... Do you think I could fix this problem with a timer? |
| ||
"That is not true. directsound only supports the officiel Microsoft Chunks (RIFF FMT DATA). Blitzbasic dont use directsound but fmod 3.x." Then this currently looping wav file in B3D must just be my imagination then, eh? (I use Audio Cleaning Lab to save/load the wav file and problem goes away.) |