Example #1
0
        unsafe void PrepSound()
        {
            fixed(short *sl = LeftBuffer, sr = RightBuffer)
            {
                for (uint i = 0; i < SampPerFrame * 2; i += 2)
                {
                    int s = (sl[i] + sl[i + 1]) / 2;
                    if (s != LatchL)
                    {
                        blip_left.AddDelta(i, s - LatchL);
                        LatchL = s;
                    }
                    s = (sr[i] + sr[i + 1]) / 2;
                    if (s != LatchR)
                    {
                        blip_right.AddDelta(i, s - LatchR);
                        LatchR = s;
                    }
                }
            }

            blip_left.EndFrame(SampPerFrame * 2);
            blip_right.EndFrame(SampPerFrame * 2);
            int count = blip_left.SamplesAvailable();

            if (count != blip_right.SamplesAvailable())
            {
                throw new Exception("Sound problem?");
            }

            // calling blip.Clear() causes rounding fractions to be reset,
            // and if only one channel is muted, in subsequent frames we can be off by a sample or two
            // not a big deal, but we didn't account for it.  so we actually complete the entire
            // audio read and then stamp it out if muted.

            blip_left.ReadSamplesLeft(SampleBuffer, count);
            if (L.Muted)
            {
                fixed(short *p = SampleBuffer)
                {
                    for (int i = 0; i < SampleBuffer.Length; i += 2)
                    {
                        p[i] = 0;
                    }
                }
            }

            blip_right.ReadSamplesRight(SampleBuffer, count);
            if (R.Muted)
            {
                fixed(short *p = SampleBuffer)
                {
                    for (int i = 1; i < SampleBuffer.Length; i += 2)
                    {
                        p[i] = 0;
                    }
                }
            }
            SampleBufferContains = count;
        }
Example #2
0
 public void GetSamplesSync(out short[] samples, out int nsamp)
 {
     blip.EndFrame((uint)_tStatesPerFrame);
     nsamp   = blip.SamplesAvailable();
     samples = new short[nsamp * 2];
     blip.ReadSamples(samples, nsamp, true);
     for (int i = 0; i < nsamp * 2; i += 2)
     {
         samples[i + 1] = samples[i];
     }
 }
Example #3
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip.EndFrame(master_audio_clock);

            nsamp = _blip.SamplesAvailable();

            samples = new short[nsamp * 2];

            _blip.ReadSamples(samples, nsamp, true);

            master_audio_clock = 0;
        }
Example #4
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            blip_L.EndFrame(sampleclock);
            blip_R.EndFrame(sampleclock);

            nsamp   = Math.Max(Math.Max(blip_L.SamplesAvailable(), blip_R.SamplesAvailable()), 1);
            samples = new short[nsamp * 2];

            blip_L.ReadSamplesLeft(samples, nsamp);
            blip_R.ReadSamplesRight(samples, nsamp);

            sampleclock = 0;
        }
Example #5
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip.EndFrame((uint)_clocksPerFrame);
            nsamp   = _blip.SamplesAvailable();
            samples = new short[nsamp * 2];
            _blip.ReadSamples(samples, nsamp, true);
            for (int i = 0; i < nsamp * 2; i += 2)
            {
                samples[i + 1] = samples[i];
            }

            clockCounter = 0;
        }
Example #6
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            AudioChange();

            _blip.EndFrame((uint)ClockPerFrame);
            nsamp   = _blip.SamplesAvailable();
            samples = new short[nsamp * 2];
            _blip.ReadSamples(samples, nsamp, true);

            for (int i = 0; i < nsamp * 2; i += 2)
            {
                samples[i + 1] = samples[i];
            }
        }
Example #7
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip_C.EndFrame(master_audio_clock);

            nsamp = _blip_C.SamplesAvailable();

            samples = new short[nsamp * 2];

            if (nsamp != 0)
            {
                _blip_C.ReadSamples(samples, nsamp, false);
            }

            master_audio_clock = 0;
        }
Example #8
0
        private void ProcessSoundEnd()
        {
            _blipL.EndFrame(_blipAccumulate);
            _blipR.EndFrame(_blipAccumulate);
            _blipAccumulate = 0;

            _soundoutbuffcontains = _blipL.SamplesAvailable();
            if (_soundoutbuffcontains != _blipR.SamplesAvailable())
            {
                throw new InvalidOperationException("Audio processing error");
            }

            _blipL.ReadSamplesLeft(_soundoutbuff, _soundoutbuffcontains);
            _blipR.ReadSamplesRight(_soundoutbuff, _soundoutbuffcontains);
        }
Example #9
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            uint f_clock = LibMSX.MSX_get_audio(MSX_Pntr, Aud, ref num_samp);

            for (int i = 0; i < num_samp; i++)
            {
                blip.AddDelta((uint)Aud[i * 2], Aud[i * 2 + 1]);
            }

            blip.EndFrame(f_clock);

            nsamp   = blip.SamplesAvailable();
            samples = new short[nsamp * 2];

            blip.ReadSamples(samples, nsamp, true);
        }
Example #10
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip_L.EndFrame(master_audio_clock);
            _blip_R.EndFrame(master_audio_clock);

            nsamp = _blip_L.SamplesAvailable();

            samples = new short[nsamp * 2];

            if (nsamp != 0)
            {
                _blip_L.ReadSamplesLeft(samples, nsamp);
                _blip_R.ReadSamplesRight(samples, nsamp);
            }

            master_audio_clock = 0;
        }
