コード例 #1
1
        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);
        }
コード例 #2
1
ファイル: Form1.cs プロジェクト: Alexrerx/yaalp
        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);
        }
コード例 #3
0
        public static void setupAudio(System.Windows.Forms.Control callingForm)
        {
            aSoundCard = new Device(globalSettings.audioDevice);
            aSoundCard.SetCooperativeLevel(callingForm, CooperativeLevel.Priority);

            aSound = new SecondaryBuffer[262];

            // For the pitch shifting roll
            aSample = new sample[262];

            for (int i = 0; i < 261; i++)
            {
                //sampleLocations[i] = "";
                loopSample[i] = false;
            }



            //aSound[255].Play(0,Microsoft.DirectX.DirectSound.BufferPlayFlags.Default);

            //Microsoft.DirectX.DirectSound.EffectDescription[] bufferEffects = new EffectDescription[256];



            //bufferEffects[0] = Microsoft.DirectX.DirectSound.DSoundHelper.StandardChorusGuid;
            //aSound[255].SetEffects(bufferEffects);
            //aSound[255].Play(0,Microsoft.DirectX.DirectSound.BufferPlayFlags.Default);
        }
コード例 #4
0
ファイル: AudioRecorder.cs プロジェクト: daisy/obi
        public void SetInputDevice()
        {
            CaptureDevicesCollection devices = new CaptureDevicesCollection();

            Microsoft.DirectX.DirectSound.Device mDevice = new Device(devices[Index].DriverGuid);
            mInputDevice = mDevice;
        }
コード例 #5
0
        private void cmbDone_Click(object sender, System.EventArgs e)
        {
            // Gets the GUID of the selected sound device
            globalSettings.audioDevice = directSoundDevices[cmbDevices.SelectedIndex];
            //globalSettings.selectedAudioDevice = cmbDevices.SelectedIndex;

            globalSettings.aDC.selectedAudioDevice = cmbDevices.SelectedIndex;
            audioDeviceSave();

            if (dsInterface.aSoundCard == null)
            {
                // Sets up the DX Audio Interface for the program
                dsInterface.setupAudio(this);
            }
            else
            {
                dsInterface.changeAudioDevice();
            }



            // Close it all down
            testSound  = null;
            testCard   = null;
            AboutTimer = null;
            this.Close();
        }
コード例 #6
0
ファイル: MainForm.cs プロジェクト: zendive/sound
        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();
            }
        }
コード例 #7
0
ファイル: Form1.cs プロジェクト: TheMatthew/Salisify
 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;
     }
 }
コード例 #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            StreamReader sr1 = new StreamReader("mame.ini");

            sr1.ReadLine();
            sSelect = sr1.ReadLine();
            sr1.Close();
            this.Text = Version.build_version;
            resetToolStripMenuItem.Enabled = false;
            gameStripMenuItem.Enabled      = false;
            cpsToolStripMenuItem.Enabled   = false;
            Mame.sHandle1 = this.Handle.ToString();
            RomInfo.Rom   = new RomInfo();
            dev           = new DSDevice();
            dev.SetCooperativeLevel(this, CooperativeLevel.Normal);
            desc1               = new BufferDescription();
            desc1.Format        = CreateWaveFormat();
            desc1.BufferBytes   = 0x9400;
            desc1.ControlVolume = true;
            desc1.GlobalFocus   = true;
            Keyboard.InitializeInput(this);
            Sound.buf2 = new SecondaryBuffer(desc1, dev);
            //Mame.init_machine();
            InitLoadForm();
            InitCheatForm();
            InitCheatsearchForm();
            InitIpsForm();
            InitM68000Form();
            InitZ80Form();
            InitM6809Form();
            InitCpsForm();
            InitNeogeoForm();
            InitNamcos1Form();
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: kurtis2222/snarf-win32
 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();
 }
コード例 #10
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;
        }
コード例 #11
0
ファイル: PSI_DirectFrame.cs プロジェクト: d3x0r/xperdex
 public D3DState()
 {
     Direct3D.Device    graphics  = null;
     DirectSound.Device sound     = null;
     DirectInput.Device keyboard  = null;
     DirectInput.Device mouse     = null;
     DirectInput.Device gameinput = null;
 }
