コード例 #1
0
        public void HandleNewSlot(SourceVoiceSlot slot)
        {
#if JMOD_SANITY_CHECK
            if (CarriesStream)
            {
                throw new Exception();
            }
#endif
            DebugHistory("HandleNewSlot called (" + slot.ID + ")");
            slot.SetupBuffer(this, Looping);

            SourceVoiceSlot = slot;
            if (!Paused)
            {
                slot.CurrentSourceVoice.Start();
                State = ChannelState.Playing;
            }
            else
            {
                State = ChannelState.Paused;
            }

            if (LeavesVirtual != null)
            {
                LeavesVirtual(this, null);
            }
        }
コード例 #2
0
 public void Stop()
 {
     DebugHistory("Stop() called");
     if (!IsVirtual)
     {
         //SourceVoiceSlot.CurrentSourceVoice.Stop();
         SourceVoiceSlot.StopSourceVoice(StopReason.Stopped);
     }
     else
     {
         HandleFinishedSlot(false);
     }
 }
コード例 #3
0
        public void ReleaseSourceVoiceSlot(SourceVoiceSlot svs)
        {
#if JMOD_SANITY_CHECK
            bool usedContains = usedVoices.Contains(svs);
            bool freeContains = freeVoices.Contains(svs);
            if (!usedContains || freeContains)
            {
                throw new Exception("Balance not maintained");
            }
#endif

            usedVoices.Remove(svs);
            freeVoices.Push(svs);
        }
コード例 #4
0
        public void Update(float dtime, Listener listener)
        {
            ChannelState test1 = ChannelState.Paused, test2 = ChannelState.Paused;

            UpdateScore(listener.Position);
            if (SourceVoiceSlot != null)
            {
#if JMOD_SANITY_CHECK
                if (SourceVoiceSlot is SourceVoiceSlot && ((SourceVoiceSlot)SourceVoiceSlot).CurrentChannel != this)
                {
                    throw new Exception();
                }
                if (SourceVoiceSlot is StreamSourceVoiceSlot && ((StreamSourceVoiceSlot)SourceVoiceSlot).CurrentChannel != this)
                {
                    throw new Exception();
                }
#endif
                test1 = State;
                if (State == ChannelState.Stopped)
                {
                    //JMOD.Sound.DebugOutput("WARNING! State is Stopped, but SourceVoiceSlot not null");
                    throw new Exception("WARNING! State is Stopped, but SourceVoiceSlot not null [" + system.NUpdates + "]");
                }
                SourceVoiceSlot.Update();
                test2 = State;
            }
#if JMOD_SANITY_CHECK
            else if (State != ChannelState.Virtual)
            {
                throw new Exception();
            }
#endif
            if (State == ChannelState.Virtual)
            {
                elapsedSamples += dtime * sampleRate;
                if (elapsedSamples >= totalSamples)
                {
                    JMOD.Sound.DebugOutput("Virtual channel reached end");
                    if (Looping)
                    {
                        JMOD.Sound.DebugOutput("Restarting...");
                        elapsedSamples -= totalSamples;
                    }
                    else
                    {
                        DebugHistory("Virtual stop detected in update");
                        JMOD.Sound.DebugOutput("Stopping...");
                        HandleFinishedSlot(true);
                        system.ReleaseVirtualChannel(this);
                    }
                }
                return;
            }

            if (State == ChannelState.WaitingToPlay)
            {
                DebugHistory("WaitingToPlay dealt with in Update()");
                if (!CarriesStream)
                {
                    UpdateOutputMatrix(system.Listener);
                }
                SourceVoiceSlot.CurrentSourceVoice.Start();
                State = ChannelState.Playing;
            }
            else if (Sound.Is3DSound && !IsVirtual)
            {
                UpdateOutputMatrix(listener);
            }
        }