2012-10-23 71 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

相關問題