SDK Question Simular "IsPlaying3" call

JMW

Aspiring Addon Developer
Joined
Aug 5, 2008
Messages
670
Reaction score
89
Points
43
Location
Happy Wherever
Does anyone know if there is a call I can code in a .dll to know if the "crash.wav" is playing.
Thanks guys.
JMW
 
I doubt it, that's a pretty tenuous event to grab. However, given known conditions for which that file is played, you can pull in the same vessel information OrbiterSound does to decide when to play it - i.e VESSEL::GetAltitude() and VESSEL::GetAirSpeed() - comparing the two and applying some logic will tell you when the vessel is in the situation where the "crash.wav" file would be played - for example;

Code:
<clbkPostStep/clbkPreStep>
bool crashing = false;
if (GetAltitude() <= 0.1 && GetAirspeed() >= 200) crashing = true;

(GetAirSpeed returns in m/s - Altitude returns in m - the numbers are less important than the logical comparison)

This approach would also be compatible for those installations which do not have OrbiterSound installed, of which there are a few.
 
Last edited:
Are these conditions compatible with non-zero COG elevation?
 
I doubt it, as far as I know they take their readings from the vessel's COG (wherever it is), but they may take it from _V(0,0,0) as the "origin" of the vessel. If it's your vessel module and you know the offsets, though, you can adjust the values to compensate for it manually.

Edit: Checking the API reference didn't clue me in as to which it is, but my suspicion is leaning towards _V(0,0,0) now.
 
Last edited:
Turns out COG and _V(0,0,0) coincide...
 
thanks for your thoughts.

I'm thinking though that if it's as you state Xyon, the "crash" sound could play everytime the vessel lands - good or bad.
There must be some input relative to vertical speed too - the speed we're "hitting" the surface.
I've tried somethings like
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] vspddwn = (v.y );[/SIZE]
[SIZE=2][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] (vspddwn <-4.0 &&GetAltitude() < 10)[/SIZE]
[SIZE=2]PlayVesselWave3(MySoundID,CRASH);[/SIZE]
[/SIZE]
but nothing happens.(This is with the creation of a MySound element for CRASH of course)
I'm actually trying to get a control on landing gear suspension compression depending on downward vertical speed.

Does anyone know a simpler way?

Regards,

JMW
 
Last edited:
Code:
<clbkPostStep/clbkPreStep>
bool crashing = false;
if (GetAltitude() <= 0.1 && GetAirspeed() >= 200) crashing = true;

This would fail quite frequently. I'd look for ground contact of touchdown points myself, log the time of last contact and compare it to the length of the crash.wav
 
A dumb question to JMW: is the v vector in the Horizon coordinate frame?
 
This would fail quite frequently. I'd look for ground contact of touchdown points myself, log the time of last contact and compare it to the length of the crash.wav

This is true, and I was somewhat asleep when I wrote it - what you suggest works better. I'm not sure how you grab vertical speed, ie if there's an actual call for that, but it can be calculated, if nothing else, by comparing the speed from GetAirSpeed() with GetAltitude(), I'd think. Unless airspeed means something different to what I think it does, anyway.
 
Back
Top