Beispiel #1
0
 public void SetAsyncInputPin(ISoundProvider source)
 {
     syncsoundProvider          = null;
     asyncsoundProvider         = source;
     semisync.BaseSoundProvider = source;
     semisync.RecalculateMagic(Global.CoreComm.VsyncRate);
 }
Beispiel #2
0
		DCFilter(ISoundProvider input, ISyncSoundProvider syncinput, int filterwidth)
		{
			if (filterwidth < 8 || filterwidth > 65536)
				throw new ArgumentOutOfRangeException();
			this.input = input;
			this.syncinput = syncinput;
			depth = DepthFromFilterwidth(filterwidth);
		}
Beispiel #3
0
 public static DCFilter AsISyncSoundProvider(ISyncSoundProvider syncinput, int filterwidth)
 {
     if (syncinput == null)
     {
         throw new ArgumentNullException();
     }
     return(new DCFilter(null, syncinput, filterwidth));
 }
Beispiel #4
0
 DCFilter(ISoundProvider input, ISyncSoundProvider syncinput, int filterwidth)
 {
     if (filterwidth < 8 || filterwidth > 65536)
     {
         throw new ArgumentOutOfRangeException();
     }
     this.input     = input;
     this.syncinput = syncinput;
     depth          = DepthFromFilterwidth(filterwidth);
 }
Beispiel #5
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;
            }
        }
Beispiel #6
0
 public void SetAsyncInputPin(ISoundProvider source)
 {
     if (_syncSoundProvider != null)
     {
         _syncSoundProvider.DiscardSamples();
         _syncSoundProvider = null;
     }
     if (_outputProvider != null)
     {
         _outputProvider.DiscardSamples();
         _outputProvider.BaseSoundProvider = null;
     }
     _asyncSoundProvider         = source;
     _semiSync.BaseSoundProvider = source;
     _semiSync.RecalculateMagic(Global.Emulator.CoreComm.VsyncRate);
 }
Beispiel #7
0
        public void DumpAV(IVideoProvider v, ISyncSoundProvider s, out short[] samples, out int samplesprovided)
        {
            VerifyParams();
            s.GetSamples(out samples, out samplesprovided);
            exaudio_num += samplesprovided * (long)fpsnum;

            // todo: scan for duplicate frames (ie, video content exactly matches previous frame) and for them, skip the threshone step
            // this is a good idea, but expensive on time.  is it worth it?

            if (exaudio_num >= threshone)
            {
                // add frame once
                w.AddFrame(v);
                exaudio_num -= threshtotal;
            }
            else
            {
                Console.WriteLine("Dropped Frame!");
            }
            while (exaudio_num >= threshmore)
            {
                // add frame again!
                w.AddFrame(v);
                exaudio_num -= threshtotal;
                Console.WriteLine("Dupped Frame!");
            }

            // a bit of hackey due to the fact that this api can't read a
            // usable buffer length separately from the actual length of the buffer
            if (samples.Length == samplesprovided * channels)
            {
                w.AddSamples(samples);
            }
            else
            {
                if (_samples.Length != samplesprovided * channels)
                {
                    _samples = new short[samplesprovided * channels];
                }

                Buffer.BlockCopy(samples, 0, _samples, 0, samplesprovided * channels * sizeof(short));
                w.AddSamples(_samples);
            }
        }
