public override void Create(Component component) { var player = (PlayerComponent)component; var cam = new GameCamera(player.Owner.Layer, ScreenController.MainCamera); cam.Target = player.Owner.GetComponent <PositionComponent>(); player.Listener = Listener3D.Create(); player.Listener.ForwardOrientation = -player.Listener.ForwardOrientation; }
public MdxListener(Device device) { BufferDescription desc = new BufferDescription(); desc.PrimaryBuffer = true; desc.Control3D = true; desc.Mute3DAtMaximumDistance = true; Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(desc, device); _listener = new Listener3D(buffer); Orientation = Matrix.Identity; }
public MdxListener(Device device) { BufferDescription desc = new BufferDescription(); desc.PrimaryBuffer = true; desc.Control3D = true; desc.Mute3DAtMaximumDistance = true; Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(desc, device); _listener = new Listener3D(buffer); Orientation = Matrix.Identity; }
public Listener() { // Create the listener BufferDescription desc = new BufferDescription(); desc.PrimaryBuffer = true; desc.Control3D = true; listener = new Listener3D( new Microsoft.DirectX.DirectSound.Buffer(desc, SoundManager.Device)); // Set the listener orientation orientation = new Listener3DOrientation(); orientation.Front = new Vector3(0, 0, 1); orientation.Top = new Vector3(0, 1, 0); listener.Orientation = orientation; }
public TgcDirectSound() { //Crear device de DirectSound dsDevice = new Device(); dsDevice.SetCooperativeLevel(GuiController.Instance.MainForm, CooperativeLevel.Normal); //Crear Listener3D BufferDescription primaryBufferDesc = new BufferDescription(); primaryBufferDesc.Control3D = true; primaryBufferDesc.PrimaryBuffer = true; primaryBuffer = new Microsoft.DirectX.DirectSound.Buffer(primaryBufferDesc, dsDevice); listener3d = new Listener3D(primaryBuffer); listener3d.Position = new Vector3(0f, 0f, 0f); listener3d.Orientation = new Listener3DOrientation(new Vector3(1, 0, 0), new Vector3(0, 1, 0)); }
public void InitializeD3DDevice(Control control) { //Crear device de DirectSound DsDevice = new Device(); DsDevice.SetCooperativeLevel(control, CooperativeLevel.Normal); //Crear Listener3D var primaryBufferDesc = new BufferDescription(); primaryBufferDesc.Control3D = true; primaryBufferDesc.PrimaryBuffer = true; primaryBuffer = new Buffer(primaryBufferDesc, DsDevice); Listener3d = new Listener3D(primaryBuffer); Listener3d.Position = new Vector3(0f, 0f, 0f); Listener3d.Orientation = new Listener3DOrientation(new Vector3(1, 0, 0), new Vector3(0, 1, 0)); }
public TgcDirectSound() { //Crear device de DirectSound dsDevice = new Device(); dsDevice.SetCooperativeLevel(GuiController.Instance.MainForm, CooperativeLevel.Normal); //Crear Listener3D BufferDescription primaryBufferDesc = new BufferDescription(); primaryBufferDesc.Control3D = true; primaryBufferDesc.PrimaryBuffer = true; primaryBuffer = new Microsoft.DirectX.DirectSound.Buffer(primaryBufferDesc, dsDevice); listener3d = new Listener3D(primaryBuffer); listener3d.Position = new Vector3(0f, 0f, 0f); listener3d.Orientation = new Listener3DOrientation(new Vector3(1, 0, 0), new Vector3(0, 1, 0)); }
/// <summary> /// Sets up an instance of DirectSound9Driver and sets ups /// DirectSound so its render for audio playback. /// </summary> private void InitializeDevice() { // Setup the DirectSound device _dx9Device = new Device(); if (GraphicsManager.RenderTarget as GraphicsCanvas != null) { _dx9Device.SetCooperativeLevel(((GraphicsCanvas)GraphicsManager.RenderTarget).RenderControl, CooperativeLevel.Priority); } // Create our 3D sound listener. BufferDescription bufferDescription = new BufferDescription(); bufferDescription.PrimaryBuffer = true; bufferDescription.Control3D = true; // Get the primary buffer Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(bufferDescription, _dx9Device); // Attach the listener to the primary buffer _listener3D = new Listener3D(buffer); _listener3D.DistanceFactor = 0.03f; //_listener3D.DopplerFactor = 0.1f; //_listener3D.RolloffFactor = 0.1f; }
public override void SetRenderWindow(RenderWindow renderwindow, Camera camera) { base.SetRenderWindow(renderwindow, camera); // link the device to our current System.Windows.Form (since we need DirectX we're sure that we're in Windows) device.SetCooperativeLevel((System.Windows.Forms.Control)window.Handle, CooperativeLevel.Priority); // create a buffer for the listener BufferDescription desc = new BufferDescription(); desc.Control3D = true; desc.PrimaryBuffer = true; Buffer lbuffer = new Buffer(desc, device); listener = new Listener3D(lbuffer); // let the log know that we're using DirectSound and it's set up LogManager.Instance.Write("DirectSound SoundSystem initialised"); }
public Play3DSound() { try { // Load the icon from our resources System.Resources.ResourceManager resources = new System.Resources.ResourceManager(this.GetType()); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); } catch { // It's no big deal if we can't load our icons, but try to load the embedded one try { this.Icon = new System.Drawing.Icon(this.GetType(), "directx.ico"); } catch {} } // // Required for Windows Form Designer support // InitializeComponent(); BufferDescription description = new BufferDescription(); WaveFormat fmt = new WaveFormat(); description.PrimaryBuffer = true; description.Control3D = true; Buffer buff = null; fmt.FormatTag = WaveFormatTag.Pcm; fmt.Channels = 2; fmt.SamplesPerSecond = 22050; fmt.BitsPerSample = 16; fmt.BlockAlign = (short)(fmt.BitsPerSample / 8 * fmt.Channels); fmt.AverageBytesPerSecond = fmt.SamplesPerSecond * fmt.BlockAlign; try { applicationDevice = new Device(); applicationDevice.SetCooperativeLevel(this, CooperativeLevel.Priority); } catch { MessageBox.Show("Unable to create sound device. Sample will now exit."); this.Close(); throw; } // Get the primary buffer and set the format. buff = new Buffer(description, applicationDevice); buff.Format = fmt; applicationListener = new Listener3D(buff); listenerParameters = applicationListener.AllParameters; labelFilename.Text = String.Empty; labelStatus.Text = "No file loaded."; string path = Utility.FindMediaFile("grid.jpg"); pictureboxRenderWindow.BackgroundImage = Image.FromFile(path); GridWidth = pictureboxRenderWindow.Width; GridHeight = pictureboxRenderWindow.Height; trackbarDopplerSlider.Maximum = ConvertLogScaleToLinearSliderPos(DSoundHelper.MaxDopplerFactor); trackbarDopplerSlider.Minimum = ConvertLogScaleToLinearSliderPos(DSoundHelper.MinDopplerFactor); trackbarRolloffSlider.Maximum = ConvertLogScaleToLinearSliderPos(DSoundHelper.MaxRolloffFactor); trackbarRolloffSlider.Minimum = ConvertLogScaleToLinearSliderPos(DSoundHelper.MinRolloffFactor); trackbarMindistanceSlider.Maximum = 40; trackbarMindistanceSlider.Minimum = 1; trackbarMaxdistanceSlider.Maximum = 40; trackbarMaxdistanceSlider.Minimum = 1; trackbarVerticalSlider.Maximum = 100; trackbarVerticalSlider.Minimum = -100; trackbarVerticalSlider.Value = 100; trackbarHorizontalSlider.Maximum = 100; trackbarHorizontalSlider.Minimum = -100; trackbarHorizontalSlider.Value = 100; SetSlidersPos(0, 0, maxOrbitRadius, maxOrbitRadius * 20.0f); SliderChanged(); }
/// <summary> /// Sets up an instance of DirectSound9Driver and sets ups /// DirectSound so its render for audio playback. /// </summary> private void InitializeDevice() { // Setup the DirectSound device _dx9Device = new Device(); if (GraphicsManager.RenderTarget as GraphicsCanvas != null) _dx9Device.SetCooperativeLevel(((GraphicsCanvas)GraphicsManager.RenderTarget).RenderControl, CooperativeLevel.Priority); // Create our 3D sound listener. BufferDescription bufferDescription = new BufferDescription(); bufferDescription.PrimaryBuffer = true; bufferDescription.Control3D = true; // Get the primary buffer Microsoft.DirectX.DirectSound.Buffer buffer = new Microsoft.DirectX.DirectSound.Buffer(bufferDescription, _dx9Device); // Attach the listener to the primary buffer _listener3D = new Listener3D(buffer); _listener3D.DistanceFactor = 0.03f; //_listener3D.DopplerFactor = 0.1f; //_listener3D.RolloffFactor = 0.1f; }