public static void Initialize(System.Windows.Forms.Control Parent)
        {
            // Initialize sound
            sounddevice = new DS.Device();
            sounddevice.SetCooperativeLevel(Parent, CooperativeLevel.Normal);

            //BufferDescription description = new BufferDescription();
            description = new BufferDescription();
            description.ControlEffects = false;

            shotsound = new SecondaryBuffer[10];
            //shotsound[0]
            //    = new SecondaryBuffer("turn-left.wav", description, sounddevice);
            //shotsound[1]
            //    = new SecondaryBuffer("turn-left.wav", description, sounddevice);
            shotsound[2]
                = new SecondaryBuffer("turn-left.wav", description, sounddevice);
            shotsound[3]
                = new SecondaryBuffer("turn-right.wav", description, sounddevice);
            shotsound[4]
                = new SecondaryBuffer("horn.wav", description, sounddevice);
            shotsound[5]
                = new SecondaryBuffer("ignition.wav", description, sounddevice);
            shotsound[6]
                = new SecondaryBuffer("police_siren.wav", description, sounddevice);
            shotsound[7]
                = new SecondaryBuffer("ambulance_siren.wav", description, sounddevice);
            //shotsound[8]
            //    = new SecondaryBuffer("ignition.wav", description, sounddevice);
            //shotsound[9]
            //    = new SecondaryBuffer("ignition.wav", description, sounddevice);

            //shotsound = new SecondaryBuffer("horn.wav", description, sounddevice);
            //shotsound.Play(0, BufferPlayFlags.Default);
        }
Esempio n. 2
1
        public Form1()
        {
            InitializeComponent();

            deviceSound = new Microsoft.DirectX.DirectSound.Device();
            deviceSound.SetCooperativeLevel(Handle, CooperativeLevel.Priority);
            Init();
            GetGamePads();

            //the soundwaves class contains methods for synthesizing audio, and playing static audio
            soundWaves = new SoundWaves(deviceSound);
        }
Esempio n. 3
0
 private void init_dx()
 {
     try
     {
         sound_card = new Device();
         sound_card.SetCooperativeLevel(this, CooperativeLevel.Priority);
     }
     catch
     {
         MessageBox.Show("Failed to create a sound card, check your directX version\nTheSoftware will run in compatibility mode. It will NOT sound good as it can only play one sound at a time");
         return;
     }
     try
     {
         description = new BufferDescription();
         description.ControlVolume    = true;
         description.LocateInSoftware = true;
     }
     catch
     {
         MessageBox.Show("Failed to create a sound buffer, check your directX version\nTheSoftware will run in compatibility mode. It will NOT sound good as it can only play one sound at a time");
         sound_card.Dispose();
         sound_card = null;
         return;
     }
 }
Esempio n. 4
0
 public Form1(int lvl)
 {
     //Init DirectSound
     snddev = new DSound.Device();
     snddev.SetCooperativeLevel(Handle, DSound.CooperativeLevel.Priority);
     snd_phit              = new DSound.Buffer(FLD_SND + "hit.wav", snddev);
     level                 = lvl;
     Text                  = TITLE;
     Icon                  = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
     FormBorderStyle       = FormBorderStyle.FixedSingle;
     BackColor             = EGA_PALETTE[(tags + 7) % 13 + 1];
     img_splash            = new Bitmap(FLD_GFX + "main.png");
     img_game              = new Bitmap(FLD_GFX + "game.png");
     img_end               = new Bitmap(FLD_GFX + "end.png");
     BackgroundImage       = new Bitmap(img_splash);
     BackgroundImageLayout = ImageLayout.Zoom;
     gfx = Graphics.FromImage(BackgroundImage);
     gfx.SmoothingMode      = System.Drawing.Drawing2D.SmoothingMode.None;
     gfx.InterpolationMode  = System.Drawing.Drawing2D.InterpolationMode.NearestNeighbor;
     gfx.PixelOffsetMode    = System.Drawing.Drawing2D.PixelOffsetMode.None;
     gfx.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighSpeed;
     ClientSize             = BackgroundImage.Size;
     SetStyle(
         ControlStyles.OptimizedDoubleBuffer |
         ControlStyles.AllPaintingInWmPaint |
         ControlStyles.UserPaint, true);
     rnd   = new Random();
     state = 0;
     CenterToScreen();
 }
