public GameState( ISceneManager sceneManager, IResourceManager resourceManager, IPaletteProvider paletteProvider, IEngineDataManager engineDataManager, IRenderWindow renderWindow, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <IMapRenderer> getMapEngine, Func <eSessionType, ISessionManager> getSessionManager, Func <string, IRandomizedMapGenerator> getRandomizedMapGenerator ) { this.sceneManager = sceneManager; this.resourceManager = resourceManager; this.paletteProvider = paletteProvider; this.getMapEngine = getMapEngine; this.getSessionManager = getSessionManager; this.engineDataManager = engineDataManager; this.renderWindow = renderWindow; this.soundProvider = soundProvider; this.mpqProvider = mpqProvider; this.getRandomizedMapGenerator = getRandomizedMapGenerator; originalMouseCursor = renderWindow.MouseCursor; PlayerInfos = new List <PlayerInfo>(); mapDataLookup = new List <MapCellInfo>(); }
public SyncToAsyncProvider(Func <double> getCoreVsyncRateCallback, ISoundProvider baseProvider) { _outputProvider = new SoundOutputProvider(getCoreVsyncRateCallback, standaloneMode: true) { BaseSoundProvider = baseProvider }; }
private long _soundRemainder; // audio timekeeping for video dumping public void DumpAV(IVideoProvider v, ISoundProvider asyncSoundProvider, out short[] samples, out int samplesprovided) { // Sound refactor TODO: we could try 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 (asyncSoundProvider.SyncMode != SyncSoundMode.Async) { throw new InvalidOperationException("Only async mode is supported, set async mode before passing in the sound provider"); } if (!aset || !vset) { throw new InvalidOperationException("Must set params first!"); } long nsampnum = samplerate * (long)fpsden + _soundRemainder; long nsamp = nsampnum / fpsnum; // exactly remember fractional parts of an audio sample _soundRemainder = nsampnum % fpsnum; samples = new short[nsamp * channels]; asyncSoundProvider.GetSamplesAsync(samples); samplesprovided = (int)nsamp; w.AddFrame(v); w.AddSamples(samples); }
/// <summary> /// Attaches a new input pin which will run either in sync or async mode depending /// on its SyncMode property. Once attached, the sync mode must not change unless /// the pin is re-attached. /// </summary> public void SetInputPin(ISoundProvider source) { if (_bufferedProvider != null) { _bufferedProvider.BaseSoundProvider = null; _bufferedProvider.DiscardSamples(); _bufferedProvider = null; } if (source == null) { return; } if (source.SyncMode == SyncSoundMode.Sync) { _bufferedProvider = _outputProvider; } else if (source.SyncMode == SyncSoundMode.Async) { _bufferedAsync.RecalculateMagic(Global.Emulator.VsyncRate()); _bufferedProvider = _bufferedAsync; } else { throw new InvalidOperationException("Unsupported sync mode."); } _bufferedProvider.BaseSoundProvider = source; }
DCFilter(ISoundProvider input, ISyncSoundProvider syncinput, int filterwidth) { if (filterwidth < 8 || filterwidth > 65536) throw new ArgumentOutOfRangeException(); this.input = input; this.syncinput = syncinput; depth = DepthFromFilterwidth(filterwidth); }
public static DCFilter AsISoundProvider(ISoundProvider input, int filterwidth) { if (input == null) { throw new ArgumentNullException(); } return(new DCFilter(input, null, filterwidth)); }
DCFilter(ISoundProvider input, ISyncSoundProvider syncinput, int filterwidth) { if (filterwidth < 8 || filterwidth > 65536) { throw new ArgumentOutOfRangeException(); } this.input = input; this.syncinput = syncinput; depth = DepthFromFilterwidth(filterwidth); }
/// <summary> /// Signs that the device has been attached to the Spectrum virtual machine /// </summary> public void OnAttachedToVm(ISpectrumVm hostVm) { HostVm = hostVm; _soundConfiguration = hostVm.SoundConfiguration; _soundProvider = hostVm.SoundProvider; _frameTacts = hostVm.FrameTacts; _tactsPerSample = _soundConfiguration.TactsPerSample; _lpf = new BandPassFilter(32, _soundConfiguration.AudioSampleRate, 150.0, 8000.0); Reset(); }
public void AddSource(ISoundProvider source, short maxVolume) { SoundProviders.Add(new Provider { SoundProvider = source, MaxVolume = maxVolume }); EqualizeVolumes(); }
// Detached mode public DCFilter(int filterwidth) { if (filterwidth < 8 || filterwidth > 65536) { throw new ArgumentOutOfRangeException(); } _depth = DepthFromFilterwidth(filterwidth); _soundProvider = null; }
public void AddSource(ISoundProvider source, short maxVolume, string description) { SoundProviders.Add(new Provider { SoundProvider = source, MaxVolume = maxVolume, ProviderDescription = description }); EqualizeVolumes(); }
/// <summary> /// Adds an ISoundProvider to the SyncSoundMixer /// </summary> /// <param name="source">The source ISoundProvider</param> /// <param name="sourceDescription">An ident string for the ISoundProvider (useful when debugging)</param> /// <param name="sourceMaxVolume">The MaxVolume level for this particular ISoundProvider</param> /// <param name="isMono">If this is true then only half the samples should be present</param> public void PinSource(ISoundProvider source, string sourceDescription, short sourceMaxVolume) { _soundProviders.Add(new ChildProvider { SoundProvider = source, ProviderDescription = sourceDescription, MaxVolume = sourceMaxVolume }); EqualizeVolumes(); }
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); } }
public MainMenu( IRenderWindow renderWindow, ISceneManager sceneManager, ITextDictionary textDictionary, IResourceManager resourceManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <eButtonType, IButton> createButton ) { this.renderWindow = renderWindow; this.sceneManager = sceneManager; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true; diabloLogoRight = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120)); diabloLogoRight.Blend = true; diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120)); diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120)); btnSinglePlayer = createButton(eButtonType.Wide); btnSinglePlayer.Text = textDictionary.Translate("strStartMenu1"); btnSinglePlayer.Location = new Point(264, 290); btnSinglePlayer.OnActivate = OnSinglePlayerClicked; btnWebsite = createButton(eButtonType.Wide); btnWebsite.Text = "Visit Github".ToUpper(); btnWebsite.Location = new Point(264, 330); btnWebsite.OnActivate = OnVisitWebsiteClicked; btnExit = createButton(eButtonType.Wide); btnExit.Text = textDictionary.Translate("strexitentiregame"); btnExit.Location = new Point(264, 500); btnExit.OnActivate = OnExitClicked; btnCredits = createButton(eButtonType.Short); btnCredits.Text = textDictionary.Translate("strGameCredits"); /* TODO: We apparently need a 'half font' option... */ btnCredits.Location = new Point(264, 470); btnCredits.OnActivate = OnCreditsClicked; labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static); versionLabel = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.02 Pre-Alpha"); urlLabel = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/"); urlLabel.TextColor = Color.Magenta; soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle)); soundProvider.PlaySong(); }
//public void ApplyVolumeSettings() //{ // if (!IsStarted) return; // double volume = Global.Config.SoundVolume / 100.0; // if (volume < 0.0) volume = 0.0; // if (volume > 1.0) volume = 1.0; // _soundOutput.ApplyVolumeSettings(volume); //} public void SetSyncInputPin(ISyncSoundProvider source) { if (_asyncSoundProvider != null) { _asyncSoundProvider.DiscardSamples(); _asyncSoundProvider = null; } _semiSync.DiscardSamples(); _semiSync.BaseSoundProvider = null; _syncSoundProvider = source; if (_outputProvider != null) { _outputProvider.BaseSoundProvider = source; } }
public void SetAsyncInputPin(ISoundProvider source) { if (_syncSoundProvider != null) { _syncSoundProvider.DiscardSamples(); _syncSoundProvider = null; } if (_outputProvider != null) { _outputProvider.DiscardSamples(); _outputProvider.BaseSoundProvider = null; } _asyncSoundProvider = source; _semiSync.BaseSoundProvider = source; _semiSync.RecalculateMagic(Global.Emulator.CoreComm.VsyncRate); }
public DCFilter(ISoundProvider input, int filterwidth) { if (input == null) { throw new ArgumentNullException(); } if (filterwidth < 8 || filterwidth > 65536) { throw new ArgumentOutOfRangeException(); } _depth = DepthFromFilterwidth(filterwidth); _soundProvider = input; }
private long _soundRemainder; // audio timekeeping for video dumping public void DumpAV(IVideoProvider v, ISoundProvider s, out short[] samples, out int samplesprovided) { if (!aset || !vset) throw new InvalidOperationException("Must set params first!"); long nsampnum = samplerate * (long)fpsden + _soundRemainder; long nsamp = nsampnum / fpsnum; // exactly remember fractional parts of an audio sample _soundRemainder = nsampnum % fpsnum; samples = new short[nsamp * channels]; s.GetSamples(samples); samplesprovided = (int)nsamp; w.AddFrame(v); w.AddSamples(samples); }
public void DisableSource(ISoundProvider source) { var sp = SoundProviders.Where(a => a.SoundProvider == source); if (sp.Count() == 1) { SoundProviders.Remove(sp.First()); } else if (sp.Count() > 1) { foreach (var s in sp) { SoundProviders.Remove(s); } } EqualizeVolumes(); }
public MainMenu( IRenderWindow renderWindow, ISceneManager sceneManager, IResourceManager resourceManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, Func <eButtonType, IButton> createButton, Func <eSceneType, IScene> getScene // Temporary until SDL load functions are sped up ) { this.renderWindow = renderWindow; this.sceneManager = sceneManager; backgroundSprite = renderWindow.LoadSprite(ResourcePaths.GameSelectScreen, Palettes.Sky); diabloLogoLeft = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireLeft, Palettes.Units, new Point(400, 120)); diabloLogoLeft.Blend = true; diabloLogoRight = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoFireRight, Palettes.Units, new Point(400, 120)); diabloLogoRight.Blend = true; diabloLogoLeftBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackLeft, Palettes.Units, new Point(400, 120)); diabloLogoRightBlack = renderWindow.LoadSprite(ResourcePaths.Diablo2LogoBlackRight, Palettes.Units, new Point(400, 120)); btnSinglePlayer = createButton(eButtonType.Wide); btnSinglePlayer.Text = "Single Player".ToUpper(); btnSinglePlayer.Location = new Point(264, 290); btnSinglePlayer.OnActivate = OnSinglePlayerClicked; btnWebsite = createButton(eButtonType.Wide); btnWebsite.Text = "Visit Github".ToUpper(); btnWebsite.Location = new Point(264, 460); btnWebsite.OnActivate = OnVisitWebsiteClicked; btnExit = createButton(eButtonType.Wide); btnExit.Text = "Exit Diablo II".ToUpper(); btnExit.Location = new Point(264, 500); btnExit.OnActivate = OnExitClicked; labelFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Static); versionLabel = renderWindow.CreateLabel(labelFont, new Point(50, 555), "v0.01 Pre-Alpha"); urlLabel = renderWindow.CreateLabel(labelFont, new Point(50, 569), "https://github.com/essial/OpenDiablo2/"); urlLabel.TextColor = Color.Magenta; soundProvider.LoadSong(mpqProvider.GetStream(ResourcePaths.BGMTitle)); soundProvider.PlaySong(); }
private long _soundRemainder; // audio timekeeping for video dumping public void DumpAV(IVideoProvider v, ISoundProvider s, out short[] samples, out int samplesprovided) { if (!aset || !vset) { throw new InvalidOperationException("Must set params first!"); } long nsampnum = samplerate * (long)fpsden + _soundRemainder; long nsamp = nsampnum / fpsnum; // exactly remember fractional parts of an audio sample _soundRemainder = nsampnum % fpsnum; samples = new short[nsamp * channels]; s.GetSamples(samples); samplesprovided = (int)nsamp; w.AddFrame(v); w.AddSamples(samples); }
public Game( IRenderWindow renderWindow, IMapRenderer mapRenderer, IGameState gameState, IMouseInfoProvider mouseInfoProvider, IItemManager itemManager, ISessionManager sessionManager, ISoundProvider soundProvider, IMPQProvider mpqProvider, IGameHUD gameHUD ) { this.renderWindow = renderWindow; this._mapRenderer = mapRenderer; this.gameState = gameState; this.mouseInfoProvider = mouseInfoProvider; this.sessionManager = sessionManager; this.gameHUD = gameHUD; //var item = itemManager.getItem("hdm"); }
/// <summary> /// /// </summary> /// <param name="quality">0 to 10</param> /// <param name="rationum">numerator of srate change ratio (inrate / outrate)</param> /// <param name="ratioden">demonenator of srate change ratio (inrate / outrate)</param> /// <param name="sratein">sampling rate in, rounded to nearest hz</param> /// <param name="srateout">sampling rate out, rounded to nearest hz</param> /// <param name="drainer">function which accepts output as produced. if null, act as an ISyncSoundProvider</param> /// <param name="input">source to take input from when output is requested. if null, no autofetching</param> public SpeexResampler(int quality, uint rationum, uint ratioden, uint sratein, uint srateout, Action <short[], int> drainer = null, ISoundProvider input = null) { if (drainer != null && input != null) { throw new ArgumentException("Can't autofetch without being an ISyncSoundProvider?"); } LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS; st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err); if (st == IntPtr.Zero) { throw new Exception("LibSpeexDSP returned null!"); } CheckError(err); this.drainer = drainer ?? InternalDrain; this.input = input; outbuf = new short[inbuf.Length * ratioden / rationum / 2 * 2 + 128]; }
/// <summary> /// Initializes a new instance of the <see cref="SpeexResampler"/> class /// </summary> /// <param name="quality">0 to 10</param> /// <param name="rationum">numerator of sample rate change ratio (inrate / outrate)</param> /// <param name="ratioden">denominator of sample rate change ratio (inrate / outrate)</param> /// <param name="sratein">sampling rate in, rounded to nearest hz</param> /// <param name="srateout">sampling rate out, rounded to nearest hz</param> /// <param name="drainer">function which accepts output as produced. if null, act as an <seealso cref="ISoundProvider"/></param> /// <param name="input">source to take input from when output is requested. if null, no auto-fetching</param> public SpeexResampler(Quality quality, uint rationum, uint ratioden, uint sratein, uint srateout, Action <short[], int> drainer = null, ISoundProvider input = null) { if (drainer != null && input != null) { throw new ArgumentException($"Can't autofetch without being an {nameof(ISoundProvider)}?"); } LibSpeexDSP.RESAMPLER_ERR err = LibSpeexDSP.RESAMPLER_ERR.SUCCESS; _st = LibSpeexDSP.speex_resampler_init_frac(2, rationum, ratioden, sratein, srateout, quality, ref err); if (_st == IntPtr.Zero) { throw new Exception($"{nameof(LibSpeexDSP)} returned null!"); } CheckError(err); _drainer = drainer ?? InternalDrain; _input = input; _outbuf = new short[(_inbuf.Length * ratioden / rationum / 2 * 2) + 128]; }
public void Load(ISceneProvider draw, IEventProvider events, INetworkProvider network, ISoundProvider sound, IModuleProvider modules, IMovementProvider movement, ICollisionProvider collision, IVoiceChatProvider voicechat, IWorldManager world, ITextureManager texture, ISoundManager soundmanager) { this.drawprovider = draw; this.eventprovider = events; this.networkprovider = network; this.soundprovider = sound; this.moduleprovider = modules; this.movementprovider = movement; this.collisionprovider = collision; this.voicechatprovider = voicechat; this.texturemanager = texture; this.worldmanager = world; this.soundmanager = soundmanager; this.LoadContexts (drawprovider, eventprovider, networkprovider, soundprovider, moduleprovider, movementprovider, collisionprovider, voicechatprovider, texturemanager, worldmanager, soundmanager); }
public SelectHeroClass( IRenderWindow renderWindow, IMouseInfoProvider mouseInfoProvider, ISceneManager sceneManager, ISoundProvider soundProvider, Func <eButtonType, IButton> createButton, Func <ITextBox> createTextBox, ITextDictionary textDictionary, IKeyboardInfoProvider keyboardInfoProvider, IMPQProvider mpqProvider, IGameState gameState ) { this.renderWindow = renderWindow; this.mouseInfoProvider = mouseInfoProvider; this.sceneManager = sceneManager; this.textDictionary = textDictionary; this.keyboardInfoProvider = keyboardInfoProvider; this.soundProvider = soundProvider; this.gameState = gameState; sfxDictionary = new Dictionary <string, byte[]>(); backgroundSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBackground, Palettes.Fechar); campfireSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectCampfire, Palettes.Fechar, new Point(380, 335)); campfireSprite.Blend = true; heroRenderInfo[eHero.Barbarian] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianUnselected, Palettes.Fechar, new Point(400, 330)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianUnselectedH, Palettes.Fechar, new Point(400, 330)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianForwardWalk, Palettes.Fechar, new Point(400, 330)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianForwardWalkOverlay, Palettes.Fechar, new Point(400, 330)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianSelected, Palettes.Fechar, new Point(400, 330)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectBarbarianBackWalk, Palettes.Fechar, new Point(400, 330)), SelectionBounds = new Rectangle(364, 201, 90, 170), ForwardWalkTimeMs = 2500, BackWalkTimeMs = 1000 }; heroRenderInfo[eHero.Sorceress] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressUnselected, Palettes.Fechar, new Point(626, 352)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressUnselectedH, Palettes.Fechar, new Point(626, 352)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressForwardWalk, Palettes.Fechar, new Point(626, 352)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressForwardWalkOverlay, Palettes.Fechar, new Point(626, 352)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressSelected, Palettes.Fechar, new Point(626, 352)), SelectedSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressSelectedOverlay, Palettes.Fechar, new Point(626, 352)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressBackWalk, Palettes.Fechar, new Point(626, 352)), BackWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecSorceressBackWalkOverlay, Palettes.Fechar, new Point(626, 352)), SelectionBounds = new Rectangle(580, 240, 65, 160), ForwardWalkTimeMs = 2300, BackWalkTimeMs = 1200 }; heroRenderInfo[eHero.Sorceress].SelectedSpriteOverlay.Blend = true; heroRenderInfo[eHero.Sorceress].ForwardWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Sorceress].BackWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectNecromancerUnselected, Palettes.Fechar, new Point(300, 335)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectNecromancerUnselectedH, Palettes.Fechar, new Point(300, 335)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerForwardWalk, Palettes.Fechar, new Point(300, 335)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerForwardWalkOverlay, Palettes.Fechar, new Point(300, 335)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerSelected, Palettes.Fechar, new Point(300, 335)), SelectedSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerSelectedOverlay, Palettes.Fechar, new Point(300, 335)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerBackWalk, Palettes.Fechar, new Point(300, 335)), BackWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecNecromancerBackWalkOverlay, Palettes.Fechar, new Point(300, 335)), SelectionBounds = new Rectangle(265, 220, 55, 175), ForwardWalkTimeMs = 2000, BackWalkTimeMs = 1500, }; heroRenderInfo[eHero.Necromancer].ForwardWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer].BackWalkSpriteOverlay.Blend = true; heroRenderInfo[eHero.Necromancer].SelectedSpriteOverlay.Blend = true; heroRenderInfo[eHero.Paladin] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectPaladinUnselected, Palettes.Fechar, new Point(521, 338)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectPaladinUnselectedH, Palettes.Fechar, new Point(521, 338)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinForwardWalk, Palettes.Fechar, new Point(521, 338)), ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinForwardWalkOverlay, Palettes.Fechar, new Point(521, 338)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinSelected, Palettes.Fechar, new Point(521, 338)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecPaladinBackWalk, Palettes.Fechar, new Point(521, 338)), SelectionBounds = new Rectangle(490, 210, 65, 180), ForwardWalkTimeMs = 3400, BackWalkTimeMs = 1300 }; heroRenderInfo[eHero.Amazon] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAmazonUnselected, Palettes.Fechar, new Point(100, 339)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAmazonUnselectedH, Palettes.Fechar, new Point(100, 339)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonForwardWalk, Palettes.Fechar, new Point(100, 339)), //ForwardWalkSpriteOverlay = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonForwardWalkOverlay, Palettes.Fechar, new Point(100, 339)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonSelected, Palettes.Fechar, new Point(100, 339)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelecAmazonBackWalk, Palettes.Fechar, new Point(100, 339)), SelectionBounds = new Rectangle(70, 220, 55, 200), ForwardWalkTimeMs = 2200, BackWalkTimeMs = 1500 }; heroRenderInfo[eHero.Assassin] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinUnselected, Palettes.Fechar, new Point(231, 365)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinUnselectedH, Palettes.Fechar, new Point(231, 365)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinForwardWalk, Palettes.Fechar, new Point(231, 365)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinSelected, Palettes.Fechar, new Point(231, 365)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectAssassinBackWalk, Palettes.Fechar, new Point(231, 365)), SelectionBounds = new Rectangle(175, 235, 50, 180), ForwardWalkTimeMs = 3800, BackWalkTimeMs = 1500 }; heroRenderInfo[eHero.Druid] = new HeroRenderInfo { Stance = eHeroStance.Idle, IdleSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidUnselected, Palettes.Fechar, new Point(720, 370)), IdleSelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidUnselectedH, Palettes.Fechar, new Point(720, 370)), ForwardWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidForwardWalk, Palettes.Fechar, new Point(720, 370)), SelectedSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidSelected, Palettes.Fechar, new Point(720, 370)), BackWalkSprite = renderWindow.LoadSprite(ResourcePaths.CharacterSelectDruidBackWalk, Palettes.Fechar, new Point(720, 370)), SelectionBounds = new Rectangle(680, 220, 70, 195), ForwardWalkTimeMs = 4800, BackWalkTimeMs = 1500 }; headingFont = renderWindow.LoadFont(ResourcePaths.Font30, Palettes.Units); heroDescFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Units); uiFont = renderWindow.LoadFont(ResourcePaths.Font16, Palettes.Units); headingLabel = renderWindow.CreateLabel(headingFont); headingLabel.Text = textDictionary.Translate("strSelectHeroClass"); headingLabel.Location = new Point(400 - (headingLabel.TextArea.Width / 2), 17); heroClassLabel = renderWindow.CreateLabel(headingFont); heroClassLabel.Text = ""; heroClassLabel.Location = new Point(400 - (heroClassLabel.TextArea.Width / 2), 65); heroDesc1Label = renderWindow.CreateLabel(heroDescFont); heroDesc2Label = renderWindow.CreateLabel(heroDescFont); heroDesc3Label = renderWindow.CreateLabel(heroDescFont); characterNameLabel = renderWindow.CreateLabel(uiFont); characterNameLabel.Text = textDictionary.Translate("strCharacterName"); characterNameLabel.Location = new Point(320, 475); characterNameLabel.TextColor = Color.FromArgb(216, 196, 128); exitButton = createButton(eButtonType.Medium); exitButton.Text = textDictionary.Translate("strExit"); exitButton.Location = new Point(33, 540); exitButton.OnActivate = OnExitClicked; okButton = createButton(eButtonType.Medium); okButton.Text = textDictionary.Translate("strOk"); okButton.Location = new Point(630, 540); okButton.OnActivate = OnOkclicked; okButton.Enabled = false; characterNameTextBox = createTextBox(); characterNameTextBox.Text = ""; characterNameTextBox.Location = new Point(320, 493); Parallel.ForEach(new[] { ResourcePaths.SFXAmazonSelect, ResourcePaths.SFXAssassinSelect, ResourcePaths.SFXBarbarianSelect, ResourcePaths.SFXDruidSelect, ResourcePaths.SFXNecromancerSelect, ResourcePaths.SFXPaladinSelect, ResourcePaths.SFXSorceressSelect, ResourcePaths.SFXAmazonDeselect, ResourcePaths.SFXAssassinDeselect, ResourcePaths.SFXBarbarianDeselect, ResourcePaths.SFXDruidDeselect, ResourcePaths.SFXNecromancerDeselect, ResourcePaths.SFXPaladinDeselect, ResourcePaths.SFXSorceressDeselect }, (path => sfxDictionary.Add(path, mpqProvider.GetBytes(path)))); }
public DualSyncSound(ISoundProvider left, ISoundProvider right) { _left = left; _right = right; }
/// <summary> /// Disposes the current provider and resets the provider to a no op provider /// </summary> public static void Dispose() { Provider.Dispose(); Provider = new NoOpSoundProvider(); }
public static void Play(this string @string, ISoundProvider sound, uint duration) { foreach (var n in from n in @string select (Notes)Enum.Parse(typeof(Notes), n.ToString())) sound.PlaySound(Pitch.GetFrequencyFor(n), duration); }
public static DCFilter AsISoundProvider(ISoundProvider input, int filterwidth) { if (input == null) throw new ArgumentNullException(); return new DCFilter(input, null, filterwidth); }
public void PullSamples(ISoundProvider source) { Array.Clear(pullBuffer, 0, 1470); source.GetSamples(pullBuffer); buffer.enqueue_samples(pullBuffer, 735); }
public Instrument(ISoundProvider sound) { _sound = sound; }
public MetaspuAsync(ISoundProvider input, ESynchMethod method) { input.SetSyncMode(SyncSoundMode.Sync); _buffer = Metaspu.metaspu_construct(method); _input = input; }
public void SetSyncInputPin(ISyncSoundProvider source) { syncsoundProvider = source; asyncsoundProvider = null; semisync.DiscardSamples(); }
/// <summary> /// start AV recording /// </summary> private void _RecordAv(string videowritername, string filename, bool unattended) { if (_currAviWriter != null) { return; } // select IVideoWriter to use IVideoWriter aw = null; if (unattended) { aw = VideoWriterInventory.GetVideoWriter(videowritername); } else { aw = VideoWriterChooserForm.DoVideoWriterChoserDlg(VideoWriterInventory.GetAllWriters(), this, out _avwriterResizew, out _avwriterResizeh, out _avwriterpad, out _dumpaudiosync); } if (aw == null) { GlobalWin.OSD.AddMessage( unattended ? string.Format("Couldn't start video writer \"{0}\"", videowritername) : "A/V capture canceled."); return; } try { if (_dumpaudiosync) { aw = new VideoStretcher(aw); } else { aw = new AudioStretcher(aw); } aw.SetMovieParameters(Global.Emulator.CoreComm.VsyncNum, Global.Emulator.CoreComm.VsyncDen); if (_avwriterResizew > 0 && _avwriterResizeh > 0) { aw.SetVideoParameters(_avwriterResizew, _avwriterResizeh); } else { aw.SetVideoParameters(Global.Emulator.VideoProvider().BufferWidth, Global.Emulator.VideoProvider().BufferHeight); } aw.SetAudioParameters(44100, 2, 16); // select codec token // do this before save dialog because ffmpeg won't know what extension it wants until it's been configured if (unattended) { aw.SetDefaultVideoCodecToken(); } else { var token = aw.AcquireVideoCodecToken(this); if (token == null) { GlobalWin.OSD.AddMessage("A/V capture canceled."); aw.Dispose(); return; } aw.SetVideoCodecToken(token); } // select file to save to if (unattended) { aw.OpenFile(filename); } else { string ext = aw.DesiredExtension(); string pathForOpenFile; //handle directories first if (ext == "<directory>") { var fbd = new FolderBrowserEx(); if (fbd.ShowDialog() == DialogResult.Cancel) { aw.Dispose(); return; } pathForOpenFile = fbd.SelectedPath; } else { var sfd = new SaveFileDialog(); if (Global.Game != null) { sfd.FileName = PathManager.FilesystemSafeName(Global.Game) + "." + ext; //dont use Path.ChangeExtension, it might wreck game names with dots in them sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null); } else { sfd.FileName = "NULL"; sfd.InitialDirectory = PathManager.MakeAbsolutePath(Global.Config.PathEntries.AvPathFragment, null); } sfd.Filter = string.Format("{0} (*.{0})|*.{0}|All Files|*.*", ext); var result = sfd.ShowHawkDialog(); if (result == DialogResult.Cancel) { aw.Dispose(); return; } pathForOpenFile = sfd.FileName; } aw.OpenFile(pathForOpenFile); } // commit the avi writing last, in case there were any errors earlier _currAviWriter = aw; GlobalWin.OSD.AddMessage("A/V capture started"); AVIStatusLabel.Image = Properties.Resources.AVI; AVIStatusLabel.ToolTipText = "A/V capture in progress"; AVIStatusLabel.Visible = true; } catch { GlobalWin.OSD.AddMessage("A/V capture failed!"); aw.Dispose(); throw; } if (_dumpaudiosync) { Global.Emulator.EndAsyncSound(); } else { _aviSoundInput = !Global.Emulator.StartAsyncSound() ? new MetaspuAsync(Global.Emulator.SyncSoundProvider, ESynchMethod.ESynchMethod_V) : Global.Emulator.SoundProvider; } _dumpProxy = new MetaspuSoundProvider(ESynchMethod.ESynchMethod_V); RewireSound(); }
public void DisableSource(ISoundProvider source) { SoundProviders.Remove(source); }
private void StopAv() { if (_currAviWriter == null) { _dumpProxy = null; RewireSound(); return; } _currAviWriter.CloseFile(); _currAviWriter.Dispose(); _currAviWriter = null; GlobalWin.OSD.AddMessage("A/V capture stopped"); AVIStatusLabel.Image = Properties.Resources.Blank; AVIStatusLabel.ToolTipText = string.Empty; AVIStatusLabel.Visible = false; _aviSoundInput = null; _dumpProxy = null; // return to normal sound output RewireSound(); }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="spf">number of sample pairs to request and provide on each GetSamples() call</param> public FakeSyncSound(ISoundProvider source, int spf) { this.source = source; this.spf = spf; }
/// <summary> /// Adds an ISoundProvider to the SyncSoundMixer /// </summary> /// <param name="source">The source ISoundProvider</param> /// <param name="sourceDescription">An ident string for the ISoundProvider (useful when debugging)</param> /// <param name="isMono">If this is true then only half the samples should be present</param> public void PinSource(ISoundProvider source, string sourceDescription) { PinSource(source, sourceDescription, FinalMaxVolume); }
public void AddSource(ISoundProvider source) { SoundProviders.Add(source); }
public void SetAsyncInputPin(ISoundProvider source) { syncsoundProvider = null; asyncsoundProvider = source; semisync.BaseSoundProvider = source; semisync.RecalculateMagic(Global.CoreComm.VsyncRate); }
public SoundPlayerImpl(ISoundProvider <string> provider, SoundPlayerConfig config = null) : base(provider, config) { }
public SoundService() { _soundProvider = DependencyService.Get<ISoundProvider> (); }