Load3D Sound problem
Blitz3D Forums/Blitz3D Beginners Area/Load3D Sound problem
| ||
I have an airship circling around my 3d world with a 3d sound assigned to it. I have also created a listener which is attached to my camera so the closer I get to the airship the louder the sound should get. What I move towards it I get is a high pitch sound which is different to the .wav file I loaded, it sounds orrible. I have a feeling that it could be something to do with the way I am emitting the sound in the main program loop. Anyone else have problems looping a 3d sound from a mesh entity? |
| ||
>> the way I am emitting the sound in the main program loop << could you describe this closer? AFAIK there is no need to "emit" it repeatedly in the mainloop (manually) once it plays in loop mode. |
| ||
I have the following lines to set up my 3d sound outside the main loop, microphone=CreateListener(camera) shipbuzz=Load3DSound("airship.wav") LoopSound=shipbuzz As the airship is moving around in a circle (Using Sin/cos), I am thinking the sound must move with the entity somehow so I have EmitSound(shipbuzz,airship) in the main loop. When I move the camera closer to the airship the sound does generate but it sounds rough... If I move emit sound out of the loop, I hear nothing |
| ||
Try something likeGlobal gShipSoundPlaying=false at the start of your program, then in your main loop If gShipSoundPlaying=false EmitSound(shipbuzz,airship) gShipSoundPlaying=true endif so that you only start the sound once. |
| ||
uh,LoopSound=shipbuzz dhouldn't this be LoopSound shipbuzz ??? |
| ||
Nice one Shambler that worked a treat. I guess the little if-endif controls the sound logic in the mail loop. bot builder - yep - should have been loopsound shipbuzz. I now get a looping engine noise which gets louder the closer I get to the object. Perfect.. |
| ||
I guess you have to "emitsound" only once, before the mainloop, right? |
| ||
jfk, Correct. Set up the sound loop outside the main program and activate it once within the main loop. I think what i was experiencing was a continuous trigger of the sound through the speakers before adding the if-endif routine Shambler mentioned...... |
| ||
You can just call EmitSound after loading/looping too... no need to wait until the main loop or repeatedly check it's playing (assuming it's meant to just keep looping). See the Load3DSound bit in this: http://www.blitzbasic.co.nz/codearcs/codearcs.php?code=340 |
| ||
James, Yes it just needs to loop constantly, So prior to the main loop something like, shipbuzz = Load3DSound ("airship.wav") If shipbuzz LoopSound shipbuzz CreateListener (cam) shipchannel = EmitSound (shipbuzz, airship) EndIf Then Just turn the channel on and off when required in the main loop....Nice.. Cheers, |