Thomas

Thomas

  • NA
  • 7
  • 0

directSound problems (beginners question)

Nov 20 2009 11:48 AM
Hi

I'm trying to make use of directsound in a .Net project. I haven't much experience with c# so bare over with me.

I have borrowed some code found on the net that I'm trying to merge into my own little project to get a soft start. I'm already failing to initialize the directsound device. Here is what I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

using Microsoft.DirectX.DirectSound;
using DS = Microsoft.DirectX.DirectSound;

namespace AudioProcessor
{

    public class SoundSetup
    {
        private DS.Device sounddevice;
        private SecondaryBuffer shotsound;
   
        public void InitDxSound()
        {
            sounddevice = new DS.Device();
            sounddevice.SetCooperativeLevel(this, CooperativeLevel.Priority);

        }
     }
   
    static class Program
    {
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
           
        }
    }
}


 I get the following errors:

Error    1    The best overloaded method match for 'Microsoft.DirectX.DirectSound.Device.SetCooperativeLevel(System.IntPtr, Microsoft.DirectX.DirectSound.CooperativeLevel)' has some invalid arguments   
Error    2    Argument '1': cannot convert from 'AudioProcessor.SoundSetup' to 'System.IntPtr'   

Can someone please tell me how to resolve this (I suspect that this has to do with the use of "this")?

Best Regards
Thomas

Answers (4)