2012-10-23 50 views
0

我在Windows应用商店应用程序中使用SharpDX和XAudio2。我试图创建一个自定义的XAPO,我甚至无法开始。在Windows 8应用程序中使用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) 
    { 
    } 
} 

如果我删除线,以使效果则空过程方法永远不会运行。如果我把它在,会出现以下错误没用:

The Error I receive

回答

0

这竟然是与SharpDX执行的问题。见Issue 272的SharpDX谷歌代码页:

问题:的错误同时防止影响和SubMixVoices不 工作。

文件: Voice.cs

原因:的EffectChain // SendList总是被通过函数调用设定 后resetet。这两种情况都是由于缺少围绕 的下列行引起的:

SetOutputVoices((VoiceSendDescriptors?)null);在功能 SetOutputVoices

SetEffectChain((EffectChain)空?); in功能SetEffectChain

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

+0

嗨..我知道这是一个古老的线程,但我有点Stucked实施'过程'方法。你可以举一个例子来说明如何使用'inputProcessParameters'和'outputProcessParameters'? – bitWorking

+0

好吧,有..其他人感兴趣:例如[ModulatorEffect.cs](https://github.com/sharpdx/SharpDX-Samples/blob/master/WindowsDesktop/XAudio2/PlaySoundCustomXAPO/ModulatorEffect.cs) – bitWorking

相关问题