From d30d5ba06daa315aab4df6e6d0051da609a6bdbc Mon Sep 17 00:00:00 2001 From: adelikat Date: Fri, 27 Mar 2015 23:24:58 +0000 Subject: [PATCH] Apple II - a bad attempt at wiring up sound, not hooked up since it crashes, also checking in some code that visual studio wants to be in the .sln because I am tired of reverting it --- .../Computers/AppleII/AppleII.cs | 21 +++++++++++++++++-- .../Computers/AppleII/Virtu/Speaker.cs | 2 ++ BizHawk.sln | 3 --- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs index a70bcc871e..806c86550b 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/AppleII.cs @@ -1,7 +1,9 @@ using System.IO; +using System.Linq; using BizHawk.Emulation.Common; using Jellyfish.Virtu; using Jellyfish.Virtu.Services; +using System; namespace BizHawk.Emulation.Cores.Computers.AppleII { @@ -30,11 +32,12 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII _machine = new Machine(); var vidService = new BizVideoService(_machine); + _soundService = new BizAudioService(_machine); var gpService = new Jellyfish.Virtu.Services.GamePortService(_machine); var kbService = new BizKeyboardService(_machine); _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.DebugService), new Jellyfish.Virtu.Services.DebugService(_machine)); - _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.AudioService), new BizAudioService(_machine)); + _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.AudioService), _soundService); _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.VideoService), vidService); _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.GamePortService), gpService); _machine.Services.AddService(typeof(Jellyfish.Virtu.Services.KeyboardService), kbService); @@ -55,6 +58,7 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII private readonly byte[] _disk1; private readonly byte[] _appleIIRom; private readonly byte[] _diskIIRom; + private readonly BizAudioService _soundService; private static readonly ControllerDefinition AppleIIController = new ControllerDefinition @@ -81,13 +85,26 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII } } - private class BizAudioService : AudioService + private class BizAudioService : AudioService, ISyncSoundProvider { public BizAudioService(Machine _machine) : base(_machine) { } public override void SetVolume(float volume) { } + + public void GetSamples(out short[] samples, out int nsamp) + { + samples = Array.ConvertAll(Source, b => (short)b); // TODO: is it really 8 bit? + + nsamp = Source.Length; + } + + public void DiscardSamples() + { + //TODO + //Source.DiscardSamples(); + } } private void FrameAdv(bool render, bool rendersound) diff --git a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Speaker.cs b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Speaker.cs index e1cf991648..a19e53fe71 100644 --- a/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Speaker.cs +++ b/BizHawk.Emulation.Cores/Computers/AppleII/Virtu/Speaker.cs @@ -86,5 +86,7 @@ namespace Jellyfish.Virtu private int _totalCycles; private long _lastCycles; private float _volume; + + public AudioService AudioService { get { return _audioService; } } } } diff --git a/BizHawk.sln b/BizHawk.sln index 9fa06fd945..9c86993233 100644 --- a/BizHawk.sln +++ b/BizHawk.sln @@ -138,9 +138,6 @@ Global {E6B436B1-A3CD-4C9A-8F76-5D7154726884} = {0540A9A6-977E-466D-8BD3-1D8590BD5282} {B95649F5-A0AE-41EB-B62B-578A2AFF5E18} = {B51F1139-3D2C-41BE-A762-EF1F9B41EACA} EndGlobalSection - GlobalSection(Performance) = preSolution - HasPerformanceSessions = true - EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution StartupItem = BizHawk.Client.EmuHawk\BizHawk.Client.EmuHawk.csproj EndGlobalSection