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)
{
}
}
如果我刪除線,以使效果則空過程方法永遠不會運行。如果我把它在,會出現以下錯誤沒用:
嗨..我知道這是一個古老的線程,但我有點Stucked實施'過程'方法。你可以舉一個例子來說明如何使用'inputProcessParameters'和'outputProcessParameters'? – bitWorking
好吧,有..其他人感興趣:例如[ModulatorEffect.cs](https://github.com/sharpdx/SharpDX-Samples/blob/master/WindowsDesktop/XAudio2/PlaySoundCustomXAPO/ModulatorEffect.cs) – bitWorking