Esempio n. 5
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            dxSoundDevice = new Microsoft.DirectX.DirectSound.Device();
            dxSoundDevice.SetCooperativeLevel(this, CooperativeLevel.Priority);

            WaveFormat wf = new WaveFormat();

            wf.FormatTag             = WaveFormatTag.Pcm;
            wf.BitsPerSample         = 8;
            wf.Channels              = 1;
            wf.BlockAlign            = 1;
            wf.SamplesPerSecond      = (int)(dSampleRate);
            wf.AverageBytesPerSecond = wf.SamplesPerSecond * wf.BlockAlign;

            // buffer description
            BufferDescription bd = new BufferDescription(wf);

            bd.DeferLocation = true;
            bd.GlobalFocus   = true; // play this buffer, even if the app looses focus
            bd.ControlPan    = true;
            bd.ControlVolume = true;
            bd.PrimaryBuffer = false;
            bd.BufferBytes   = wave.Length;

            soundBuffer        = new SecondaryBuffer(bd, dxSoundDevice);
            soundBuffer.Volume = tbVolume.Value;
            soundBuffer.Pan    = 0;

            if (chkPlay.Checked)
            {
                m_ambient.Start();
            }
        }
        public Listener(System.Windows.Forms.Form form, Object3D object_listening)
        {
            m_listener = object_listening;
            Sound.BufferDescription description = new Sound.BufferDescription();
            Sound.WaveFormat        fmt         = new Sound.WaveFormat();
            description.PrimaryBuffer = true;
            description.Control3D     = true;
            Sound.Buffer buff = null;

            fmt.FormatTag             = Sound.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;

            applicationDevice.SetCooperativeLevel(form, Sound.CooperativeLevel.Priority);

            // Get the primary buffer and set the format.
            buff        = new Buffer(description, Device);
            buff.Format = fmt;

            applicationListener = new Listener3D(buff);
            listenerParameters  = applicationListener.AllParameters;
        }
Esempio n. 7
0
 /// <summary>
 /// hack to make sure the cooperative level is set after a window is created.
 /// </summary>
 private void CheckCoop()
 {
     if (System.Windows.Forms.Form.ActiveForm != null)
     {
         mDevice.SetCooperativeLevel(System.Windows.Forms.Form.ActiveForm.Handle,
                                     Microsoft.DirectX.DirectSound.CooperativeLevel.Priority);
     }
 }
Esempio n. 8
0
        private void InitAudio()
        {
            DevicesCollection dcollection = new DevicesCollection();
            Guid devguid = dcollection[1].DriverGuid;

            device = new Microsoft.DirectX.DirectSound.Device(devguid);
            device.SetCooperativeLevel(wpfHwnd, CooperativeLevel.Normal);
        }
Esempio n. 9
0
        public void SetInputDeviceForRecording(Control FormHandle, int Index)
        {
            CaptureDevicesCollection devices = new CaptureDevicesCollection();

            Microsoft.DirectX.DirectSound.Device mDevice = new  Microsoft.DirectX.DirectSound.Device(devices[Index].DriverGuid);
            mDevice.SetCooperativeLevel(FormHandle, CooperativeLevel.Priority);
            m_InputDevice = mDevice;
        }
