Example #1
0
        public void GetSamplesAsync(short[] samples)
        {
            short[] sampin;
            int     numsamp;

            _input.GetSamplesSync(out sampin, out numsamp);
            _buffer.EnqueueSamples(sampin, numsamp);
            _buffer.OutputSamples(samples, samples.Length / 2);
        }
Example #2
0
        public void GetSamplesAsync(short[] samples)
        {
            short[] sampin;
            int     numsamp;

            input.GetSamplesSync(out sampin, out numsamp);
            buffer.enqueue_samples(sampin, numsamp);
            buffer.output_samples(samples, samples.Length / 2);
        }
Example #3
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            short[] sampin;
            int     nsampin;

            _soundProvider.GetSamplesSync(out sampin, out nsampin);

            short[] ret = new short[nsampin * 2];
            PushThroughSamples(sampin, ret, nsampin * 2);
            samples = ret;
            nsamp   = nsampin;
        }
 public void GetSamplesSync(out short[] samples, out int nsamp)
 {
     if (input != null)
     {
         short[] sampin;
         int     nsampin;
         input.GetSamplesSync(out sampin, out nsampin);
         EnqueueSamples(sampin, nsampin);
     }
     Flush();
     nsamp      = outbuf2pos / 2;
     samples    = outbuf2;
     outbuf2pos = 0;
 }
Example #5
0
        public void DumpAV(IVideoProvider v, ISoundProvider syncSoundProvider, out short[] samples, out int samplesprovided)
        {
            // Sound refactor TODO: we could just set it here, but we want the client to be responsible for mode switching? There may be non-trivial complications with when to switch modes that we don't want this object worrying about
            if (syncSoundProvider.SyncMode != SyncSoundMode.Sync)
            {
                throw new InvalidOperationException("Only sync mode is supported, set sync mode before passing in the sound provider");
            }

            VerifyParams();
            syncSoundProvider.GetSamplesSync(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);
            }
        }
Example #6
0
        public void Fetch()
        {
            int nsampl, nsampr;

            short[] sampl, sampr;
            _left.GetSamplesSync(out sampl, out nsampl);
            _right.GetSamplesSync(out sampr, out nsampr);

            int n = Math.Min(nsampl + _leftOverflowCount, nsampr + _rightOverflowCount);

            if (_samp.Length < n * 2)
            {
                _samp = new short[n * 2];
            }

            int i, j;

            for (i = 0, j = 0; i < _leftOverflowCount; i++, j++)
            {
                _samp[j * 2] = Mix(_leftOverflow, i);
            }
            for (i = 0; j < n; i++, j++)
            {
                _samp[j * 2] = Mix(sampl, i);
            }
            _leftOverflowCount = Math.Min(nsampl - i, 16);
            Array.Copy(sampl, i * 2, _leftOverflow, 0, _leftOverflowCount * 2);
            for (i = 0, j = 0; i < _rightOverflowCount; i++, j++)
            {
                _samp[j * 2 + 1] = Mix(_rightOverflow, i);
            }
            for (i = 0; j < n; i++, j++)
            {
                _samp[j * 2 + 1] = Mix(sampr, i);
            }
            _rightOverflowCount = Math.Min(nsampr - i, 16);
            Array.Copy(sampr, i * 2, _rightOverflow, 0, _rightOverflowCount * 2);

            _nsamp = n;
        }
Example #7
0
 /// <summary>
 /// Fetches sample data from the child ISoundProvider
 /// </summary>
 public void GetSamples()
 {
     SoundProvider.GetSamplesSync(out InputBuffer, out InputNSamp);
 }