コード例 #12
0
ファイル: WindVideo.xaml.cs プロジェクト: xungong91/GxProgram
        private void InitAudio()
        {
            DevicesCollection dcollection = new DevicesCollection();
            Guid devguid = dcollection[1].DriverGuid;

            device = new Microsoft.DirectX.DirectSound.Device(devguid);
            device.SetCooperativeLevel(wpfHwnd, CooperativeLevel.Normal);
        }
コード例 #13
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);
 }
コード例 #14
0
        public ShootingClass(Device d3dDevice, DSound.Device dsoundD)
        {
            Hashtable aux = new Hashtable();

            Directions   = Hashtable.Synchronized(aux);
            dsoundDevice = dsoundD;
            dsoundBuffer = new DSound.SecondaryBuffer(@"media\sound\machgun.wav", dsoundDevice);
            gunshot      = new shot(d3dDevice);
        }
コード例 #15
0
        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
            }
        }
コード例 #16
0
ファイル: MafiaLoader.cs プロジェクト: sinshu/mafia
        public SecondaryBuffer GetBuffer(Microsoft.DirectX.DirectSound.Device device, string fileName)
        {
            BufferDescription bd = new BufferDescription();

            bd.ControlEffects = false;
            bd.ControlPan     = true;
            bd.ControlVolume  = true;
            return(new SecondaryBuffer(GetFileStream(fileName), bd, device));
        }
コード例 #17
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);
        }
コード例 #18
0
ファイル: Form1.cs プロジェクト: qbytes-dq/GameProgramming
 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
 }
コード例 #19
0
ファイル: Mp3Player.cs プロジェクト: Valentine1/LexiGame
        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();
        }
コード例 #20
0
ファイル: Main.cs プロジェクト: 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;
    }
コード例 #21
0
        public SoundBuffer(Device soundDevice, string filename, Sounds thisSound, bool looping)
        {
            this.thisSound = thisSound;
            this.looping = looping;

            try {
                buffer = new SecondaryBuffer(filename, soundDevice);
            }
            catch (Exception e) {
                throw new Exception(String.Format("Error opening {0}", filename), e);
            }
        }
コード例 #22
0
        public SoundBuffer(Device soundDevice, string filename, Sounds thisSound, bool looping)
        {
            this.thisSound = thisSound;
            this.looping   = looping;

            try {
                buffer = new SecondaryBuffer(filename, soundDevice);
            }
            catch (Exception e) {
                throw new Exception(String.Format("Error opening {0}", filename), e);
            }
        }
コード例 #23
0
ファイル: Sound.cs プロジェクト: kevinnewkevin/PiaoPiao
 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();
     }
     //*/
 }
コード例 #24
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);
        }
コード例 #25
0
        public Sound2d(string file, DirectSound.Device device)
        {
            // 2d setup
            m_description2d = new DirectSound.BufferDescription();
            m_description2d.ControlEffects        = false;
            m_description2d.ControlVolume         = true;
            m_description2d.GlobalFocus           = true;
            m_description2d.ControlPositionNotify = true;

            m_secondaryBuffer = new DirectSound.SecondaryBuffer(file, m_description2d, device);

            m_notify = new DirectSound.Notify(m_secondaryBuffer);
        }
コード例 #26
0
ファイル: Mp3Player.cs プロジェクト: Valentine1/LexiGame
 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();
     }
 }
コード例 #27
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;
            }
        }
コード例 #28
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();
        }
コード例 #29
0
ファイル: Sound.cs プロジェクト: soapyfrog/grrr
 static Sound()
 {
     // Not sure what the equiv of java's Class.forName() is for testing availability...
     try
     {
         Device d = new Microsoft.DirectX.DirectSound.Device();
         d.Dispose();
         available = true;
     }
     catch (Exception e) {
         // to avoid warning on e not being used.
         // is there a [SuppressWarning] attribute?
         available = (e == null);
     }
 }
コード例 #30
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();
        }
