private void ToOgg(MemoryStream stream) { var audioStream = new AudioStreamOGGVorbis(); audioStream.Data = stream.ToArray(); AudioStream = audioStream; }
private AudioStreamOGGVorbis GetMusicStream(string name, bool repeat = true) { AudioStreamOGGVorbis stream = ResourceLoader.Load <AudioStreamOGGVorbis>("res://SoundEngine/Assets/Music/" + name + ".ogg"); stream.SetLoop(repeat); return(stream); }
public static AudioStream loadOGG(byte[] buffer, bool loop = false) { var stream = new AudioStreamOGGVorbis(); stream.Data = buffer; stream.Loop = loop; return(stream); }
public void PlaySong(int selectedSong = 0) { currentSong = selectedSong; string songName = songs[selectedSong]; AudioStreamOGGVorbis stream = (AudioStreamOGGVorbis)GD.Load(songName); stream.Loop = false; Stream = stream; Playing = true; }
public AudioStreamPlayer PlaySfx(AudioStreamOGGVorbis stream, Node owner, string bus = "SfxA") { AudioStreamPlayer player = new AudioStreamPlayer(); player.SetStream(stream); player.SetBus(bus); owner.AddChild(player); player.Play(); Logger.Debug("Play Sfx: " + stream.ResourcePath); return(player); }
public AudioStreamPlayer2D PlaySfxLoop2D(AudioStreamOGGVorbis stream, Node2D target, string bus = "SfxA") { PositionalAudioStreamPlayer2D player = new PositionalAudioStreamPlayer2D(); player.Init(target); player.SetStream(stream); player.SetBus(bus); target.AddChild(player); player.Play(); Logger.Debug("Play Sfx Loop 2D: " + stream.ResourcePath); return(player); }
public void PlaySound(SoundEnum sound, bool loop = false, float volumeDb = 0f) { GD.Print($"Playing {sound}. Loop? {loop} volumeDb? {volumeDb} "); Dictionary <SoundEnum, string> sounds = Constants.SoundEffects(); string soundPath = sounds[sound]; AudioStreamOGGVorbis stream = (AudioStreamOGGVorbis)GD.Load(soundPath); stream.Loop = loop; UnitDb = volumeDb; MaxDb = volumeDb; Stream = stream; Playing = true; }
public static void PlaySong(Songs song) { if (song == Songs.None) { return; } string fileName = SongFile(song); AudioStreamOGGVorbis stream = (AudioStreamOGGVorbis)GD.Load(fileName); Session.InitJukeBox(); Session.session.jukeBox.Stream = stream; Session.session.jukeBox.Playing = true; }
public void PlayMusic(string name, bool repeat = true, bool fade = true, string bus = "Music") { AudioStreamOGGVorbis stream = GetMusicStream(name, repeat); if (stream != null) { musicPlayer.SetStream(stream); musicPlayer.SetBus(bus); Logger.Debug("Play Music :" + stream.ResourcePath); musicPlayer.Play(); } else { Logger.Warning("Music not found: " + name); } }
public static void PlaySong(Songs song) { if (song == Songs.None) { return; } if (song == Session.session.currentSong) { GD.Print("Don't restart the current song"); return; } GD.Print("Changing " + Session.session.currentSong + " to " + song); string fileName = SongFile(song); AudioStreamOGGVorbis stream = (AudioStreamOGGVorbis)GD.Load(fileName); Session.InitJukeBox(); Session.session.jukeBox.Stream = stream; Session.session.jukeBox.Playing = true; Session.session.currentSong = song; }
public override void _Ready() { // Get nodes _joystick = GetParent().GetNode("CanvasLayer/Joystick").GetChild <JoystickButton>(0); _playerSprite = GetNode <Sprite>("PlayerSprite"); _inventory = GetParent().GetNode <Inventory>("CanvasLayer/Inventory"); _debugOverlay = GetParent().GetNode <DebugOverlay>("CanvasLayer/DebugOverlay"); _audioPlayer = GetNode <AudioStreamPlayer>("AudioPlayer"); _itemTooltip = (ItemTooltip)GD.Load <PackedScene>("res://ItemTooltip.tscn").Instance(); GetParent().GetNode("CanvasLayer").AddChild(_itemTooltip); _gathering = GetParent <Gathering>(); _footstepPlayer = GetNode <AudioStreamPlayer>("FootstepPlayer"); _miscPlayer = GetNode <AudioStreamPlayer>("MiscPlayer"); // Load assets _runForwards = GD.Load <Texture>("res://textures/Player_run_forwards.png"); _runBackwards = GD.Load <Texture>("res://textures/Player_run_backwards.png"); _runRight = GD.Load <Texture>("res://textures/Player_run_right.png"); _runForwardsNormal = GD.Load <Texture>("res://textures/normal/Player_run_forwards_n.png"); _runBackwardsNormal = GD.Load <Texture>("res://textures/normal/Player_run_backwards_n.png"); _runRightNormal = GD.Load <Texture>("res://textures/normal/Player_run_right_n.png"); _forestSong = GD.Load <AudioStreamOGGVorbis>("res://audio/music/enchanted_forest_longer.ogg"); // Load footstep sounds into an array for (int i = 0; i < _footstepSounds.Length; i++) { string terrainType = string.Empty; int indexOffset = 0; if (i < 4) { terrainType = "dirt"; } else if (i >= 4 && i < 8) { terrainType = "grass"; indexOffset = 4; } else if (i >= 8) { terrainType = "stone"; indexOffset = 8; } _footstepSounds[i] = GD.Load <AudioStream>("res://audio/sfx/footstep/" + terrainType + "_" + (i - indexOffset + 1).ToString() + ".wav"); } // Load magic pop sounds for (int i = 0; i < _magicPopSounds.Length; i++) { _magicPopSounds[i] = GD.Load <AudioStream>("res://audio/sfx/magic/magic_pop_open_0" + (i + 1).ToString() + ".wav"); } // Other setup Timer spriteAnimTimer = GetNode <Timer>("SpriteAnimateTimer"); spriteAnimTimer.WaitTime = 1f / _SpriteFPS; spriteAnimTimer.Connect("timeout", this, nameof(AnimateSprite)); _invItems.AddRange(new Item.ItemStack[] { new Item.ItemStack(Items.BRIMSTONE, 1), new Item.ItemStack(Items.FLY_AGARIC, 3), new Item.ItemStack(Items.ELDERBERRIES, 5), new Item.ItemStack(Items.AQUA_FORTIS, 1), new Item.ItemStack(Items.HOLLY_BERRIES, 3), new Item.ItemStack(Items.AQUA_VITAE, 1) }); GetParent().GetNode <Inventory>("CanvasLayer/Inventory").UpdateSlots(_invItems); _debugOverlay.TrackProperty(nameof(_inventory.Scale), _inventory, "Inventory Scale"); _debugOverlay.TrackFunc(nameof(FloorPositionString), this, "Player Position"); _inventory.Connect("ItemSlotSelected", this, nameof(InventorySlotSelected)); _audioPlayer.Stream = _forestSong; _audioPlayer.VolumeDb = -25f; _audioPlayer.Play(); }