0

XNA サウンド エフェクトで動作するインストゥルメント アプリケーションがあります。私の問題はそれです。別の効果音を再生中に別の効果音を再生すると、最後の効果音が最初の効果音を殺しています。それは私が望んでいるものではなく、同じ音でも非同期で再生したいのです。私はそれについて何ができますか?

ご協力いただきありがとうございます。

  public static SoundEffectInstance passSound;
  public static SoundEffect passSound;


  LoadSoundInstance("Assets/SoundEffects/passSound.wav", out passSound, out passSoundInstance);


  private void LoadSound(String SoundFilePath, out SoundEffect Sound)
    {
        // For error checking, assume we'll fail to load the file.
        Sound = null;

        try
        {
            // Holds informations about a file stream.
            StreamResourceInfo SoundFileInfo = App.GetResourceStream(new Uri(SoundFilePath, UriKind.Relative));

            // Create the SoundEffect from the Stream
            Sound = SoundEffect.FromStream(SoundFileInfo.Stream);
        }
        catch (NullReferenceException)
        {
            // Display an error message
            MessageBox.Show("Couldn't load sound " + SoundFilePath);
        }
    }

    private void LoadSoundInstance(String SoundFilePath, out SoundEffect Sound, out SoundEffectInstance SoundInstance)
    {
        // For error checking, assume we'll fail to load the file.
        Sound = null;
        SoundInstance = null;

        try
        {
            LoadSound(SoundFilePath, out Sound);
            SoundInstance = Sound.CreateInstance();
        }
        catch (NullReferenceException)
        {
            // Display an error message
            MessageBox.Show("Couldn't load sound instance " + SoundFilePath);
        }
    }

遊びだけで使用しています。

   public void PlaySound(SoundEffectInstance sound)
    {
        sound.Play();
    }

同じサウンドの再生中に PlaySound メソッドを呼び出すと、新しいサウンドは再生されません。

4

0 に答える 0