コード例 #31
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
コード例 #32
0
        public Sound3d(string file, DirectSound.Device device)
        {
            m_description3d = new DirectSound.BufferDescription();
            m_description3d.ControlEffects        = false;
            m_description3d.GlobalFocus           = true;
            m_description3d.Control3D             = true;
            m_description3d.ControlVolume         = true;
            m_description3d.Guid3DAlgorithm       = DirectSound.DSoundHelper.Guid3DAlgorithmHrtfFull;
            m_description3d.ControlPositionNotify = true;

            m_secondaryBuffer = new DirectSound.SecondaryBuffer(file, m_description3d, device);

            m_buffer3d          = new DirectSound.Buffer3D(m_secondaryBuffer);
            m_buffer3d.Position = new SoundVector(0, 0, 1);
            m_buffer3d.Mode     = DirectSound.Mode3D.Normal;

            m_notify = new DirectSound.Notify(m_secondaryBuffer);
        }
コード例 #33
0
        public SoundListener3d(DirectSound.Device device)
        {
            // 3d setup
            m_descriptionListener = new DirectSound.BufferDescription();

            m_descriptionListener.ControlEffects = false;
            m_descriptionListener.Control3D      = true;
            m_descriptionListener.ControlVolume  = true;
            m_descriptionListener.PrimaryBuffer  = true;

            m_primary3d  = new DirectSound.Buffer(m_descriptionListener, device);
            m_listener3d = new DirectSound.Listener3D(m_primary3d);

            // default orientation
            DirectSound.Listener3DOrientation o = new DirectSound.Listener3DOrientation();
            o.Front = new Microsoft.DirectX.Vector3(0, 0, 1);   // facing forward
            o.Top   = new Microsoft.DirectX.Vector3(0, 1, 0);   // standing upright

            m_listener3d.Orientation = o;
        }
コード例 #34
0
ファイル: Sounds.cs プロジェクト: Skinny1001/PlayUO
 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];
 }
コード例 #35
0
ファイル: Main.cs プロジェクト: ptaa32/ARDOP
 public bool StopCodec(ref string strFault)
 {
     bool functionReturnValue = false;
     // Stop the capture
     lock (objCodecLock)
     {
         try
         {
             if (MCB.DebugLog)
                 Logs.WriteDebug("[Main.StopCodec] Stop thrNotify with blnSCCapturing = False");
             blnSCCapturing = false;
             // this should end the wait thread if it is still running
             Thread.Sleep(200);
             //If blnInWaitThread Then
             if (thrNotify != null && thrNotify.IsAlive)
             {
                 if (MCB.DebugLog)
                     Logs.WriteDebug("[Main.StopCodec] Aborting thrNotify");
                 thrNotify.Abort();
                 Thread.Sleep(100);
                 thrNotify.Join(3000);
             }
             thrNotify = null;
             //blnInWaitThread = False
             //lblCapture.BackColor = Color.LightSalmon
             // Stop the buffer
             if (objCapture != null)
             {
                 objCapture.Stop();
                 objCapture.Dispose();
             }
             objCapture = null;
             if (devCaptureDevice != null)
                 devCaptureDevice.Dispose();
             devCaptureDevice = null;
             if (devSelectedPlaybackDevice != null)
             {
                 devSelectedPlaybackDevice.Dispose();
             }
             devSelectedPlaybackDevice = null;
             if (MCB.DebugLog)
                 Logs.WriteDebug("[Main.StopCodec] = True");
             functionReturnValue = true;
             objProtocol.ARDOPProtocolState = ProtocolState.OFFLINE;
         }
         catch (Exception ex)
         {
             Logs.Exception("[Main.StopCodec] Err: " + ex.ToString);
             if (MCB.DebugLog)
                 Logs.WriteDebug("[Main.StopCodec] = False");
             strFault = Err.Number.ToString + "/" + Err.Description;
             functionReturnValue = false;
         }
         //blnEnableCaptureRestart = False
     }
     return functionReturnValue;
 }
コード例 #36
0
ファイル: GameEngine.cs プロジェクト: scarlac/d3d-strategy
 public void InitializeSound()
 {
     soundDevice = new DXSoundDevice();
     soundDevice.SetCooperativeLevel(Game.renderSurface, CooperativeLevel.Normal);
 }
コード例 #37
0
ファイル: c_audio.cs プロジェクト: kindziora/csharpDX
 public c_audio(ref c_resource_management tmpmgm)
 {
     pRESOURCES = tmpmgm;
     pDEVICE = pRESOURCES.SOUNDDEVICE;
 }