Esempio n. 10
0
 // --------------------------------------------------------------------
 // Initialize the DirectSound subsystem
 // --------------------------------------------------------------------
 public void InitializeSound()
 {
     // set up a device
     _sound = new Device();
     _sound.SetCooperativeLevel(this, CooperativeLevel.Normal);
     _wave = new SecondaryBuffer("..\\..\\air_whoosh.wav", _sound);
     _wave.Play(0, BufferPlayFlags.Looping);
 }
        private void InitializeGraphics()
        {
            try {
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed               = true;
                presentParams.SwapEffect             = SwapEffect.Discard;
                presentParams.BackBufferFormat       = Format.Unknown;
                presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                presentParams.EnableAutoDepthStencil = true;

                // Store the default adapter
                int         adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;
                CreateFlags flags          = CreateFlags.SoftwareVertexProcessing;

                // Check to see if we can use a pure hardware device
                D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);

                // Do we support hardware vertex processing?
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                {
                    // Replace the software vertex processing
                    flags = CreateFlags.HardwareVertexProcessing;
                }

                // Do we support a pure device?
                if (caps.DeviceCaps.SupportsPureDevice)
                {
                    flags |= CreateFlags.PureDevice;
                }

                device              = new D3D.Device(0, D3D.DeviceType.Hardware, this, flags, presentParams);
                device.DeviceReset += new System.EventHandler(this.OnResetDevice);
                OnResetDevice(device, null);

                tileSheet = TextureLoader.FromFile(device, MediaUtilities.FindFile("donuts.bmp"), 1024, 1024,
                                                   1, 0, Format.A8R8G8B8, Pool.Managed, Filter.Point, Filter.Point, (unchecked ((int)0xff000000)));

                tileSet      = new TileSet(tileSheet, 0, 0, 6, 5, 32, 32);
                tilePosition = new Rectangle(tileSet.XOrigin, tileSet.YOrigin, tileSet.ExtentX * 2, tileSet.ExtentY * 2);

                //set up DirectInput keyboard device...
                kbd = new DI.Device(SystemGuid.Keyboard);
                kbd.SetCooperativeLevel(this,
                                        DI.CooperativeLevelFlags.Background | DI.CooperativeLevelFlags.NonExclusive);
                kbd.Acquire();

                //Set up DirectSound device and buffers
                snd = new DS.Device();
                snd.SetCooperativeLevel(this, DS.CooperativeLevel.Normal);
                bounce = new DS.SecondaryBuffer(MediaUtilities.FindFile("bounce.wav"), snd);

                hrt.Start();
            }
            catch (DirectXException) {
                // Catch any errors and return a failure
            }
        }
Esempio n. 12
0
 private void button2_Click(object sender, System.EventArgs e)
 {
     ApplicationDevice = new Microsoft.DirectX.DirectSound.Device();
     ApplicationDevice.SetCooperativeLevel(this, Microsoft.DirectX.DirectSound.CooperativeLevel.Priority);
     //SoundFX_LoadSoundFile(@"Z:\My Documents\My Music - parts\idj 126\breathless (1).MP3");
     //SoundFX_LoadSoundFile(@"Z:\mp3\hummingbird_0.01.02[1]\--autopilot--\hummingbird\root\wavfiles\cold fusion mafia - exteroceptor (edit).wav");
     SoundFX_LoadSoundFile(@"Z:\My Documents\My Programming\Pong\qbytespong.wav");
     SoundFX_PlaySound(true); // play sample (looping enabled)
     timer1.Enabled = true;
     //trackBar2.Value = ApplicationBuffer
 }
