/// <summary> /// Play an audio stream globally, without position. /// </summary> /// <param name="stream">The audio stream to play.</param> public void Play(AudioStream stream, AudioParams?audioParams = null) { if (GameController.Mode == GameController.DisplayMode.Clyde) { var source = _clyde.CreateAudioSource(stream); if (audioParams.HasValue) { source.SetPitch(audioParams.Value.PitchScale); source.SetVolume(audioParams.Value.Volume); } source.SetGlobal(); source.StartPlaying(); var playing = new PlayingClydeStream { Source = source, }; PlayingClydeStreams.Add(playing); return; } if (GameController.Mode != GameController.DisplayMode.Godot) { return; } var player = new Godot.AudioStreamPlayer() { Stream = stream.GodotAudioStream, Playing = true, }; if (audioParams != null) { var val = audioParams.Value; player.Bus = val.BusName; player.VolumeDb = val.Volume; //player.PitchScale = val.PitchScale; player.MixTarget = (Godot.AudioStreamPlayer.MixTargetEnum)val.MixTarget; } sceneTree.WorldRoot.AddChild(player); TrackGodotPlayer(player); }
/// <summary> /// Play an audio stream globally, without position. /// </summary> /// <param name="stream">The audio stream to play.</param> public void Play(AudioStream stream, AudioParams?audioParams = null) { var player = new Godot.AudioStreamPlayer() { Stream = stream.GodotAudioStream, Playing = true, }; if (audioParams != null) { var val = audioParams.Value; player.Bus = val.BusName; player.VolumeDb = val.Volume; //player.PitchScale = val.PitchScale; player.MixTarget = (Godot.AudioStreamPlayer.MixTargetEnum)val.MixTarget; } sceneTree.WorldRoot.AddChild(player); TrackAudioPlayer(player); }