public void StopSong()
 {
     if (music == IntPtr.Zero)
     {
         return;
     }
     SDL_mixer.Mix_HaltChannel(musicChannel);
     SDL_mixer.Mix_FreeChunk(music);
     music = IntPtr.Zero;
 }
Example #2
0
 public void Stop(int channel = -1)
 {
     if (channel == MusicChannel)
     {
         SDL_mixer.Mix_HaltMusic();
     }
     else
     {
         SDL_mixer.Mix_HaltChannel(channel);
     }
 }
Example #3
0
 public override void Reset()
 {
     foreach (var it in playback)
     {
         Playback play    = it.Value;
         int      channel = it.Key;
         if (play.Loop)
         {
             Logger.Info("Sound", $"Stopping sound '{play.Sound}' on channel {channel} ({play.VirtualChannel})");
             SDL_mixer.Mix_HaltChannel(channel);
         }
     }
     Update(new FPoint(0, 0));
 }
Example #4
0
        private void StopChannel()
        {
            if (Channel < 0)
            {
                return;
            }

            var isPlayimg = SDL_mixer.Mix_Playing(Channel) == 1;

            if (isPlayimg)
            {
                SDL_mixer.Mix_HaltChannel(Channel);
            }

            Channel = -1;
        }
Example #5
0
        internal static void ArreterJouerSon(String son)
        {
            int id_canal = sons.Keys.ToList().IndexOf(son);

            // Son non trouvé
            if (id_canal == -1)
            {
                return;
            }

            // Son non joué
            if (SDL_mixer.Mix_Playing(id_canal) == 0)
            {
                return;
            }

            SDL_mixer.Mix_HaltChannel(id_canal);
        }
Example #6
0
        protected override void Play(Playback play)
        {
            int  channel    = -1;
            bool setChannel = false;

            if (!play.VirtualChannel.Equals(Sound.GLOBAL_VIRTUAL_CHANNEL))
            {
                if (channels.TryGetValue(play.VirtualChannel, out int vc))
                {
                    SDL_mixer.Mix_HaltChannel(vc);
                    channels.Remove(play.VirtualChannel);
                }
                setChannel = true;
            }
            channel = SDL_mixer.Mix_PlayChannel(-1, play.Sound.GetChunk(), play.Loop ? -1 : 0);
            if (channel == -1)
            {
                Logger.Error("Sound", $"Failed to play sound '{play.Sound}', no more channels available");
            }
            else
            {
                SDL_mixer.Mix_ChannelFinished(channelFinished);
                Logger.Info("Sound", $"Playing sound '{play.Sound}' on channel {channel} ({play.VirtualChannel})");
            }
            byte dist;

            if (play.Location.X != 0 || play.Location.Y != 0)
            {
                float v = 255.0f * (CalcDist(lastPos, play.Location) / soundFallOff);
                v    = Math.Min(Math.Max(v, 0.0f), 255.0f);
                dist = (byte)v;
            }
            else
            {
                dist = 0;
            }
            SetChannelPosition(channel, 0, dist);
            if (setChannel)
            {
                channels[play.VirtualChannel] = channel;
            }
            playback[channel] = play;
        }
Example #7
0
        protected override void RenderGame(float interpolation)
        {
            if (RogueskivGame.GameEvents.Any(ev => ev is ToggleSoundEvent))
            {
                UxConfig.SoundsOn = !UxConfig.SoundsOn;
                if (!UxConfig.SoundsOn)
                {
                    SDL_mixer.Mix_HaltChannel(-1);
                }
            }

            PlayerRenderer.SetUxCenter(UxContext, PlayerPositionComp.Position, UxConfig.CameraMovementFriction);
            base.RenderGame(interpolation);

            if (UxConfig.SoundsOn)
            {
                PlayerMovementEffectPlayer.Play();
                EffectPlayers.ForEach(ep => ep.Play());
            }
            RogueskivGame.GameEvents.Clear();
        }
 public void StopSfx(int channel)
 {
     SDL_mixer.Mix_HaltChannel(channel);
 }