示例#1
0
        //public void ApplyVolumeSettings()
        //{
        //  if (!IsStarted) return;

        //  double volume = Global.Config.SoundVolume / 100.0;
        //  if (volume < 0.0) volume = 0.0;
        //  if (volume > 1.0) volume = 1.0;
        //  _soundOutput.ApplyVolumeSettings(volume);
        //}

        public void SetSyncInputPin(ISyncSoundProvider source)
        {
            if (_asyncSoundProvider != null)
            {
                _asyncSoundProvider.DiscardSamples();
                _asyncSoundProvider = null;
            }
            _semiSync.DiscardSamples();
            _semiSync.BaseSoundProvider = null;
            _syncSoundProvider          = source;
            if (_outputProvider != null)
            {
                _outputProvider.BaseSoundProvider = source;
            }
        }
示例#2
0
 public void DiscardSamples()
 {
     if (BaseSoundProvider != null)
     {
         BaseSoundProvider.DiscardSamples();
     }
 }
示例#3
0
        public void DiscardSamples()
        {
            buffer.Clear();

            if (BaseSoundProvider != null)
            {
                BaseSoundProvider.DiscardSamples();
            }
        }
        public void DiscardSamples()
        {
            ResetBuffer();
            _extraCountHistory.Clear();
            _outputCountHistory.Clear();
            _hardCorrectionHistory.Clear();
            _baseConsecutiveEmptyFrames = 0;
            _baseEmptyFrameCorrectionHistory.Clear();
            _lastAdvertisedSamplesPerFrame = 0.0;
            _baseSamplesPerFrame.Clear();
            _outputBuffer   = new short[0];
            _resampleBuffer = new short[0];
            _resampleLengthRoundingError = 0.0;

            if (BaseSoundProvider != null)
            {
                BaseSoundProvider.DiscardSamples();
            }
        }
示例#5
0
 public void DiscardSamples()
 {
     _soundProvider.DiscardSamples();
 }
示例#6
0
 public void DiscardSamples()
 {
     _input.DiscardSamples();
     _buffer.Clear();
 }
示例#7
0
文件: Sound.cs 项目: stuff2600/RAEmus
        public void UpdateSound()
        {
            if (Global.Config.SoundEnabled == false || disposed)
            {
                if (asyncsoundProvider != null)
                {
                    asyncsoundProvider.DiscardSamples();
                }
                if (syncsoundProvider != null)
                {
                    syncsoundProvider.DiscardSamples();
                }
                return;
            }

            int samplesNeeded = SNDDXGetAudioSpace() * 2;

            short[] samples;

            int samplesProvided;


            if (Muted)
            {
                if (samplesNeeded == 0)
                {
                    return;
                }
                samples         = new short[samplesNeeded];
                samplesProvided = samplesNeeded;

                if (asyncsoundProvider != null)
                {
                    asyncsoundProvider.DiscardSamples();
                }
                if (syncsoundProvider != null)
                {
                    syncsoundProvider.DiscardSamples();
                }
            }
            else if (syncsoundProvider != null)
            {
                if (DSoundBuffer == null)
                {
                    return;                                       // can cause SNDDXGetAudioSpace() = 0
                }
                int nsampgot;

                syncsoundProvider.GetSamples(out samples, out nsampgot);

                samplesProvided = 2 * nsampgot;

                if (!Global.ForceNoThrottle)
                {
                    while (samplesNeeded < samplesProvided)
                    {
                        System.Threading.Thread.Sleep((samplesProvided - samplesNeeded) / 88);                         // let audio clock control sleep time
                        samplesNeeded = SNDDXGetAudioSpace() * 2;
                    }
                }
            }
            else if (asyncsoundProvider != null)
            {
                if (samplesNeeded == 0)
                {
                    return;
                }
                samples = new short[samplesNeeded];
                //if (asyncsoundProvider != null && Muted == false)
                //{
                semisync.BaseSoundProvider = asyncsoundProvider;
                semisync.GetSamples(samples);
                //}
                //else asyncsoundProvider.DiscardSamples();
                samplesProvided = samplesNeeded;
            }
            else
            {
                return;
            }

            int cursor = soundoffset;

            for (int i = 0; i < samplesProvided; i++)
            {
                short s = samples[i];
                SoundBuffer[cursor++] = (byte)(s & 0xFF);
                SoundBuffer[cursor++] = (byte)(s >> 8);

                if (cursor >= SoundBuffer.Length)
                {
                    cursor = 0;
                }
            }

            DSoundBuffer.Write(SoundBuffer, 0, LockFlags.EntireBuffer);

            soundoffset += samplesProvided * 2;
            soundoffset %= BufferSize;
        }
示例#8
0
 public void DiscardSamples()
 {
     input.DiscardSamples();
     buffer.clear();
 }
示例#9
0
 void ISoundProvider.DiscardSamples()
 {
     input.DiscardSamples();
 }
示例#10
0
 public void DiscardSamples()
 {
     source.DiscardSamples();
 }