Example #11
0
File: Audio.cs Project: m35/BizHawk
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip.EndFrame(master_audio_clock);

            nsamp = _blip.SamplesAvailable();

            samples = new short[nsamp * 2];

            _blip.ReadSamples(samples, nsamp, true);

            for (int i = 0; i < nsamp * 2; i += 2)
            {
                samples[i + 1] = samples[i];
            }

            master_audio_clock = 0;
        }
Example #12
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            blip.EndFrame(apu.sampleclock);
            apu.sampleclock = 0;

            nsamp   = blip.SamplesAvailable();
            samples = new short[nsamp * 2];

            blip.ReadSamples(samples, nsamp, true);
            // duplicate to stereo
            for (int i = 0; i < nsamp * 2; i += 2)
            {
                samples[i + 1] = samples[i];
            }

            Board.ApplyCustomAudio(samples);
        }
Example #13
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip_L.EndFrame(master_audio_clock);
            _blip_R.EndFrame(master_audio_clock);

            nsamp = _blip_L.SamplesAvailable();

            // only for running without errors, remove this line once you get audio
            nsamp = 1;

            samples = new short[nsamp * 2];

            // uncomment these once you have audio to play
            //_blip_L.ReadSamplesLeft(samples, nsamp);
            //_blip_R.ReadSamplesRight(samples, nsamp);

            master_audio_clock = 0;
        }
        private void ProcessSound()
        {
            var len = bridge.LibretroBridge_GetAudioSize(cbHandler);

            if (len == 0)             // no audio?
            {
                return;
            }
            if (len > _inSampBuf.Length)
            {
                _inSampBuf = new short[len];
            }
            var ns = 0;

            bridge.LibretroBridge_GetAudio(cbHandler, ref ns, _inSampBuf);

            for (uint i = 0; i < ns; i++)
            {
                int curr = _inSampBuf[i * 2];

                if (curr != _latchL)
                {
                    int diff = _latchL - curr;
                    _latchL = curr;
                    _blipL.AddDelta(i, diff);
                }

                curr = _inSampBuf[(i * 2) + 1];

                if (curr != _latchR)
                {
                    int diff = _latchR - curr;
                    _latchR = curr;
                    _blipR.AddDelta(i, diff);
                }
            }

            _blipL.EndFrame((uint)ns);
            _blipR.EndFrame((uint)ns);
            _outSamps = _blipL.SamplesAvailable();
            _blipL.ReadSamplesLeft(_outSampBuf, _outSamps);
            _blipR.ReadSamplesRight(_outSampBuf, _outSamps);
        }
Example #15
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            _blip.EndFrame((uint)_sampleClock);
            _sampleClock = 0;

            nsamp = _blip.SamplesAvailable();
            int targetLength = nsamp * 2;

            if (_sampleBuffer.Length != targetLength)
            {
                _sampleBuffer = new short[targetLength];
            }

            _blip.ReadSamplesLeft(_sampleBuffer, nsamp);
            for (int i = 0; i < _sampleBuffer.Length; i += 2)
            {
                _sampleBuffer[i + 1] = _sampleBuffer[i];
            }

            samples = _sampleBuffer;
        }
Example #16
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            uint f_clock = LibMSX.MSX_get_audio(MSX_Pntr, Aud_L, Aud_R, ref num_samp_L, ref num_samp_R);

            for (int i = 0; i < num_samp_L; i++)
            {
                blip_L.AddDelta(Aud_L[i * 2], (int)Aud_L[i * 2 + 1]);
            }

            for (int i = 0; i < num_samp_R; i++)
            {
                blip_R.AddDelta(Aud_R[i * 2], (int)Aud_R[i * 2 + 1]);
            }

            blip_L.EndFrame(f_clock);
            blip_R.EndFrame(f_clock);

            nsamp   = Math.Max(Math.Max(blip_L.SamplesAvailable(), blip_R.SamplesAvailable()), 1);
            samples = new short[nsamp * 2];

            blip_L.ReadSamplesLeft(samples, nsamp);
            blip_R.ReadSamplesRight(samples, nsamp);
        }
Example #17
0
            public void GetSamplesSync(out short[] samples, out int nsamp)
            {
                //Console.WriteLine("ASync: {0}", nes.apu.dlist.Count);
                foreach (var d in nes.apu.dlist)
                {
                    blip.AddDelta(d.time, d.value);
                }
                nes.apu.dlist.Clear();
                blip.EndFrame(nes.apu.sampleclock);
                nes.apu.sampleclock = 0;

                nsamp   = blip.SamplesAvailable();
                samples = new short[nsamp * 2];

                blip.ReadSamples(samples, nsamp, true);
                // duplicate to stereo
                for (int i = 0; i < nsamp * 2; i += 2)
                {
                    samples[i + 1] = samples[i];
                }

                nes.Board.ApplyCustomAudio(samples);
            }
Example #18
0
        public void GetSamplesSync(out short[] samples, out int nsamp)
        {
            if (!disablePSG)
            {
                blip_L.EndFrame(sampleclock);
                blip_R.EndFrame(sampleclock);

                nsamp   = Math.Max(Math.Max(blip_L.SamplesAvailable(), blip_R.SamplesAvailable()), 1);
                samples = new short[nsamp * 2];

                blip_L.ReadSamplesLeft(samples, nsamp);
                blip_R.ReadSamplesRight(samples, nsamp);

                ApplyYMAudio(samples);
            }
            else
            {
                nsamp   = 735;
                samples = new short[nsamp * 2];
                ApplyYMAudio(samples);
            }

            sampleclock = 0;
        }