Esempio n. 13
0
File: Main.cs Progetto: sjk7/DX90SDK
    private void DlgMainForm_Load(object sender, System.EventArgs e)
    {
        string sdkpath = DXUtil.SdkMediaPath;

        // Get the graphics object for the static groupbox control.
        applicationGraphics = gbStatic.CreateGraphics();
        mappings            = new ActionFormat[1];
        mappings[0]         = new ActionFormat();

        ConstructActionMap();
        // Get the devices on the system that can be mapped to the action map, and are attached.
        applicationDevices = Manager.GetDevices(mappings[0], EnumDevicesBySemanticsFlags.AttachedOnly);

        // Make sure there are sound devices available.
        if (0 == applicationDevices.Count)
        {
            MessageBox.Show("No available input devices. Sample will close.");
            Close();
            return;
        }

        try
        {
            // Create a sound device, and sound buffer array.
            applicationSoundDevice = new SoundDevice();
            applicationSoundDevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
            applicationSoundBuffers = new SecondaryBuffer[8];
        }
        catch (SoundException)
        {
            MessageBox.Show("No available sound device. Sample will close.");
            Close();
            return;
        }

        foreach (SemanticsInstance instance in applicationDevices)
        {
            // Build and set the action map against each device.
            instance.Device.BuildActionMap(mappings[0], ActionMapControl.Default);
            instance.Device.SetActionMap(mappings[0], ApplyActionMap.Default);
        }

        // Load default wav files.
        LoadSoundFile(sdkpath + "drumpad-bass_drum.wav", 0);
        LoadSoundFile(sdkpath + "drumpad-snare_drum.wav", 1);
        LoadSoundFile(sdkpath + "drumpad-hhat_up.wav", 2);
        LoadSoundFile(sdkpath + "drumpad-hhat_down.wav", 3);
        LoadSoundFile(sdkpath + "drumpad-crash.wav", 4);
        LoadSoundFile(sdkpath + "drumpad-voc_female_ec.wav", 5);
        LoadSoundFile(sdkpath + "drumpad-speech.wav", 6);

        // Turn on the timer.
        timer1.Enabled = true;
    }
Esempio n. 14
0
        public SoundManager(System.Windows.Forms.Control owner)
        {
            m_sounddevice = new DirectSound.Device(Guid.Empty);
            m_sounddevice.SetCooperativeLevel(owner, DirectSound.CooperativeLevel.Normal);

            DirectSound.Speakers speakers = new DirectSound.Speakers();
            speakers.Surround           = true;
            m_sounddevice.SpeakerConfig = speakers;

            m_listener = new SoundListener3d(m_sounddevice);
        }
Esempio n. 15
0
        public void PlayWithEndNotifacation(Stream audio, IntPtr hwnd)
        {
            Mp3Stream mp3Stream = new Mp3Sharp.Mp3Stream(audio);

            mp3Stream.Position = 0;
            dev = new Microsoft.DirectX.DirectSound.Device();
            dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
            ApplicationStreamedSound = new StreamedMp3Sound(dev, mp3Stream);
            ApplicationStreamedSound.BufferNotification += ApplicationStreamedSound_BufferNotificationSendPostback;
            ApplicationStreamedSound.Play();
        }
Esempio n. 16
0
 public void Init()
 {
     DelRes();
     ds = new Microsoft.DirectX.DirectSound.Device();
     ds.SetCooperativeLevel(form, CooperativeLevel.Normal);
     secBufferEffs = new EffectSound[effLen];
     for (int i = 0; i < effLen; i++)
     {
         secBufferEffs[i] = new EffectSound();
     }
     //*/
 }