コード例 #38
0
        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
            }
        }
コード例 #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);
        }
コード例 #40
0
ファイル: Sounds.cs プロジェクト: Skinny1001/PlayUO
 public void Dispose()
 {
     if (m_Cache != null)
     {
         for (int i = 0; i < 0x1000; i++)
         {
             if (m_Cache[i] != null)
             {
                 m_Cache[i].Dispose();
                 m_Cache[i] = null;
             }
         }
         m_Cache = null;
     }
     m_Stream.Close();
     m_Stream = null;
     m_Index.Close();
     m_Index = null;
     m_Device = null;
     this.m_Buffer = null;
 }
コード例 #41
0
ファイル: engine_game.cs プロジェクト: unk1nd/US_AirForce
        public virtual void Dispose()
        {
            foreach(Engine_Picture picture in m_Pictures)
                picture.Dispose();
            m_Pictures.Clear();

            foreach(Engine_Font font in m_Fonts)
                font.Dispose();
            m_Fonts.Clear();

            foreach(Engine_Sound sound in m_Sounds)
                sound.Dispose();
            m_Sounds.Clear();

            foreach (Engine_Music music in m_Music)
                music.Dispose();
            m_Music.Clear();

            dIDevice.Dispose();
            dIDevice = null;
            // Kommenter ut disse 2 linjer under "dsDevice..." om du ikke har lydkort
            dsDevice.Dispose();
            dsDevice = null;
            DXSprite.Dispose();
            DXSprite = null;
            dGDevice.Dispose();
            dGDevice = null;
            m_GameWindow.Dispose();
            m_GameWindow = null;
            m_Disposed = true;
        }
コード例 #42
0
 private void InitializeSound()
 {
     soundDevice = new DS.Device();
     soundDevice.SetCooperativeLevel(this, CooperativeLevel.Normal);
 }
コード例 #43
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();
        }
コード例 #44
0
ファイル: engine_game.cs プロジェクト: unk1nd/US_AirForce
 static void InitializeSound()
 {
     // Om du ikke har lydkort, kommenter bort disse 2 linjer under
     dsDevice = new DSDevice();
     dsDevice.SetCooperativeLevel(m_GameWindow, CooperativeLevel.Normal);
 }
