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)); }
public virtual void UpdateSprite(float DeltaTime) { frameTrigger += DeltaTime; //Do we move to the next frame? if (frameTrigger >= frameRate) { frameTrigger = 0f; frame++; if (frame == tileSet.NumberFrameColumns * tileSet.NumberFrameRows) { frame = 0; //loop to beginning } } //Now change the location of the image tilePosition.X = tileSet.XOrigin + ((int)frame % tileSet.NumberFrameColumns) * tileSet.ExtentX * 2; tilePosition.Y = tileSet.YOrigin + ((int)frame / tileSet.NumberFrameColumns) * tileSet.ExtentY * 2; //update sprite position spritePosition.X += spriteVelocity.X * DeltaTime; spritePosition.Y += spriteVelocity.Y * DeltaTime; //bounce sprite if it tries to go outside window if (spritePosition.X > (this.Width - (tileSet.ExtentX * 2)) || spritePosition.X < 0) { spriteVelocity.X *= -1; bounce.Play(0, DS.BufferPlayFlags.Default); } if (spritePosition.Y > (this.Height - (tileSet.ExtentY * 2)) || spritePosition.Y < 0) { spriteVelocity.Y *= -1; bounce.Play(0, DS.BufferPlayFlags.Default); } }
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); } } }
private void play() { dxWriteCursor = 0; feedBuffer(); dxOutputBuffer.Play(0, BufferPlayFlags.Looping); try { while (!kill) { if (needsFeed) { if (paused) { feedSilence(); } else { feedBuffer(); } } System.Threading.Thread.Sleep(OutputDX.SLEEP_TIME_BETWEEN_BUFFER_CHECKS); } } catch (Microsoft.DirectX.DirectSound.NoDriverException e) { System.Diagnostics.Debug.WriteLine(e.ToString()); resetDevice(); playStartThread(); } catch (Exception e) { System.Diagnostics.Debug.WriteLine(e.ToString()); } }
public void PlayExplosion() { if (ExplosionSound == null) { ExplosionSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundExplosion, device); } ExplosionSound.SetCurrentPosition(0); ExplosionSound.Play(0, DirectSound.BufferPlayFlags.Default); }
public void NewShot(Vector3 pos, Vector3 direction) { dsoundBuffer.Play(0, DSound.BufferPlayFlags.Default); int id = Directions.Count; Directions[id] = direction; gunshot.Directions[id] = direction; gunshot.Positions[id] = pos; }
public void PlayStep() { if (StepSound == null) { StepSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundStep, device); } StepSound.SetCurrentPosition(0); StepSound.Play(0, DirectSound.BufferPlayFlags.Default); }
public void PlayGunShot() { if (GunSound == null) { GunSound = new DirectSound.SecondaryBuffer(GameConfig.Files.SoundGun, device); } GunSound.SetCurrentPosition(0); GunSound.Play(0, DirectSound.BufferPlayFlags.Default); }
/// <summary> /// play sound /// </summary> /// <param name="loop"></param> /// <param name="volume"></param> public override void Play(bool loop, int volume) { Microsoft.DirectX.DirectSound.BufferPlayFlags flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Default; if (loop) { flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Looping; } SetVolume(volume); m_secondaryBuffer.Play(0, flags); }
private void SoundFX_PlaySound(bool bLooping) // plays sound file { if (null != ApplicationBuffer) { ApplicationBuffer.Frequency = trackBar1.Value; ApplicationBuffer.Play(0, (bLooping ? Microsoft.DirectX.DirectSound.BufferPlayFlags.Looping : Microsoft.DirectX.DirectSound.BufferPlayFlags.Default)); } //ApplicationBuffer. }
public override void Play(SoundVector pos, bool loop, int volume) { Microsoft.DirectX.DirectSound.BufferPlayFlags flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Default; if (loop) { flags = Microsoft.DirectX.DirectSound.BufferPlayFlags.Looping; } UpdatePosition(pos); SetVolume(volume); m_secondaryBuffer.Play(0, flags); }
private void playSound(String url) { try { Microsoft.DirectX.DirectSound.SecondaryBuffer snd = new Microsoft.DirectX.DirectSound.SecondaryBuffer( url, dev); snd.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default); } catch (Exception ex) { ; } }
} // inicializarSom().fim // ---] // [--- private void Tela_KeyDown(object sender, KeyEventArgs e) { // Toca o som no lado esquerdo if (e.KeyCode == Keys.Left) { som.Pan = -5000; som.Play(0, DirectSound.BufferPlayFlags.Default); } // endif // Toca o som no lado esquerdo\direito igualmente if (e.KeyCode == Keys.Up) { som.Pan = 0; som.Play(0, DirectSound.BufferPlayFlags.Default); } // endif // Toca o som no lado direito if (e.KeyCode == Keys.Right) { som.Pan = 5000; som.Play(0, DirectSound.BufferPlayFlags.Default); } // endif } // Tela_KeyDown().fim
} // 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
/// <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); }
} // MostrarTexto().fim private void Tela_KeyDown(object sender, KeyEventArgs e) { // Toca o som efetivamente som.Play(0, DirectSound.BufferPlayFlags.Default); }
public override void Play() { mBuffer.Play(0, Microsoft.DirectX.DirectSound.BufferPlayFlags.Default); }