From GuitarBabe at earthlink.net Thu May 3 02:06:18 2007 From: GuitarBabe at earthlink.net (Guitar Babe) Date: Wed, 02 May 2007 18:06:18 -0700 Subject: [AGDev-newbies] Another C# / DX question Message-ID: <5.2.1.1.0.20070502180548.00df4d78@pop.earthlink.net> Hi All, while I've gotten 3D sound to work for me just fine when placing its code in a method within my Form1 class, I've placed it in it's own class / namespace and now cannot compile it. I'll post the code from the Form1 class the DXMisc.DXSound namespace and class, (my new namespace and class) along with the error list I'm getting. Now I believe I understand why I'm getting the first three errors, which have to do with the "this" reference though I've tried changing it and simply get one less error, with the new references not being liked either. However, I'm not sure why the last four errors are happening. I've added the DXMisc namespace into the proper using statement and have included the new code into my project as a CS file. I'm wondering if it's still not being seen as a reference?... Anyway, any help or suggestions would be appreciated. Again, this code all works just fine if I place it within the same namespace within the Form1 class, so I'm curious for your thoughts?... Thanks so very much and catch ya on the flip!... Smiles, Cara *** Form1.cs *** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DXMisc; namespace CQ_Sound_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); DXSound.InitDXSound(); DXSound.InitPrimaryBuffer(); DXSound.InitListener(); DXSound.InitSecondary3DBuffer(); } } } *** CQDX.cs *** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.DirectSound; namespace DXMisc { public class DXSound { public Device dsDevice; public Microsoft.DirectX.DirectSound.Buffer Buff; public Listener3D Person; public SecondaryBuffer secBuff; public Buffer3D Sound3D; public void InitDXSound() { try { dsDevice = new Device(); dsDevice.SetCooperativeLevel(this, CooperativeLevel.Priority); } catch { MessageBox.Show("Could not initialize DirectSound device, exiting...", "Exiting...", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); throw; } } public void InitPrimaryBuffer() { try { BufferDescription dp = new BufferDescription(); dp.PrimaryBuffer = true; dp.Control3D = true; Buff = new Microsoft.DirectX.DirectSound.Buffer(dp, dsDevice); } catch { MessageBox.Show("Failed to create Primary buffer"); } } public void InitListener() { try { Person = new Listener3D(Buff); Listener3DOrientation o = new Listener3DOrientation(); o.Front = new Vector3(0, 0, 1); o.Top = new Vector3(0, 1, 0); Person.Orientation = o; Person.Position = new Vector3(0, 0, 0); } catch { MessageBox.Show("Failed to create listener"); } } public void InitSecondary3DBuffer() { try { BufferDescription desc = new BufferDescription(); // desc.ControlPan = true; // desc.ControlVolume =true; // desc.ControlFrequency = true; desc.Control3D = true; desc.Guid3DAlgorithm = DSoundHelper.Guid3DAlgorithmHrtfFull; secBuff = new SecondaryBuffer("blah.wav", desc, dsDevice); Sound3D = new Buffer3D(secBuff); Sound3D.Mode = Mode3D.HeadRelative; } catch { MessageBox.Show("Failed to create secondary buffer"); } } public void PlaySound() { secBuff.Play(0, BufferPlayFlags.Default); } public void PlaceSound(Vector3 SoundPos) { Sound3D.Position = SoundPos; } public void PlaceListener(Vector3 ListenerPos) { Person.Position = ListenerPos; } // end of class } } *** Error List *** Error 1 The best overloaded method match for 'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.IntPtr, Microsoft.DirectX.DirectSound.CooperativeLevel)' has some invalid arguments C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\CQ DX stuff.cs 27 1 CQ Sound 2 Error 2 Argument '1': cannot convert from 'DXMisc.DXSound' to 'System.IntPtr' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\CQ DX stuff.cs 27 30 CQ Sound 2 Error 3 'DXMisc.DXSound' does not contain a definition for 'Close' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\CQ DX stuff.cs 34 6 CQ Sound 2 Error 4 An object reference is required for the nonstatic field, method, or property 'DXMisc.DXSound.InitDXSound()' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\Form1.cs 18 1 CQ Sound 2 Error 5 An object reference is required for the nonstatic field, method, or property 'DXMisc.DXSound.InitPrimaryBuffer()' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\Form1.cs 19 1 CQ Sound 2 Error 6 An object reference is required for the nonstatic field, method, or property 'DXMisc.DXSound.InitListener()' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\Form1.cs 20 1 CQ Sound 2 Error 7 An object reference is required for the nonstatic field, method, or property 'DXMisc.DXSound.InitSecondary3DBuffer()' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\Form1.cs 21 1 CQ Sound 2 -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.6.2/781 - Release Date: 4/30/2007 9:14 AM From GuitarBabe at earthlink.net Fri May 4 02:48:48 2007 From: GuitarBabe at earthlink.net (Guitar Babe) Date: Thu, 03 May 2007 18:48:48 -0700 Subject: [AGDev-newbies] My C# question revisited... Message-ID: <5.2.1.1.0.20070503184815.00dc13e0@pop.earthlink.net> Hi All, below is my revised code and error list with only one error this time. However, I would love some feedback if anyone has any, concerning this. The error has to do with the close() method for the MessageBox. I'm passing a window handle to it that it doesn't like, but I really don't know any other way to represent the form that's calling the function. I understand that there needs to be a proper handle for this to work, but everything I've tried thus far fails in various ways. What I really don't get, is the fact that even though I'm passing the proper form name to the method, it fails from it's present location, but if I place the actual code for the MessageBox and it's close method within the Form1 class, it works. As I said, even though I'm still sending the Form1 handle to it... am I making sense? Anyway, here's the code, and thanks in advance for any help anyone can offer... Smiles, Cara *** error list *** Error 1 'System.Windows.Forms.Control' does not contain a definition for 'Close' C:\Documents and Settings\cARA\My Documents\Visual Studio 2005\Projects\CQ Sound 2\CQ Sound 2\CQ DX stuff.cs 34 6 CQ Sound 2 *** end of error list *** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using Microsoft.DirectX; using Microsoft.DirectX.DirectSound; namespace DXMisc { public class DXSound { public Device dsDevice; public Microsoft.DirectX.DirectSound.Buffer Buff; public Listener3D Person; public SecondaryBuffer secBuff; public Buffer3D Sound3D; public void InitDXSound(Control This) { try { dsDevice = new Device(); dsDevice.SetCooperativeLevel(This, CooperativeLevel.Priority); } catch { MessageBox.Show("Could not initialize DirectSound device, exiting...", "Exiting...", MessageBoxButtons.OK, MessageBoxIcon.Error); This.Close(); throw; } } public void InitPrimaryBuffer() { try { BufferDescription dp = new BufferDescription(); dp.PrimaryBuffer = true; dp.Control3D = true; Buff = new Microsoft.DirectX.DirectSound.Buffer(dp, dsDevice); } catch { MessageBox.Show("Failed to create Primary buffer"); } } public void InitListener() { try { Person = new Listener3D(Buff); Listener3DOrientation o = new Listener3DOrientation(); o.Front = new Vector3(0, 0, 1); o.Top = new Vector3(0, 1, 0); Person.Orientation = o; Person.Position = new Vector3(0, 0, 0); } catch { MessageBox.Show("Failed to create listener"); } } public void InitSecondary3DBuffer() { try { BufferDescription desc = new BufferDescription(); // desc.ControlPan = true; // desc.ControlVolume =true; // desc.ControlFrequency = true; desc.Control3D = true; desc.Guid3DAlgorithm = DSoundHelper.Guid3DAlgorithmHrtfFull; secBuff = new SecondaryBuffer("blah.wav", desc, dsDevice); Sound3D = new Buffer3D(secBuff); Sound3D.Mode = Mode3D.HeadRelative; } catch { MessageBox.Show("Failed to create secondary buffer"); } } public void PlaySound() { secBuff.Play(0, BufferPlayFlags.Default); } public void PlaceSound(Vector3 SoundPos) { Sound3D.Position = SoundPos; } public void PlaceListener(Vector3 ListenerPos) { Person.Position = ListenerPos; } // end of class } } *** Form1.cs *** using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using DXMisc; namespace CQ_Sound_2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); DXSound DSound = new DXSound(); DSound.InitDXSound(this); DSound.InitPrimaryBuffer(); DSound.InitListener(); DSound.InitSecondary3DBuffer(); } } } -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.6.2/781 - Release Date: 4/30/2007 9:14 AM From tward1978 at earthlink.net Tue May 8 22:16:33 2007 From: tward1978 at earthlink.net (Thomas Ward) Date: Tue, 08 May 2007 17:16:33 -0400 Subject: [AGDev-newbies] Another C# / DX question In-Reply-To: <5.2.1.1.0.20070502180548.00df4d78@pop.earthlink.net> References: <5.2.1.1.0.20070502180548.00df4d78@pop.earthlink.net> Message-ID: <4640E8B1.3030502@earthlink.net> Hi Cara, I think I will be able to solve your issues, but unfortunately right now I am in the middle of a move, and my desktop computer I usually use bit the dust. So I probably won't be able to get to your questions until sometime after June 1 when my wife and I move in to our new place and get settled. right now I am stuck on my laptop for email when and where I can check in to the lists and get back off the net. Cheers. From GuitarBabe at earthlink.net Wed May 9 03:09:57 2007 From: GuitarBabe at earthlink.net (Guitar Babe) Date: Tue, 08 May 2007 19:09:57 -0700 Subject: [AGDev-newbies] Another C# / DX question In-Reply-To: <4640E8B1.3030502@earthlink.net> References: <5.2.1.1.0.20070502180548.00df4d78@pop.earthlink.net> <5.2.1.1.0.20070502180548.00df4d78@pop.earthlink.net> Message-ID: <5.2.1.1.0.20070508190702.00dd5e18@pop.earthlink.net> Hey Tom, not a problem! I actually have most of this solved already, and am working on the last lil bit here. Thank you anyway, and I wish you and yours the most relaxing move experience possible! All of my best to you both! Talk with you soon!... Smiles, Cara At 05:16 PM 5/8/2007 -0400, you wrote: >Hi Cara, >I think I will be able to solve your issues, but unfortunately right now I >am in the middle of a move, and my desktop computer I usually use bit the dust. >So I probably won't be able to get to your questions until sometime after >June 1 when my wife and I move in to our new place and get settled. right >now I am stuck on my laptop for email when and where I can check in to the >lists and get back off the net. >Cheers. > > > >_______________________________________________ >AGDev-newbies mailing list >AGDev-newbies at lists.agdev.org >http://lists.agdev.org/cgi-bin/mailman/listinfo/agdev-newbies > > > >-- >No virus found in this incoming message. >Checked by AVG Free Edition. >Version: 7.5.446 / Virus Database: 269.6.5/793 - Release Date: 5/7/2007 >2:55 PM -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.446 / Virus Database: 269.6.5/793 - Release Date: 5/7/2007 2:55 PM