Esempio n. 17
0
 public Form1()
 {
     InitializeComponent();
     dev.SetCooperativeLevel(this,
                             Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
     this.FormClosed            += new FormClosedEventHandler(Form1_FormClosed);
     port.ReceivedBytesThreshold = 1;
     port.BaudRate      = 115200;
     port.DtrEnable     = true;
     port.DataReceived += new SerialDataReceivedEventHandler(port_DataReceived);
     port.Open();
 }
Esempio n. 18
0
        public Form1()
        {
            InitializeComponent();

            deviceSound = new Microsoft.DirectX.DirectSound.Device();
            deviceSound.SetCooperativeLevel(Handle, CooperativeLevel.Priority);
            Init();
            GetGamePads();

            //the soundwaves class contains methods for synthesizing audio, and playing static audio
            soundWaves = new SoundWaves(deviceSound);
        }
Esempio n. 19
0
 public void Play(Stream audio, IntPtr hwnd)
 {
     if (!IsPlaying)
     {
         IsPlaying           = true;
         _mp3Stream          = new Mp3Sharp.Mp3Stream(audio);
         MyMp3Sream.Position = 0;
         dev = new Microsoft.DirectX.DirectSound.Device();
         dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
         ApplicationStreamedSound = new StreamedMp3Sound(dev, MyMp3Sream);
         ApplicationStreamedSound.BufferNotification += ApplicationStreamedSound_BufferNotification;
         ApplicationStreamedSound.Play();
     }
 }
Esempio n. 20
0
        public SoundAccess(ScreenAccess ParentForm)
        {
            try
            {
                device = new DirectSound.Device();
                device.SetCooperativeLevel(ParentForm, DirectSound.CooperativeLevel.Normal);
//				BackgroundMusic = new DirectSound.SecondaryBuffer(GameFiles.BgMusic, device);
//
//				BackgroundMusic.Play(0, DirectSound.BufferPlayFlags.Looping);
            }
            catch (Exception err)
            {
                throw err;
            }
        }
Esempio n. 21
0
        public PlayerHelper(Form parent)
        {
            wavPlayer = new SoundPlayer();
            wavFile   = null;


            soundDevice = new Microsoft.DirectX.DirectSound.Device(DSoundHelper.DefaultPlaybackDevice);
            soundDevice.SetCooperativeLevel(parent, CooperativeLevel.Normal);
            buffDesc = new BufferDescription();
            buffDesc.ControlEffects = true;
            buffDesc.ControlPan     = true;
            sound = null;

            wplayer = new WMPLib.WindowsMediaPlayer();
        }
Esempio n. 22
0
        private void frmAbout_Load(object sender, System.EventArgs e)
        {
            // All this to get the file name where the home directory of the app

            int fileName = Application.ExecutablePath.Length - Application.ExecutablePath.LastIndexOf("\\") - 1;

            path = Application.ExecutablePath.Remove(Application.ExecutablePath.Length - fileName, fileName);
            //MessageBox.Show(path);

            globalSettings.path = path;


            // I got sick of waiting while developing ;-)
                        #if (DEBUG)
            cmbDone.Visible = true;
                        #endif


            try
            {
                testCard = new Microsoft.DirectX.DirectSound.Device();
                testCard.SetCooperativeLevel(this, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);

                //Microsoft.DirectX.DirectSound.SecondaryBuffer[] aSound = new SecondaryBuffer[256];
                testSound = new Microsoft.DirectX.DirectSound.SecondaryBuffer(path + "fire.wav", testCard);
            }
            catch (Microsoft.DirectX.DirectSound.SoundException Exc)
            {
                MessageBox.Show("There has been an error while seting up your sound card; please review your Direct X settings. :: " + Exc.ErrorString.ToString());
            }

            lblVersion.Text = "Sending Request";
            string _webCheck = globalSettings.versionCheckAddress + globalSettings.releaseVersion;
            try
            {
                // Don't need to check if I am running the latest version while
                // developing it ;-)
                #if (!DEBUG)
                lblVersion.Text = httpFunctions.getVersion(_webCheck);
                #endif
            }
            catch
            {
            }

            // Audio device enumeration
            AudioDeviceEnumeration();
        }
Esempio n. 23
0
        } // initGfx().fim

        // [---
        public void inicializarSom()
        {
            string som_arquivo = @"c:\gameprog\gdkmedia\som\shoot.wav";

            // Cria um dispositivo de som
            radio = new DirectSound.Device();

            // Estabelece o nível de cooperação
            radio.SetCooperativeLevel(this, DirectSound.CooperativeLevel.Normal);

            // Cria um objeto SecondaryBuffer que toca o som
            som = new DirectSound.SecondaryBuffer(som_arquivo, radio);

            // Toca o som efetivamente
            som.Play(0, DirectSound.BufferPlayFlags.Default);
        } // inicializarSom().fim