コード例 #45
0
ファイル: Main.cs プロジェクト: ptaa32/ARDOP
        public bool StartCodec(ref string strFault)
        {
            bool functionReturnValue = false;
            //Returns true if successful
            Thread.Sleep(100);
            // This delay is necessary for reliable starup following a StopCodec
            lock (objCodecLock) {
            dttLastSoundCardSample = Now;
            bool blnSpectrumSave = MCB.DisplaySpectrum;
            bool blnWaterfallSave = MCB.DisplayWaterfall;
            System.DateTime dttStartWait = Now;
            MCB.DisplayWaterfall = false;
            MCB.DisplaySpectrum = false;
            string[] strCaptureDevices = EnumerateCaptureDevices();
            string[] strPlaybackDevices = EnumeratePlaybackDevices();
            functionReturnValue = false;
            DeviceInformation objDI = new DeviceInformation();
            int intPtr = 0;
            // Playback devices
            try {
                cllPlaybackDevices = null;

                cllPlaybackDevices = new Microsoft.DirectX.DirectSound.DevicesCollection();
                if ((devSelectedPlaybackDevice != null)) {
                    devSelectedPlaybackDevice.Dispose();
                    devSelectedPlaybackDevice = null;
                }

                foreach (DeviceInformation objDI in cllPlaybackDevices) {
                    DeviceDescription objDD = new DeviceDescription(objDI);
                    if (strPlaybackDevices(intPtr) == MCB.PlaybackDevice) {
                        if (MCB.DebugLog)
                            Logs.WriteDebug("[Main.StartCodec] Setting SelectedPlaybackDevice = " + MCB.PlaybackDevice);
                        devSelectedPlaybackDevice = new Device(objDD.info.DriverGuid);
                        functionReturnValue = true;
                        break; // TODO: might not be correct. Was : Exit For
                    }
                    intPtr += 1;
                }
                if (!functionReturnValue) {
                    strFault = "Playback Device setup, Device " + MCB.PlaybackDevice + " not found in Windows enumerated Playback Devices";
                }
            } catch (Exception ex) {
                strFault = Err.Number.ToString + "/" + Err.Description;
                Logs.Exception("[StartCodec], Playback Device setup] Err: " + ex.ToString);
                functionReturnValue = false;
            }
            if (functionReturnValue) {
                // Capture Device
                CaptureBufferDescription dscheckboxd = new CaptureBufferDescription();
                try {
                    functionReturnValue = false;
                    cllCaptureDevices = null;
                    cllCaptureDevices = new CaptureDevicesCollection();
                    intPtr = 0;
                    for (int i = 0; i <= cllCaptureDevices.Count - 1; i++) {
                        if (MCB.CaptureDevice == strCaptureDevices(i)) {
                            objCaptureDeviceGuid = cllCaptureDevices(i).DriverGuid;
                            devCaptureDevice = new Capture(objCaptureDeviceGuid);
                            stcSCFormat.SamplesPerSecond = 12000;
                            // 12000 Hz sample rate
                            stcSCFormat.Channels = 1;
                            stcSCFormat.BitsPerSample = 16;
                            stcSCFormat.BlockAlign = 2;
                            stcSCFormat.AverageBytesPerSecond = 2 * 12000;
                            stcSCFormat.FormatTag = WaveFormatTag.Pcm;
                            objApplicationNotify = null;
                            objCapture = null;
                            // Set the buffer sizes
                            intCaptureBufferSize = intNotifySize * intNumberRecordNotifications;
                            // Create the capture buffer
                            dscheckboxd.BufferBytes = intCaptureBufferSize;
                            stcSCFormat.FormatTag = WaveFormatTag.Pcm;
                            dscheckboxd.Format = stcSCFormat;
                            // Set the format during creatation
                            if ((objCapture != null)) {
                                objCapture.Dispose();
                                objCapture = null;
                            }
                            //objCapture = New CaptureBuffer(dscheckboxd, devCaptureDevice)
                            intNextCaptureOffset = 0;
                            WriteTextToSpectrum("CODEC Start OK", Brushes.LightGreen);
                            while (Now.Subtract(dttStartWait).TotalSeconds < 3) {
                                Application.DoEvents();
                                Thread.Sleep(100);
                            }
                            objCapture = new CaptureBuffer(dscheckboxd, devCaptureDevice);
                            InititializeNotifications();
                            objCapture.Start(true);
                            // start with looping
                            InititializeSpectrum(Color.Black);

                            functionReturnValue = true;
                        }
                    }
                    if (!functionReturnValue) {
                        strFault = "Could not find DirectSound capture device " + MCB.CaptureDevice.ToUpper;
                        //Logs.Exception("[Main.StartCodec] Could not find DirectSound capture device " & MCB.CaptureDevice & " in Windows enumerated Capture Devices")
                    }
                } catch (Exception ex) {
                    strFault = Err.Number.ToString + "/" + Err.Description;
                    functionReturnValue = false;
                    //Logs.Exception("[Main.StartCodec] Err: " & ex.ToString)
                }
            }

            if (functionReturnValue) {
                if (MCB.DebugLog)
                    Logs.WriteDebug("[Main.StartCodec] Successful start of codec");
                objProtocol.ARDOPProtocolState = ProtocolState.DISC;
            } else {
                if (MCB.DebugLog)
                    Logs.WriteDebug("[Main.StartCodec] CODEC Start Failed");
                WriteTextToSpectrum("CODEC Start Failed", Brushes.Red);
                objProtocol.ARDOPProtocolState = ProtocolState.OFFLINE;
                while (Now.Subtract(dttStartWait).TotalSeconds < 3) {
                    Application.DoEvents();
                    Thread.Sleep(100);
                }
                tmrStartCODEC.Interval = 5000;
                tmrStartCODEC.Start();
            }
            InititializeSpectrum(Color.Black);
            MCB.DisplayWaterfall = blnWaterfallSave;
            MCB.DisplaySpectrum = blnSpectrumSave;
            }
            return functionReturnValue;
        }