Esempio n. 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;
        }
Esempio n. 2
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;
        }
Esempio n. 3
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;
        }
        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);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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;
        }