【问题标题】:SharpDX / XAudio2 : Sending a SourceVoice through a SubmixVoiceSharpDX / XAudio2:通过 SubmixVoice 发送 SourceVoice
【发布时间】:2013-05-28 11:13:24
【问题描述】:

我想不通,如何通过 Submixvoice 路由 SourceVoice?网上的 C++ 示例建议我可以使用效果链,但是没有 EffectChain 构造函数或接受声音的函数。以下是基础知识:

private XAudio2 xa = null;
    private MasteringVoice mv = null;
    private SourceVoice sv = null;
    private SubmixVoice sm = null;
    private SoundStream ss = null;
    private AudioBuffer ab = null;
    private WaveFormat wf = null;
    private FilterParameters fp;
    private bool sv_playing = false;

    private void button1_Click(object sender, EventArgs e)
    {

        if (null == xa)
        {
            xa = new XAudio2();

            mv = new MasteringVoice(xa);

            var nativefilestream = new NativeFileStream(
                @"c:\dev\beat_loop.wav",
                NativeFileMode.Open,
                NativeFileAccess.Read,
                NativeFileShare.Read);

            ss = new SoundStream(nativefilestream);
            wf = ss.Format;

            ab = new AudioBuffer
            {
                Stream = ss.ToDataStream(),
                AudioBytes = (int)ss.Length,
                Flags = BufferFlags.EndOfStream
            };

            fp.Frequency = 1.0f;
            fp.OneOverQ = 1.0f;
            fp.Type = FilterType.LowPassFilter;

        }

        if (sv_playing)
        {
            if (null != sv)
            {
                sv.Stop();
                sv.Dispose();
                sv = null;
            }
        }

        if (null == sv)
        {
            sv = new SourceVoice(xa, wf,VoiceFlags.None,1.0f, true);

            sv.SubmitSourceBuffer(ab, ss.DecodedPacketsInfo);

            sv.BufferEnd += new Action<IntPtr>(sv_BufferEnd);


            sm = new SubmixVoice(xa, ss.Format.Channels, ss.Format.SampleRate, VoiceSendFlags.UseFilter,10);
            sm.SetFilterParameters(fp);


            // HOW DO I TELL sv TO ROUTE THROUGH sm??

            sv.Start();
            sv_playing = true;
        }
    }

【问题讨论】:

    标签: sharpdx xaudio2


    【解决方案1】:

    您可以使用 VoiceSendDescriptor 类将源声音路由到子混合声音

    VoiceSendDescriptor vs = new VoiceSendDescriptor(VoiceSendFlags.None, sm);
    sv.SetOutputVoices(vs);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多