Esempio n. 24
0
        private void btnPlay_Click(object sender, System.EventArgs e)
        {
            /*
             * OpenFileDialog ofd = new OpenFileDialog();
             * ofd.Filter = "wave files(*.wav|*.wav";
             * ofd.ShowDialog();
             * textBox1.Text = ofd.FileName;
             * textBox2.Text = ofd.FileName;
             *
             * //AudioClip		 ob_Clip = new AudioClip (textBox1.Text) ;
             *
             * AudioMediaAsset am = new AudioMediaAsset (ob_Clip.Channels ,  ob_Clip.BitDepth , ob_Clip.SampleRate) ;
             *
             *
             * am.AddClip (ob_Clip) ;
             *
             * AudioClip		 ob_Clip1 = new AudioClip (textBox2.Text) ;
             * am.AddClip (ob_Clip1) ;
             *
             * AudioClip		 ob_Clip2 = new AudioClip ("F:\\My Documents\\Project\\0.wav" , 0, 5000) ;
             * am.AddClip (ob_Clip2) ;
             */

            VuMeter ob_VuMeter = new VuMeter();

            ob_VuMeter.ScaleFactor      = 2;
            ob_VuMeter.SampleTimeLength = 2000;
            ob_VuMeter.LowerThreshold   = 10;
            ob_VuMeter.UpperThreshold   = 80;
            ob_VuMeter.ShowForm();
            ap.VuMeterObject = ob_VuMeter;

            Microsoft.DirectX.DirectSound.Device dSound = new  Microsoft.DirectX.DirectSound.Device();

            dSound.SetCooperativeLevel(this, CooperativeLevel.Priority);
            ap.OutputDevice = dSound;
            ap.CompFactor   = 1;
            ap.Play(am);
//MessageBox.Show ("Done") ;
        }
Esempio n. 25
0
 public Sounds()
 {
     try
     {
         m_Device = new Microsoft.DirectX.DirectSound.Device();
         m_Device.SetCooperativeLevel(Engine.m_Display, 2);
         m_Format = new WaveFormat();
         m_Format.set_Channels(1);
         m_Format.set_FormatTag(1);
         m_Format.set_BlockAlign(2);
         m_Format.set_BitsPerSample(0x10);
         m_Format.set_SamplesPerSecond(0x5622);
         m_Format.set_AverageBytesPerSecond(0xac44);
     }
     catch (Exception exception)
     {
         Debug.Trace("Error constructing sound factory");
         Debug.Error(exception);
         m_Device = null;
     }
     this.m_Buffer = new byte[0x2000];
 }
Esempio n. 26
0
 public static bool TryPlay(Stream audio, IntPtr hwnd)
 {
     try
     {
         Mp3Stream mp3Stream = new Mp3Sharp.Mp3Stream(audio);
         mp3Stream.Position = 0;
         if (mp3Stream.DecodeFrames(1) == 0)
         {
             throw new Exception("Could not decode");
         }
         Device dev = new Microsoft.DirectX.DirectSound.Device();
         dev.SetCooperativeLevel(hwnd, Microsoft.DirectX.DirectSound.CooperativeLevel.Normal);
         StreamedMp3Sound ApplicationStreamedSound = new StreamedMp3Sound(dev, mp3Stream);
         ApplicationStreamedSound.Play();
         ApplicationStreamedSound.Stop();
         return(true);
     }
     catch (Exception ex)
     {
         return(false);
     }
 }
