private void InitModel() { BassPlayerSettings settings = Controller.GetSettings(); DirectSoundBuffer directSoundBuffer = new DirectSoundBuffer(); directSoundBuffer.Load(); _directSoundBufferSizeController = new NumberSelectController(); _directSoundBufferSizeController.Initialize(directSoundBuffer); PlaybackBufferSize wasapiBuffer = new PlaybackBufferSize(); wasapiBuffer.Load(); _wasapiBufferSizeController = new NumberSelectController(); _wasapiBufferSizeController.Initialize(wasapiBuffer); DirectSoundBufferSize = settings.DirectSoundBufferSizeMilliSecs; WasapiBufferSize = settings.PlaybackBufferSizeMilliSecs; }
public DirectSoundAudioPlayer(AudioFormat format, TimeSpan bufferLength) : base(format) { IntPtr hwnd; using (var p = Process.GetCurrentProcess()) { hwnd = p.MainWindowHandle; } if (hwnd == IntPtr.Zero) { hwnd = NativeMethods.GetConsoleWindow(); } this.dataInterval = (uint)(bufferLength.TotalMilliseconds * 0.4); var dsound = DirectSoundObject.GetInstance(hwnd); this.directSoundBuffer = dsound.CreateBuffer(format, bufferLength); }