2002-03-03 02:07:21 +00:00
|
|
|
Users Guide to FlightGear sound configuration
|
2002-05-09 04:24:39 +00:00
|
|
|
Version 0.7.11, apr 27 2002
|
2002-03-03 02:07:21 +00:00
|
|
|
Author: Erik Hofman <erik@ehofman.com>
|
|
|
|
|
|
|
|
This document is an attempt to describe the configuration of
|
|
|
|
FlightGear flight simulator's aircraft sound via XML.
|
|
|
|
|
|
|
|
Some History:
|
|
|
|
------------
|
|
|
|
Older versions of FGFS had a hard coded audio layer. This was a
|
|
|
|
than ideal state of affairs due to FGFS ability to use different
|
|
|
|
aircraft models. Being primarily developed on UNIX type systems, a
|
|
|
|
modular approach is taken towards the simulation. To date, most
|
|
|
|
alternatives to the default Cessna 172 aircraft are the product
|
|
|
|
of research institutions interested in the flight characteristics and
|
|
|
|
not cosmetics. The result of this was that one could fly the X-15 or
|
|
|
|
a Boeing 747 but be limited to C172 sounds.
|
|
|
|
|
|
|
|
A rewrite of the sound code was done around v0.7.10 by Erik Hofman
|
|
|
|
allowing for configuration of the sounds via XML to address this
|
|
|
|
limitation.
|
|
|
|
|
|
|
|
Sound Architecture:
|
|
|
|
------------------
|
|
|
|
All of the sound configuration files are XML-encoded* property lists.
|
|
|
|
The root element of each file is always named <PropertyList>. Tags are
|
|
|
|
almost always found in pairs, with the closing tag having a slash
|
|
|
|
prefixing the tag name, i.e </PropertyList>. The exception is the tag
|
|
|
|
representing an aliased property. In this case a slash is prepended to
|
|
|
|
the closing angle bracket. (see section Aliasing)
|
|
|
|
|
|
|
|
The top level sound configuration file is composed of a <fx>, a
|
|
|
|
<name>, a <path> sound file and zero or more <volume> and/or <pitch>
|
|
|
|
definitions.
|
|
|
|
|
|
|
|
[ Paths are relative to $FG_ROOT (the installed location of FGFS data files.) ]
|
|
|
|
[ Absolute paths may be used.Comments are bracketed with <!-- -->. ]
|
|
|
|
|
|
|
|
A limited sound configuration file would look something like this:
|
|
|
|
|
|
|
|
<PropertyList>
|
|
|
|
<fx>
|
|
|
|
<engine>
|
|
|
|
<name>engine</name>
|
|
|
|
<path>Sounds/wasp.wav</path>
|
|
|
|
<mode>looped</mode>
|
2002-05-09 04:24:39 +00:00
|
|
|
<condition>
|
|
|
|
<property>/engines/engine/running</property>
|
|
|
|
</condition>
|
2002-03-03 02:07:21 +00:00
|
|
|
<volume>
|
|
|
|
<property>/engines/engine/mp-osi</property>
|
|
|
|
<factor>0.005</factor>
|
|
|
|
<min>0.15</min>
|
|
|
|
<max>0.5</max>
|
|
|
|
<offset>0.15</offset>
|
|
|
|
</volume>
|
|
|
|
<pitch>
|
|
|
|
<property>/engines/engine/rpm</property>
|
|
|
|
<factor>0.0012</factor>
|
|
|
|
<min>0.3</min>
|
|
|
|
<max>5.0</max>
|
|
|
|
<offset>0.3</offset>
|
|
|
|
</pitch>
|
|
|
|
</engine>
|
|
|
|
</fx>
|
|
|
|
</PropertyList>
|
|
|
|
|
|
|
|
This would define an engine sound event handler for a piston engine driven
|
|
|
|
aeroplane. The sound representing the engine is located in $FG_ROOT/Sounds
|
|
|
|
and is named wasp.wav. The event is started when the property
|
|
|
|
/engines/engine/running becomes non zero.
|
|
|
|
|
|
|
|
When that happens, the sound will be played looped (see <mode>) until the
|
|
|
|
property returns zero again. As you can see the volume is mp-osi dependant,
|
|
|
|
and the pitch of the sound depents on the engine rpm.
|
|
|
|
|
|
|
|
Configuration description:
|
|
|
|
-------------------------
|
|
|
|
|
|
|
|
<fx>
|
|
|
|
Named FX subtree living under /sim/sound
|
|
|
|
|
|
|
|
< ... >
|
|
|
|
This is the event seperator. The text inside the brackets
|
|
|
|
can be anything. Bit it is adviced to give it a meaningfull name
|
2002-05-09 04:24:39 +00:00
|
|
|
like: crank, engine, rumble, gear, squeal, flap, wind or stall
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
The value can be defined multiple times, thus anything which is
|
2002-03-27 18:47:31 +00:00
|
|
|
related may have the same name (grouping them together).
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<name>
|
|
|
|
This defines the name of the event. This name is used internally
|
|
|
|
and, although it can me defined multiple times in the same file,
|
2002-05-09 04:24:39 +00:00
|
|
|
should normally have an unique value.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
Multiple definitions of the same name will allow multiple sections
|
|
|
|
to interfere in the starting and stopping of the sample.
|
|
|
|
|
|
|
|
This method can't be used to controll the pitch or volume of the
|
|
|
|
sample, but instead multiple volume or pitch section should be
|
|
|
|
included inside the same event.
|
|
|
|
|
|
|
|
The types "raise" and "fall" will stop the playback of the sample
|
|
|
|
regardless of any other event. This means that when the type "raise"
|
|
|
|
is supplied, sample playback will stop when the event turns false.
|
|
|
|
Using the type "fall" will stop playback when the event turns true.
|
|
|
|
|
|
|
|
IMPORTANT:
|
2002-05-09 04:24:39 +00:00
|
|
|
If the trigger is used for anything else but stopping the sound
|
2002-03-27 18:47:31 +00:00
|
|
|
at a certain event, all sections with the same name *should* have
|
|
|
|
exactly the same sections for everything but property and type.
|
|
|
|
|
|
|
|
In the case of just stopping the sample at a certain event, the
|
|
|
|
sections for path, volume and pitch may be omitted.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<path>
|
|
|
|
This defined th path to the sound file. The path is relative to the
|
|
|
|
FlightGear root directory but could be specified absolute.
|
2002-03-27 18:47:31 +00:00
|
|
|
|
2002-05-09 04:24:39 +00:00
|
|
|
<condition>
|
|
|
|
Define a condition that triggers the event.
|
|
|
|
For a complete description of the FlightGear conditions,
|
|
|
|
please read docs-mini/README.conditions
|
2002-03-27 18:47:31 +00:00
|
|
|
|
2002-05-09 04:24:39 +00:00
|
|
|
An event should define either a condition or a property.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-05-09 04:24:39 +00:00
|
|
|
<property>
|
|
|
|
Define which property triggers the event, and reffers to a node
|
|
|
|
in the FlightGear property tree. Action is taken when the property
|
|
|
|
is non zero.
|
2002-03-27 18:47:31 +00:00
|
|
|
|
2002-05-09 04:24:39 +00:00
|
|
|
A more sophisticated mechanism to trigger the event is described
|
|
|
|
in <condition>
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<mode>
|
|
|
|
This defines how the sample should be played:
|
|
|
|
|
|
|
|
once: the sample is played once.
|
|
|
|
this is the default.
|
|
|
|
|
|
|
|
looped: the sample plays continuesly,
|
|
|
|
until the event turns false.
|
2002-05-09 04:24:39 +00:00
|
|
|
|
|
|
|
in-transit: the sample plays continuesly,
|
|
|
|
while the property is changing its value.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<volume> / <pitch>
|
|
|
|
Volume or Pitch definition. Currently there may be up to 5
|
|
|
|
volume and up to 5 pitch definitions defined within one sound
|
2002-03-27 18:47:31 +00:00
|
|
|
event. Normally all offset values are added together and the
|
2002-03-03 02:07:21 +00:00
|
|
|
results after property calculations will be miltplied.
|
2002-03-27 18:47:31 +00:00
|
|
|
A special condition occurs when the value of factor is negative,
|
2002-03-03 02:07:21 +00:00
|
|
|
in which case the offset doesn't get added to the other offset values
|
|
|
|
but instead will be used in the multiplication section.
|
|
|
|
|
|
|
|
<property>
|
|
|
|
Defins which property supplies the value for the calculation.
|
2002-05-20 16:28:21 +00:00
|
|
|
Either a <property> or an <internal> should be defined.
|
2002-03-03 02:07:21 +00:00
|
|
|
The value is treatened as a floating point number.
|
2002-05-20 16:28:21 +00:00
|
|
|
|
|
|
|
<internal>
|
|
|
|
Defins which internal variable should be used for the calculation.
|
|
|
|
The value is treatened as a floating point number.
|
|
|
|
The following internals are available at this time:
|
|
|
|
|
|
|
|
dt_play: the number of seconds since the sound started playing.
|
|
|
|
|
|
|
|
dt_stop: the number of seconds after the sound has stopped.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<type>
|
2002-03-27 18:47:31 +00:00
|
|
|
Defines the function that should be used upon the property
|
|
|
|
before it is used for calculating the net result:
|
|
|
|
|
2002-03-03 02:07:21 +00:00
|
|
|
lin: lineair handling of the property value.
|
|
|
|
this is the default.
|
|
|
|
|
|
|
|
ln: convert the property value to a natural logarithmic
|
2002-05-09 04:24:39 +00:00
|
|
|
value before scaling it. Anything below 1 will return
|
|
|
|
zero.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
log: convert the property value to a true logarithmic
|
2002-05-09 04:24:39 +00:00
|
|
|
value before scaling it. Anything below 1 will return
|
|
|
|
zero.
|
2002-03-27 18:47:31 +00:00
|
|
|
|
|
|
|
inv: inverse lineair handling (1/x).
|
|
|
|
|
|
|
|
abs: absolute handling of the value (always positive).
|
|
|
|
|
|
|
|
sqrt: calculate the square root of the absolute value
|
|
|
|
before scaling it.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<factor>
|
|
|
|
Defines the multiplication factor for the property value.
|
|
|
|
A special condition is when scale is defined as a negative
|
|
|
|
value. In this case the result of |<scale>| * <property) will be
|
|
|
|
subtracted from <default>
|
|
|
|
|
|
|
|
<offset>
|
|
|
|
The initial value for this sound. This value is also used as an
|
|
|
|
offset value for calulating the end result.
|
|
|
|
|
|
|
|
<min>
|
|
|
|
Minimum allowed value.
|
|
|
|
This is usefull if sounds start to sound funny. Anything lower
|
2002-03-27 18:47:31 +00:00
|
|
|
will be truncated to this value.
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
<max>
|
|
|
|
Maximum allowed value.
|
|
|
|
This is usefull if sounds gets to loud. Anything higher will be
|
|
|
|
truncated to this value.
|
2002-03-27 18:47:31 +00:00
|
|
|
|
2004-04-29 19:32:03 +00:00
|
|
|
<position>
|
|
|
|
Specify the position of the sounds source relative to the
|
|
|
|
pilot's ears. The coordinate system used is a right hand
|
|
|
|
coordinate system where -X = left, +X = right, -Y = down, +Y =
|
|
|
|
up, -Z = forward, +Z = aft. Distances are in meters.
|
|
|
|
|
|
|
|
<x>
|
|
|
|
X dimension offset
|
|
|
|
|
|
|
|
<y>
|
|
|
|
Y dimension offset
|
|
|
|
|
|
|
|
<z>
|
|
|
|
Z dimension offset
|
|
|
|
|
|
|
|
<reference-dist>
|
|
|
|
Set a reference distance of sound in meters. This is the
|
|
|
|
distance where the gain/volume will be halved. This can be
|
|
|
|
useful for limiting cockpit sounds to the cockpit.
|
|
|
|
|
|
|
|
<max-dist>
|
|
|
|
Set the maximum audible distance for the sound in meters.
|
|
|
|
This can be useful for limiting cockpit sounds to the cockpit.
|
|
|
|
|
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
Creating a configrationfile:
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
To make things easy, there is a default falue for most entries to allow a
|
|
|
|
sane configuration when a certain entry is omitted.
|
|
|
|
|
|
|
|
Default values are:
|
|
|
|
|
|
|
|
type: lin
|
|
|
|
factor: 1.0
|
|
|
|
offset: 0.0 for volume, 1.0 for pitch
|
2002-05-09 04:24:39 +00:00
|
|
|
min: 0.0
|
2002-03-27 18:47:31 +00:00
|
|
|
max: 0.0 (don't check)
|
|
|
|
|
2002-03-03 02:07:21 +00:00
|
|
|
|
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
Calculations are made the following way (for both pitch and volume):
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
value = 0;
|
|
|
|
offs = 0;
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
for (n = 0; n < max; n++) {
|
|
|
|
if (factor < 0)
|
|
|
|
{
|
2002-05-09 04:24:39 +00:00
|
|
|
value += offset[n] - abs(factor[n]) * function(property[n]);
|
2002-03-27 18:47:31 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-05-09 04:24:39 +00:00
|
|
|
value += factor[n] * function(property[n]);
|
|
|
|
offs += offset[n];
|
2002-03-27 18:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
volume = offs + value;
|
2002-03-03 02:07:21 +00:00
|
|
|
|
2002-03-27 18:47:31 +00:00
|
|
|
where function can be one of: lin, ln, log, inv, abs or sqrt
|