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