Esempio n. 27
0
        private void createDevice()
        {
            int tries = 0;

            while (tries < 2)
            {
                try
                {
                    if (deviceName.Length > 0)
                    {
                        Guid g = getDeviceGUID();
                        if (g == Guid.Empty)
                        {
                            device = new Device();
                        }
                        else
                        {
                            device = new Device(g);
                        }
                    }
                    else
                    {
                        device = new Device();
                    }

                    device.SetCooperativeLevel(parentForm, CooperativeLevel.Priority);
                    if (createOutputBuffer())
                    {
                        return;
                    }
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.WriteLine(ex.ToString());
                }
                tries++;
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 28
0
 public Sounds()
 {
     try
     {
         m_Device = new Microsoft.DirectX.DirectSound.Device();
         m_Device.SetCooperativeLevel(Engine.m_Display, 2);
         m_Format = new WaveFormat();
         m_Format.set_Channels(1);
         m_Format.set_FormatTag(1);
         m_Format.set_BlockAlign(2);
         m_Format.set_BitsPerSample(0x10);
         m_Format.set_SamplesPerSecond(0x5622);
         m_Format.set_AverageBytesPerSecond(0xac44);
     }
     catch (Exception exception)
     {
         Debug.Trace("Error constructing sound factory");
         Debug.Error(exception);
         m_Device = null;
     }
     this.m_Buffer = new byte[0x2000];
 }
Esempio n. 29
0
        } // initGfx().fim

        // [---
        public void inicializarSom()
        {
            string som_arquivo = @"c:\gameprog\gdkmedia\som\shoot.wav";

            // Cria um dispositivo de som
            radio = new DirectSound.Device();

            // Estabelece o nível de cooperação
            radio.SetCooperativeLevel(this, DirectSound.CooperativeLevel.Normal);
            // <b>
            // Configura descrição do som
            DirectSound.BufferDescription desc = new DirectSound.BufferDescription();

            // Habilita controle de pan
            desc.ControlPan = true;

            // Habilita foco global. Efeito sonoro toca mesmo enquanto a aplicação
            // está em segundo plano
            desc.GlobalFocus = true;

            // Cria um objeto SecondaryBuffer que toca o som
            som = new DirectSound.SecondaryBuffer(som_arquivo, desc, radio);
            // </b>
        } // inicializarSom().fim
 private void InitializeSound()
 {
     soundDevice = new DS.Device();
     soundDevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
 }
Esempio n. 31
0
        /// <summary>
        /// Funkcja inicjujaca dzialanie silnika dzwiekowego (laczy sie z karta
        /// dzwiekowa, tworzy niezbedne obiekty (tablica dzwiekow, listener,
        /// glowny bufor dzwiekowy, obiekt szukajacy sciezek do plikow)
        /// </summary>
        /// <param name="owner">Obiekt (Forms), w ktorym ma byc umieszczony 
        /// silnik dzwiekowy</param>
        /// <param name="distanceFactor">Czynnik odleglosci</param>
        /// <param name="roloffFactor">Czynnik roloff</param>
        /// <param name="volume">Glosnosc</param>
        public static void InitializeEngine(Control owner, int volume,
            float distanceFactor, float roloffFactor)
        {
            //karta dzwiekowa
            soundCard = new DS.Device();
            soundCard.SetCooperativeLevel(owner, CooperativeLevel.Normal);

            //lista dzwiekow
            soundList = new ArrayList();

            //listener
            primaryBufferDescription = new BufferDescription();
            primaryBufferDescription.ControlEffects = false;
            primaryBufferDescription.Control3D = true;
            primaryBufferDescription.PrimaryBuffer = true;
            primaryBufferDescription.ControlVolume = true;
            primaryBuffer = new DS.Buffer(primaryBufferDescription, soundCard);
            primaryBuffer.Volume = volume;

            listener = new Listener3D(primaryBuffer);
            listener.DistanceFactor = distanceFactor;
            listener.RolloffFactor = roloffFactor;

            //muzyka w tle

            //SourceNameFinder
            nameFinder = new SourceNameFinder();
        }
Esempio n. 32
0
 static void InitializeSound()
 {
     // Om du ikke har lydkort, kommenter bort disse 2 linjer under
     dsDevice = new DSDevice();
     dsDevice.SetCooperativeLevel(m_GameWindow, CooperativeLevel.Normal);
 }
Esempio n. 33
0
 public void InitializeSound()
 {
     soundDevice = new DXSoundDevice();
     soundDevice.SetCooperativeLevel(Game.renderSurface, CooperativeLevel.Normal);
 }
Esempio n. 34
0
 static void InitializeSound()
 {
     dsDevice = new DSDevice();
     dsDevice.SetCooperativeLevel(m_GameWindow, CooperativeLevel.Normal);
 }
Esempio n. 35
0
        static void InitializeSound()
        {
// Om du ikke har lydkort, kommenter bort disse 2 linjer under
            dsDevice = new DSDevice();
            dsDevice.SetCooperativeLevel(m_GameWindow, CooperativeLevel.Normal);
        }
Esempio n. 36
0
 protected void InitDSound()
 {
     dsoundDevice = new DSound.Device();
     dsoundDevice.SetCooperativeLevel(this, DSound.CooperativeLevel.Priority);
 }
        private void InitializeGraphics()
        {
            try {
                PresentParameters presentParams = new PresentParameters();
                presentParams.Windowed = true;
                presentParams.SwapEffect = SwapEffect.Discard;
                presentParams.BackBufferFormat = Format.Unknown;
                presentParams.AutoDepthStencilFormat = DepthFormat.D16;
                presentParams.EnableAutoDepthStencil = true;

                // Store the default adapter
                int adapterOrdinal = D3D.Manager.Adapters.Default.Adapter;
                CreateFlags flags = CreateFlags.SoftwareVertexProcessing;

                // Check to see if we can use a pure hardware device
                D3D.Caps caps = D3D.Manager.GetDeviceCaps(adapterOrdinal, D3D.DeviceType.Hardware);

                // Do we support hardware vertex processing?
                if (caps.DeviceCaps.SupportsHardwareTransformAndLight)
                    // Replace the software vertex processing
                    flags = CreateFlags.HardwareVertexProcessing;

                // Do we support a pure device?
                if (caps.DeviceCaps.SupportsPureDevice)
                    flags |= CreateFlags.PureDevice;

                device = new D3D.Device(0, D3D.DeviceType.Hardware, this, flags, presentParams);
                device.DeviceReset += new System.EventHandler(this.OnResetDevice);
                OnResetDevice(device, null);

                tileSheet = TextureLoader.FromFile(device, MediaUtilities.FindFile("donuts.bmp"), 1024, 1024,
                    1, 0,Format.A8R8G8B8, Pool.Managed, Filter.Point, Filter.Point, (unchecked((int)0xff000000)));

                tileSet = new TileSet(tileSheet, 0, 0, 6, 5, 32, 32);
                tilePosition = new Rectangle(tileSet.XOrigin, tileSet.YOrigin,tileSet.ExtentX*2, tileSet.ExtentY*2);

                //set up DirectInput keyboard device...
                kbd = new DI.Device(SystemGuid.Keyboard);
                kbd.SetCooperativeLevel(this,
                    DI.CooperativeLevelFlags.Background | DI.CooperativeLevelFlags.NonExclusive );
                kbd.Acquire();

                //Set up DirectSound device and buffers
                snd = new DS.Device();
                snd.SetCooperativeLevel(this, DS.CooperativeLevel.Normal);
                bounce = new DS.SecondaryBuffer(MediaUtilities.FindFile("bounce.wav"), snd);

                hrt.Start();
            }
            catch (DirectXException) {
                // Catch any errors and return a failure
            }
        }
Esempio n. 38
0
 public void InitializeSound()
 {
     soundDevice = new DXSoundDevice();
     soundDevice.SetCooperativeLevel(Game.renderSurface, CooperativeLevel.Normal);
 }
Esempio n. 39
0
        public Texture[,] TEXTURE = new Texture[4,18]; //

        #endregion Fields

        #region Constructors

        /// <summary>
        /// MAPSTUFF
        /// </summary>
        /// 
        public c_resource_management(string basepfad, IntPtr hwnd)
        {
            this.Pfad = basepfad;
            HWND = hwnd;
            SOUNDDEVICE = new Microsoft.DirectX.DirectSound.Device();
            SOUNDDEVICE.SetCooperativeLevel(HWND, CooperativeLevel.Normal);
        }