Beispiel #1
0
        public static SoundChannelGroup CreateChannelGroup(string name)
        {
            SoundChannelGroup group = new SoundChannelGroup(name);

            channelGroups.Add(group);
            return(group);
        }
Beispiel #2
0
        protected void InitInternal(int maxReal2DChannels, int maxReal3DChannels)
        {
            masterChannelGroup = CreateChannelGroup("Master");

            SetDopplerEffectScale(1);
            SetListener(null, Vector3.Zero, Vector3.Zero, Quaternion.FromDirectionZAxisUp(Vector3.XAxis));
        }
        public void AddGroup(SoundChannelGroup group)
        {
            if (group.parent != null)
            {
                Log.Fatal("SoundChannelGroup: AddGroup: Trying to add already attached group.");
            }

            group.parent = this;
            children.Add(group);
        }
        internal void SoundPlayInit(Component_Scene attachedToScene, Sound sound, SoundChannelGroup group)
        {
            this.attachedToScene = attachedToScene;
            this.sound           = sound;
            this.group           = group;

            //!!!!было
            //sound.playingCount++;
            //if( ( sound.Mode & SoundModes.Stream ) != 0 )
            //{
            //	if( sound.playingCount != 1 )
            //		Log.Fatal( "VirtualChannel: SoundPlayInit: sound.playingCount != 1." );
            //}
        }
        internal bool IsUsingGroup(SoundChannelGroup group)
        {
            SoundChannelGroup g = this.Group;

            while (g != null)
            {
                if (g == group)
                {
                    return(true);
                }
                g = g.parent;
            }
            return(false);
        }
Beispiel #6
0
        public static SoundVirtualChannel SoundPlay(Component_Scene attachedToScene, Sound sound, SoundChannelGroup group, double priority, bool paused = false)
        {
            if (sound == null)
            {
                return(null);
            }

            ////!!!!так?
            //if( ( sound.Mode & SoundModes.Loop ) == 0 && ( sound.Mode & SoundModes.Stream ) == 0 )
            //{
            //	if( attachedToScene != null && listenerCurrentScene != attachedToScene )
            //		return null;
            //}

            //!!!!было
            ////!!!!так?
            //if( ( sound.Mode & SoundModes.Loop ) == 0 && ( sound.Mode & SoundModes.Stream ) == 0 )
            //{
            //	List<RealChannel> realChannels = ( sound.Mode & SoundModes.Mode3D ) != 0 ? real3DChannels : real2DChannels;

            //	bool allowPlay = false;
            //	for( int n = 0; n < realChannels.Count; n++ )
            //	{
            //		VirtualChannel c = realChannels[ n ].CurrentVirtualChannel;
            //		if( c == null || c.Priority < priority )
            //		{
            //			allowPlay = true;
            //			break;
            //		}
            //	}
            //	if( !allowPlay )
            //		return null;
            //}

            //priority = MathEx.Saturate( priority );

            //!!!!было
            //if( ( sound.Mode & SoundModes.Stream ) != 0 )
            //{
            //	if( sound.playingCount == 1 )
            //	{
            //		Log.Warning( "SoundSystem: It is impossible to play simultaneously more one channel stream sound." );
            //		return null;
            //	}
            //}

            if (group == null)
            {
                group = MasterChannelGroup;
            }

            SoundVirtualChannel virtualChannel = new SoundVirtualChannel();

            if ((sound.Mode & SoundModes.Mode3D) != 0)
            {
                activeVirtual3DChannels.Add(virtualChannel);
                if (activeVirtual3DChannels.Count > 2048)
                {
                    Log.Info("SoundSystem: Quantity of active 3D channels > 2048.");
                }
            }
            else
            {
                activeVirtual2DChannels.Add(virtualChannel);
                if (activeVirtual2DChannels.Count > 2048)
                {
                    Log.Info("SoundSystem: Quantity of active 2D channels > 2048.");
                }
            }

            virtualChannel.SoundPlayInit(attachedToScene, sound, group);
            virtualChannel.Priority = priority;

            if (!paused)
            {
                virtualChannel.Pause = false;
            }

            return(virtualChannel);
        }