示例#1
0
 private void button5_Click(object sender, System.EventArgs e)
 {
     if (ApplicationBuffer != null)
     {
         ApplicationBuffer.SetCurrentPosition(500000);
     }
 }
 public void Play(bool on)
 {
     // looping sounds don't get restarted
     if (looping)
     {
         if (on)
         {
             if (!lastValue)
             {
                 buffer.SetCurrentPosition(1000);
                 buffer.Play(0, BufferPlayFlags.Looping);
             }
         }
         else
         {
             buffer.Stop();
         }
         lastValue = on;
     }
     else
     {
         if (on)
         {
             buffer.SetCurrentPosition(0);
             buffer.Play(0, BufferPlayFlags.Default);
         }
     }
 }
示例#3
0
        private void ghettoEditionLogo_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            try
            {
                if (testSound.Status.Playing == false)
                {
                    testSound.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default);
                }
                else
                {
                    testSound.SetCurrentPosition(0);
                    testSound.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default);
                }
            }
            catch (Microsoft.DirectX.DirectSound.SoundException Exc)
            {
                MessageBox.Show("There has been an error while attempting to play a test sample; please review your Direct X settings and confirm the test sample is located with this executable. Direct X error message follows :: " + Exc.Message.ToString() + " " + Exc.ErrorCode.ToString() + " " + Exc.ErrorString.ToString());
            }


            Graphics g;

            // Sets g to a graphics object representing the drawing surface of the
            // control or form g is a member of.
            g = ghettoEditionLogo.CreateGraphics();

            System.Drawing.SolidBrush shadow = new System.Drawing.SolidBrush(System.Drawing.Color.DarkGray);
            g.FillEllipse(shadow, new Rectangle((e.X + 1) - 5, (e.Y + 1) - 5, 10, 10));

            System.Drawing.SolidBrush hole = new System.Drawing.SolidBrush(System.Drawing.Color.Black);
            g.FillEllipse(hole, new Rectangle(e.X - 5, e.Y - 5, 10, 10));
        }
示例#4
0
 public void PlayStep()
 {
     if (StepSound == null)
     {
         StepSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundStep, device);
     }
     StepSound.SetCurrentPosition(0);
     StepSound.Play(0, DirectSound.BufferPlayFlags.Default);
 }
示例#5
0
 public void PlayGunShot()
 {
     if (GunSound == null)
     {
         GunSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundGun, device);
     }
     GunSound.SetCurrentPosition(0);
     GunSound.Play(0, DirectSound.BufferPlayFlags.Default);
 }
示例#6
0
 public void PlayExplosion()
 {
     if (ExplosionSound == null)
     {
         ExplosionSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundExplosion, device);
     }
     ExplosionSound.SetCurrentPosition(0);
     ExplosionSound.Play(0, DirectSound.BufferPlayFlags.Default);
 }
示例#7
0
文件: MainForm.cs 项目: zendive/sound
        /// <summary>Alter playback buffer by applying embient sensors</summary>
        private void HandleOnTrigger()
        {
            if (soundBuffer == null)
            {
                return;
            }
            m_ambient.m_bManualCPU = chkCPUOverride.Checked;
            if (chkCPUOverride.Checked)
            {
                m_ambient.sensor.cpu = tbCPUOverride.Value;
            }
            else
            {
                tbCPUOverride.Value = (int)m_ambient.sensor.cpu;
            }

            m_ambient.m_bManualRAM = chkRAMOverride.Checked;
            tbRAMOverride.Minimum  = 1;
            tbRAMOverride.Maximum  = (int)(m_ambient.sensor.ramTotal / 1000);
            if (chkRAMOverride.Checked)
            {
                m_ambient.sensor.ram = (double)(tbRAMOverride.Value) * 1000;
            }
            else
            {
                tbRAMOverride.Value = (int)(m_ambient.sensor.ram / 1000);
            }
            lblAmbient.Text = m_ambient.sensor.ToString();

            bool bGenerateCPUWave, bGenerateRAMWave;

            wave = WaveDynamic(sensor, m_ambient.sensor, out bGenerateCPUWave, out bGenerateRAMWave);

            if (bGenerateCPUWave && (wave[wave.Length - 1] == (byte)(2 * byAmpLevel)))
            {
                lblStatus.Text = "[" + dHz_CPU + "]";
            }

            sensor.Copy(m_ambient.sensor);

            BuildDiagram(zedGraph1, wave);

            //soundBuffer.Stop();
            soundBuffer.SetCurrentPosition(0);
            soundBuffer.Write(0, wave, LockFlag.None);
            soundBuffer.Play(0, BufferPlayFlags.Default);
        }