void Awake() { channel = soundManager.GetChannel(ChannelName); var slider = GetComponent <Slider>(); slider.value = channel.Volume; slider.onValueChanged.AddListener((value) => channel.Volume = value); }
void Awake() { channel = soundManager.GetChannel(ChannelName); var toggle = GetComponent <Toggle>(); toggle.isOn = channel.Enabled; toggle.onValueChanged.AddListener((value) => channel.Enabled = value); }
protected override void OnAddedToScene() { base.OnAddedToScene(); if (Program.Instance != null) idle = Program.Instance.SoundManager.GetSFX(global::Client.Sound.SFX.MongrelIdle1). PlayLoopedWithIntervals(6, 15, 3f + (float)Game.Random.NextDouble() * 10f, new Sound.PlayArgs { GetPosition = () => { return Position; }, GetVelocity = () => { if (MotionUnit == null) return Vector3.Zero; return MotionUnit.Velocity; } }); }
protected override void OnKilled(Unit perpetrator, Script script) { base.OnKilled(perpetrator, script); if (perpetrator == Game.Instance.Map.MainCharacter) Game.Instance.Statistics.Kills.Ghouls += 1; if (idle != null) { idle.Stop(); idle = null; } }
void Awake() { channelDict = new Dictionary <string, ISoundChannel>(); foreach (var channel in Channels) { DebugOnly.Check(!channelDict.ContainsKey(channel.Name), $"Duplicate channel name: '{channel.Name}'."); channelDict[channel.Name] = channel; channel.InternalInit(Mixer); } Sfx = GetChannel("Sfx"); Music = GetChannel("Music"); }
private void Run() { soundManager = new SoundManager(new AudioDevice(), ManagerGlue.JMOD, 1, 30); soundManager.ContentPath = "Data/Sound/"; soundManager.LoadSounds(true); playable = soundManager.GetSFX(SFX.SwordSwish1); //playable = soundManager.GetStream(Stream.MainMenuMusic1); channel = playable.Play(new Client.Sound.PlayArgs { Looping = true }); //channel.Looping = true; //channel.PlaybackStopped += new EventHandler(channel_PlaybackStopped); //channel.PlaybackStopped += (sender, ea) => { Console.WriteLine("Playback ended. Restarting..."); channel = p.Play(); }; float dtime = 1 / 60f; while (true) { soundManager.Update(dtime, Vector3.Zero, Vector3.Zero, Vector3.UnitX, Vector3.UnitZ); System.Threading.Thread.Sleep((int)(dtime * 1000)); //VolumeTest(dtime / 4f); //PauseTest(dtime / 4f); //GlobalMuteTest(dtime / 4f); } }
public LfsRegister(ISoundChannel channel) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); }
public VolumeEnvelope(ISoundChannel channel) { _channel = channel ?? throw new ArgumentNullException(nameof(channel)); }
protected override void OnKeyDown(KeyEventArgs e) { base.OnKeyDown(e); float speed = 2.5f; if (e.KeyCode == Keys.W) position.Y -= speed; else if (e.KeyCode == Keys.S) position.Y += speed; else if (e.KeyCode == Keys.A) position.X -= speed; else if (e.KeyCode == Keys.D) position.X += speed; else if (e.KeyCode == Keys.Up) floatingPoint.Y -= speed; else if (e.KeyCode == Keys.Down) floatingPoint.Y += speed; else if (e.KeyCode == Keys.Left) floatingPoint.X -= speed; else if (e.KeyCode == Keys.Right) floatingPoint.X += speed; else if (e.KeyCode == Keys.U) { if (loopingSoundChannel != null && loopingSoundChannel.Looping) loopingSoundChannel.StopAfterCurrent(); else { loopingSoundChannel = soundManager.GetSFX(SFX.ShotgunFire1).Play( new PlayArgs { Position = new Vector3(Size.Width/2f, Size.Height/2f, 0) }); } } else if (e.KeyCode == Keys.I) { if (loopingSoundChannel != null) { loopingSoundChannel.Stop(); loopingSoundChannel = null; } } else if (e.KeyCode == Keys.Q) { stopped = true; soundManager.StopAllChannels(); } else if (e.KeyCode == Keys.R) { intervalChannel.StopAfterCurrent(); } else if (e.KeyCode == Keys.Z) { intervalChannel.PlaybackSpeed -= 0.1f; } else if (e.KeyCode == Keys.X) { intervalChannel.PlaybackSpeed += 0.1f; } else if (e.KeyCode == Keys.C) { intervalChannel.Volume -= 0.1f; } else if (e.KeyCode == Keys.V) { intervalChannel.Volume += 0.1f; } else if (e.KeyCode == Keys.T) { soundManager.Volume -= 0.1f; } else if (e.KeyCode == Keys.Y) { soundManager.Volume += 0.1f; } /* else if (e.KeyCode == Keys.Oemplus) { //soundManager.SetMaxAudible("attacks", ++audible); //Text = audible + " channels"; } else if (e.KeyCode == Keys.OemMinus) { //audible = audible > 0 ? audible - 1 : 0; //soundManager.SetMaxAudible("attacks", audible); //Text = audible + " audible attack sounds"; } else if (e.KeyCode == Keys.R) { //List<Sound> list = new List<Sound>(sounds); //int index = 0; //Random r = new Random(); //while (list.Count > 0) //{ // int i = r.Next(list.Count - 1); // units[index++].Sound = list[i]; // list.RemoveAt(i); //} } else if (e.KeyCode == Keys.M) { //var rt = soundStreams[Sounds.Streams.RainThunder].Play(); //thunderRain = rt.First; //thunderRainChannel = rt.Second; //Random r = new Random(); //Unit u = new Unit //{ // Position = new Vector3(Width / 2f, Height / 2f, 0) + new Vector3((float)(r.NextDouble() * 40 - 20), (float)(r.NextDouble() * 40 - 20), 0), // Sound = soundStreams[Sounds.Streams.RainThunder], // Cooldown = 0.1f //}; //units.Add(u); } else if (e.KeyCode == Keys.Z) { rifleSpeed -= 0.1f; //soundManager.GetSFX(SFX.RifleFire1). } else if (e.KeyCode == Keys.X) { rifleSpeed += 0.1f; } else if (e.KeyCode == Keys.N) { //musicVolume = System.Math.Min(1f, musicVolume + 0.1f); //if (thunderRainChannel != null) // soundManager.SetChannelVolume(thunderRainChannel, musicVolume); } else if (e.KeyCode == Keys.B) { //musicVolume = System.Math.Min(1f, musicVolume - 0.1f); //if (thunderRainChannel != null) // soundManager.SetChannelVolume(thunderRainChannel, musicVolume); }*/ else if (e.KeyCode == Keys.OemPipe) { if ((System.Windows.Forms.Control.ModifierKeys & Keys.Shift) != 0) volumeTestResourceVolume = Clamp(volumeTestResourceVolume - 0.1f, 0, 1); else volumeTestResourceVolume = Clamp(volumeTestResourceVolume + 0.1f, 0, 1); volumeTestResource.Volume = volumeTestResourceVolume; } else if (e.KeyCode == Keys.D1) { if ((System.Windows.Forms.Control.ModifierKeys & System.Windows.Forms.Keys.Shift) != 0) volumeTestChannelVolume = Clamp(volumeTestChannelVolume - 0.1f, 0, 1); else volumeTestChannelVolume = Clamp(volumeTestChannelVolume + 0.1f, 0, 1); volumeTestChannel.Volume = volumeTestChannelVolume; } else if (e.KeyCode == Keys.D2) { } else if (e.KeyCode == Keys.D3) { fadeChannel = soundManager.GetSoundResourceGroup(soundManager.GetStream(Stream.InGameMusic1), soundManager.GetStream(Stream.ScoreScreenVictoryMusic1)).PlayLoopedWithIntervals(1, 3, 0.3f, new PlayArgs()); //fadeChannel = soundManager.GetStream(Stream.InGameMusic1).PlayLoopedWithIntervals(0.5f, 0.5f, 2f); //fadeChannel = soundManager.GetStream(Stream.InGameMusic1).Play(); } else if (e.KeyCode == Keys.D4) { if (fadeChannel != null) { //fadeChannel.PlaybackStopped += ((sender, ee) => { soundManager.GetStream(Stream.InGameMusic1).Play(3f); }); fadeChannel.PlaybackStopped += ((sender, ee) => { fadeChannel = soundManager.GetStream(Stream.InGameMusic1).PlayLoopedWithIntervals(0.5f, 0.5f, 0, new PlayArgs()); }); fadeChannel.Stop(1f); } } else if (e.KeyCode == Keys.D5) { spread = System.Math.Min(360f, System.Math.Max(0f, spread - 15f)); //SoundManager.Instance._3DSpread = spread; } else if (e.KeyCode == Keys.D6) { spread = System.Math.Min(360f, System.Math.Max(0f, spread + 15f)); //SoundManager.Instance._3DSpread = spread; } else if (e.KeyCode == Keys.D8) { panLevel = System.Math.Min(1, System.Math.Min(1f, panLevel - 0.1f)); SoundManager.Instance._3DPanLevel = panLevel; //panChannel1._3DPanLevel = panLevel; //panChannel2._3DPanLevel = panLevel; } else if (e.KeyCode == Keys.D9) { panLevel = System.Math.Min(1, System.Math.Min(1f, panLevel + 0.1f)); SoundManager.Instance._3DPanLevel = panLevel; //panChannel1._3DPanLevel = panLevel; //panChannel2._3DPanLevel = panLevel; } else if (e.KeyCode == Keys.D0) System.Windows.Forms.MessageBox.Show("PanLevel: " + panLevel + Environment.NewLine + "Spread: " + spread); else if (e.KeyCode == Keys.Oemplus) { } }
internal SoundHandle(ISoundChannel channel, SoundSource source) { Channel = channel; Source = source; HandleID = source.HandleID; }
public override void Init() { playable = SoundManager.GetStream(Stream.ScoreScreenVictoryMusic1); channel = playable.Play(new PlayArgs { Looping = true, FadeInTime = 1f }); }
public override void Init() { var playable = soundManager.GetStream(Stream.BirdsAmbient1); testChannel = playable.PlayLoopedWithIntervals(1f, 2f, 0.5f, new PlayArgs()); }
public override void HandleKeyDown(KeyEventArgs e) { base.HandleKeyDown(e); switch (e.KeyCode) { case Keys.P: var sr = testChannel.CurrentSoundResource; Console.WriteLine("Length of current sound resource: {0}", sr != null ? sr.Length : 0); break; case Keys.V: testChannel.Stop(); break; case Keys.T: if ((e.Modifiers & Keys.Shift) != 0) testChannel.Stop(); var playable = soundManager.GetStream(Stream.BirdsAmbient1); testChannel = playable.PlayLoopedWithIntervals(1f, 2f, 0.5f, new PlayArgs()); break; } }
protected override void OnKilled(Unit perpetrator, Script script) { base.OnKilled(perpetrator, script); if (idleSoundChannel != null) { idleSoundChannel.Stop(); idleSoundChannel = null; } }
protected virtual void SetupSound() { if (State == UnitState.Alive && idleSoundChannel == null) { if (Program.Instance != null) { var sm = Program.Instance.SoundManager; var idleSound = sm.GetSoundResourceGroup(sm.GetSFX(SFX.GruntIdle1), sm.GetSFX(SFX.GruntIdle2), sm.GetSFX(SFX.GruntIdle3)); idleSoundChannel = idleSound.PlayLoopedWithIntervals(8, 15, 3f + (float)Game.Random.NextDouble() * 10.0f, new Sound.PlayArgs { GetPosition = () => { return Position; }, GetVelocity = () => { if (MotionNPC != null) return MotionNPC.Velocity; else return Vector3.Zero; } }); } } else if(State != UnitState.Alive) { if (idleSoundChannel != null) { idleSoundChannel.Stop(); idleSoundChannel = null; } } }