OpenBve.Sounds.PlaySound C# (CSharp) Method

PlaySound() static private method

Plays a sound.
static private PlaySound ( SoundBuffer buffer, double pitch, double volume, OpenBveApi position, TrainManager train, int car, bool looped ) : SoundSource
buffer SoundBuffer The sound buffer.
pitch double The pitch change factor.
volume double The volume change factor.
position OpenBveApi The position. If a train and car are specified, the position is relative to the car, otherwise absolute.
train TrainManager The train the sound is attached to, or a null reference.
car int The car in the train the sound is attached to.
looped bool Whether to play the sound in a loop.
return SoundSource
		internal static SoundSource PlaySound(SoundBuffer buffer, double pitch, double volume, OpenBveApi.Math.Vector3 position, TrainManager.Train train, int car, bool looped) {
			if (Sources.Length == SourceCount) {
				Array.Resize<SoundSource>(ref Sources, Sources.Length << 1);
			}
			Sources[SourceCount] = new SoundSource(buffer, buffer.Radius, pitch, volume, position, train, car, looped);
			SourceCount++;
			return Sources[SourceCount - 1];
		}
		

Same methods

Sounds::PlaySound ( SoundBuffer buffer, double pitch, double volume, OpenBveApi position, bool looped ) : SoundSource

Usage Example

Example #1
0
            /// <summary>Releases the emergency brake</summary>
            internal void UnapplyEmergencyBrake()
            {
                if (Handles.EmergencyBrake.Driver)
                {
                    // sound
                    Sounds.SoundBuffer buffer = Cars[DriverCar].Sounds.BrakeHandleRelease.Buffer;
                    if (buffer != null)
                    {
                        Vector3 pos = Cars[DriverCar].Sounds.BrakeHandleRelease.Position;
                        Sounds.PlaySound(buffer, 1.0, 1.0, pos, this, DriverCar, false);
                    }

                    // apply

                    if (Handles.Brake is AirBrakeHandle)
                    {
                        ApplyAirBrakeHandle(AirBrakeHandleState.Service);
                    }
                    else
                    {
                        ApplyNotch(0, !Handles.SingleHandle, Handles.Brake.MaximumNotch, true);
                    }
                    Handles.EmergencyBrake.Driver = false;
                    // plugin
                    if (Plugin == null)
                    {
                        return;
                    }

                    Plugin.UpdatePower();
                    Plugin.UpdateBrake();
                }
            }
All Usage Examples Of OpenBve.Sounds::PlaySound