Beispiel #8
0
		public void DumpAV(IVideoProvider v, ISyncSoundProvider s, out short[] samples, out int samplesprovided)
		{
			VerifyParams();
			s.GetSamples(out samples, out samplesprovided);
			exaudio_num += samplesprovided * (long)fpsnum;

			// todo: scan for duplicate frames (ie, video content exactly matches previous frame) and for them, skip the threshone step
			// this is a good idea, but expensive on time.  is it worth it?

			if (exaudio_num >= threshone)
			{
				// add frame once
				w.AddFrame(v);
				exaudio_num -= threshtotal;
			}
			else
			{
				Console.WriteLine("Dropped Frame!");
			}
			while (exaudio_num >= threshmore)
			{
				// add frame again!
				w.AddFrame(v);
				exaudio_num -= threshtotal;
				Console.WriteLine("Dupped Frame!");
			}

			// a bit of hackey due to the fact that this api can't read a
			// usable buffer length separately from the actual length of the buffer
			if (samples.Length == samplesprovided * channels)
			{
				w.AddSamples(samples);
			}
			else
			{
				if (_samples.Length != samplesprovided * channels)
					_samples = new short[samplesprovided * channels];

				Buffer.BlockCopy(samples, 0, _samples, 0, samplesprovided * channels * sizeof(short));
				w.AddSamples(_samples);
			}
		}
        /// <summary>
        ///
        /// </summary>
        /// <param name="quality">0 to 10</param>
        /// <param name="rationum">numerator of srate change ratio (inrate / outrate)</param>
        /// <param name="ratioden">demonenator of srate change ratio (inrate / outrate)</param>
        /// <param name="sratein">sampling rate in, rounded to nearest hz</param>
        /// <param name="srateout">sampling rate out, rounded to nearest hz</param>
        /// <param name="drainer">function which accepts output as produced. if null, act as an ISyncSoundProvider</param>
        /// <param name="input">source to take input from when output is requested. if null, no autofetching</param>
        public SpeexResampler(int quality, uint rationum, uint ratioden, uint sratein, uint srateout, Action <short[], int> drainer = null, ISyncSoundProvider input = null)
        {
            if (drainer != null && input != null)
            {
                throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");
            }

            LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS;
            st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err);

            if (st == IntPtr.Zero)
            {
                throw new Exception("LibSpeexDSP returned null!");
            }

            CheckError(err);

            this.drainer = drainer ?? InternalDrain;
            this.input   = input;

            outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128];
        }
Beispiel #10
0
 public void SetSyncInputPin(ISyncSoundProvider source)
 {
     syncsoundProvider  = source;
     asyncsoundProvider = null;
     semisync.DiscardSamples();
 }
Beispiel #11
0
 public MetaspuAsync(ISyncSoundProvider input, ESynchMethod method)
 {
     buffer     = Metaspu.metaspu_construct(method);
     this.input = input;
 }
Beispiel #12
0
 public void SetAsyncInputPin(ISoundProvider source)
 {
     if (_syncSoundProvider != null)
     {
         _syncSoundProvider.DiscardSamples();
         _syncSoundProvider = null;
     }
     if (_outputProvider != null)
     {
         _outputProvider.DiscardSamples();
         _outputProvider.BaseSoundProvider = null;
     }
     _asyncSoundProvider = source;
     _semiSync.BaseSoundProvider = source;
     _semiSync.RecalculateMagic(Global.Emulator.CoreComm.VsyncRate);
 }
Beispiel #13
0
		public MetaspuAsync(ISyncSoundProvider input, ESynchMethod method)
		{
			buffer = Metaspu.metaspu_construct(method);
			this.input = input;
		}
Beispiel #14
0
		public void SetAsyncInputPin(ISoundProvider source)
		{
			syncsoundProvider = null;
			asyncsoundProvider = source;
			semisync.BaseSoundProvider = source;
			semisync.RecalculateMagic(Global.CoreComm.VsyncRate);
		}
Beispiel #15
0
		public void SetSyncInputPin(ISyncSoundProvider source)
		{
			syncsoundProvider = source;
			asyncsoundProvider = null;
			semisync.DiscardSamples();
		}
Beispiel #16
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;
     }
 }
Beispiel #17
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="quality">0 to 10</param>
		/// <param name="rationum">numerator of srate change ratio (inrate / outrate)</param>
		/// <param name="ratioden">demonenator of srate change ratio (inrate / outrate)</param>
		/// <param name="sratein">sampling rate in, rounded to nearest hz</param>
		/// <param name="srateout">sampling rate out, rounded to nearest hz</param>
		/// <param name="drainer">function which accepts output as produced. if null, act as an ISyncSoundProvider</param>
		/// <param name="input">source to take input from when output is requested. if null, no autofetching</param>
		public SpeexResampler(int quality, uint rationum, uint ratioden, uint sratein, uint srateout, Action<short[], int> drainer = null, ISyncSoundProvider input = null)
		{
			if (drainer != null && input != null)
				throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?");

			LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS;
			st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err);

			if (st == IntPtr.Zero)
				throw new Exception("LibSpeexDSP returned null!");

			CheckError(err);

			this.drainer = drainer ?? InternalDrain;
			this.input = input;

			outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128];
		}
Beispiel #18
0
		public static DCFilter AsISyncSoundProvider(ISyncSoundProvider syncinput, int filterwidth)
		{
			if (syncinput == null)
				throw new ArgumentNullException();
			return new DCFilter(null, syncinput, filterwidth);
		}