[Bf-committers] Game engine and samples

Alexander Ewering blender at instinctive.de
Tue Dec 28 11:31:50 CET 2004


On Tue, 28 Dec 2004, Kester Maddock wrote:

> Hi Alexander,
>
> It looks like they are from stuff that was happening before the open source.
> Maybe some NaNites can tell us.  They seem to be based on what AL exports for
> a sound.
>
> All the sound engine really has to do is go boing at the right time. :-)

:-) OK!

> I don't think sound attenuation is a function of it's volume.  Here is what I
> would do:
>
> Volume/Gain: The loudness of the sound.

So you mean an absolute gain value that is applied to the sample regardless
of any other parameters. Fine.

> Distance: Affects how far a sound carries.

OK, I can live with that. It's not totally physically accurate of course, but
well, we have to "cull" sounds anyway at a certain distance... Does the game
engine do that currently, btw? If no, I'll have to implement it. If you have
a large world with like 32 sound sources, this can quickly eat a lot of
CPU :-)

> Pitch: Fine.  You're going to have to do DSP to do arbitary pitch shifts.
> Doppler can also tie into this.

Well, I will just resample the samples - not do true pitch shifting, of course.

> Loop points: Good for eg: engine start up ... engine sound ... engine stop

Yes, agreed. This has never been implemented at all though in Blender. I can
try.

In general, I'll be cleaning up the mess that 2 bankrupcies and 3 sound systems
introduced, make all relevant parameters (distance, etc.) accessible to the
user, and make it stable, latency-free, and clean :-)

One problem, Kester: When calculating panning and volume for a sound object
relative to the listener, I'm doing this in:

void SND_SDLDevice::SetObjectTransform(int id,
                                           const MT_Vector3& position,
                                           const MT_Vector3& velocity,
                                           const MT_Matrix3x3& orientation,
                                           const MT_Vector3& lisposition,
                                           const MT_Scalar& rollofffactor) const

For now, I'm calculating the distance like this:

     x= (float)position[0]-(float)lisposition[0];
     y= (float)position[1]-(float)lisposition[1];
     z= (float)position[2]-(float)lisposition[2];
     dist= (float)sqrt(x*x+y*y+z*z);

This works only if the camera (viewer) is facing the sound source. If not,
there are suddenly huge changes in dist, which makes me think that one of
the coordinate systems is transformed?

Maybe you can give a quick hint. Thanks.

| alexander ewering              instinctive mediaworks
| ae[@]instinctive[.]de   http://www[.]instinctive[.]de


More information about the Bf-committers mailing list