Exemple #1
0
            public void GetSamples(short[] samples)
            {
                //Console.WriteLine("Sync: {0}", nes.apu.dlist.Count);
                int nsamp = samples.Length / 2;

                if (nsamp > blipbuffsize)                 // oh well.
                {
                    nsamp = blipbuffsize;
                }
                uint targetclock = (uint)blip.ClocksNeeded(nsamp);
                uint actualclock = nes.apu.sampleclock;

                foreach (var d in nes.apu.dlist)
                {
                    blip.AddDelta(d.time * targetclock / actualclock, d.value);
                }
                nes.apu.dlist.Clear();
                blip.EndFrame(targetclock);
                nes.apu.sampleclock = 0;

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

                //mix in the cart's extra sound circuit
                nes.board.ApplyCustomAudio(samples);
            }