【问题标题】:Getting a SharpDX XAudio2 custom XAPO working in Windows 8 app让 SharpDX XAudio2 自定义 XAPO 在 Windows 8 应用程序中工作
【发布时间】:2012-10-23 17:15:32
【问题描述】:

我在 Windows 应用商店应用程序中使用 SharpDX 和 XAudio2。我正在尝试创建自定义 XAPO,但我什至无法开始。

应用的 OnNavigatedTo 方法:

protected override void OnNavigatedTo(NavigationEventArgs e)
{
  XAudio2 engine = new XAudio2();
  MasteringVoice master = new MasteringVoice(engine);
  NativeFileStream fileStream = new NativeFileStream(@"Assets\sample.wav", NativeFileMode.Open, NativeFileAccess.Read);
  SoundStream soundStream = new SoundStream(fileStream);
  SourceVoice source = new SourceVoice(engine, soundStream.Format);
  AudioBuffer audioBuffer =  new AudioBuffer()
  {
    Stream = soundStream.ToDataStream(),
    AudioBytes = (int)soundStream.Length,
    Flags = SharpDX.XAudio2.BufferFlags.EndOfStream
  };

  EmptyEffect customEffect = new EmptyEffect();
  EffectDescriptor effectDescriptor = new EffectDescriptor(customEffect);
  source.SetEffectChain(effectDescriptor);
  source.EnableEffect(0);

  source.SubmitSourceBuffer(audioBuffer, soundStream.DecodedPacketsInfo);
  source.Start();
}

空的自定义 XAPO:

[StructLayout(LayoutKind.Sequential)]
public struct ModulatorParam
{
}

public class EmptyEffect : AudioProcessorBase<ModulatorParam>
{
  public EmptyEffect()
  {
    RegistrationProperties = new RegistrationProperties()
    {
      Clsid = Utilities.GetGuidFromType(typeof(EmptyEffect)),
      CopyrightInfo = "Copyright",
      FriendlyName = "Modulator",
      MaxInputBufferCount = 1,
      MaxOutputBufferCount = 1,
      MinInputBufferCount = 1,
      MinOutputBufferCount = 1,
      Flags = PropertyFlags.Default
    };
  }

public override void Process(BufferParameters[] inputProcessParameters, BufferParameters[] outputProcessParameters, bool isEnabled)
  {
  }
}

如果我删除该行以启用效果,那么空进程方法将永远不会运行。如果我保留它,则会出现以下无用的错误:

【问题讨论】:

    标签: c# windows-8 sharpdx xaudio2


    【解决方案1】:

    这原来是 SharpDX 实现的一个问题。请参阅 SharpDX Google 代码页面上的 Issue 272

    问题:这些错误阻止了 Effects 和 SubMixVoices 工作。

    文件: Voice.cs

    原因: EffectChain // SendList 在设置后总是被重置 通过函数调用。这两种情况都是由于缺少 else 周围引起的 以下几行:

    SetOutputVoices((VoiceSendDescriptors?)null);在功能上 设置输出声音

    SetEffectChain((EffectChain?)null);在函数 SetEffectChain

    通过下载包含此修复程序的最新源并从头开始构建二进制文件来解决。

    【讨论】:

    • 嗨..我知道这是一个旧线程,但我在实现 Process 方法时有点卡住了。能否举例说明如何使用inputProcessParametersoutputProcessParameters
    • 好的..其他人有兴趣:例如ModulatorEffect.cs
    猜你喜欢
    • 2012-09-29
    • 1970-01-01
    • 2015-03-23
    • 1970-01-01
    • 2011-10-25
    • 2011-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多