filoe / cscore

An advanced audio library, written in C#. Provides tons of features. From playing/recording audio to decoding/encoding audio streams/files to processing audio data in realtime (e.g. applying custom effects during playback, create visualizations,...). The possibilities are nearly unlimited.
Other
2.17k stars 450 forks source link

2 my problems with 3DSound (Xaudio2 + X3daudio) #169

Closed Mitra-M closed 6 years ago

Mitra-M commented 7 years ago

1 - I have made a simple InputPlayer using WasApi. and I want redirect the WasApi source to Xaudio2 and back it in runtime.

I tried this:

 ```
     source = new SoundInSource(soundIn) { FillWithZeros = true };
     soundOut = new WasapiOut(true, AudioClientShareMode.Shared, 1, ThreadPriority.Highest);
. . . . . 
 private void btnSwitchTo3D_Click(object sender, RoutedEventArgs e)
  {
         if (soundOut != null)
            {
                soundOut.Stop();
                 xaudio2 = XAudio2.CreateXAudio2();
                 masteringVoice = xaudio2.CreateMasteringVoice(2, 48000, selectedDevice.DevicePath);
                channelMask = masteringVoice.ChannelMask;
                _destinationChannels = masteringVoice.VoiceDetails.InputChannels;
                streamingSourceVoice = new StreamingSourceVoice(xaudio2,new InterruptDisposingChainWaveSource( source.ToWaveSource()));
              StreamingSourceVoiceListener.Default.Add(streamingSourceVoice);
              streamingSourceVoice.Start();
           }
    }
above code is working fine.

Now,I want to redirect (back) the `source` to the WasApi  :
 private void btnBackToWasapi_Click(object sender, RoutedEventArgs e)
  {
       if (streamingSourceVoice != null )
            {
                    streamingSourceVoice.Stop();
                    StreamingSourceVoiceListener.Default.Remove(streamingSourceVoice);
                    streamingSourceVoice.Dispose();
                    masteringVoice.Dispose();
                    xaudio2.Dispose(); 
                   soundOut.Play();
            }
     }


But the above code does not work sometimes, because the source is disposed.(sometimes)

I'v used `InterruptDisposingChainWaveSource` to prevent disposing but not affect.

Please tell me how to do that?

**2 -**  to simulate a real 3DSound we need to set  LPF and reverb in X3DAudio ,But there is not any good c# sample (I can't find at least) in the internet.

I found a great [XAudio2Sound3D sample](https://github.com/walbourn/directx-sdk-samples/tree/master/XAudio2/XAudio2Sound3D) in c++ (without using XAPO )  , that is what I need ,but I can't do that with cscore.

Please Please Please add a X3DAudio sample to do it or add LPF and reverb effects to X3DAudioSample.

Thank you in advance!
filoe commented 7 years ago

I've planed to add these missing features for a quite long time. I haven't forgot that yet. But currently there are some other priorities.

Mitra-M commented 7 years ago

Okay, I'm waiting.

And I pray that sooner reach the turn 3Dsound.

Thank you!

filoe commented 6 years ago

I'll close it for now. But it is marked as "open feature request". Hopefully we'll come back to this.

mrcoffeeee commented 3 years ago

Is this still planned? I would love to use effects in CSCore for XAudio2 too. Thats actually a real missing thing and would be great to get rid of SharpDX.

filoe commented 3 years ago

What exactly would you like to use? The effects and 3d audio are implemented in cscore.

Am 25.02.2021 um 08:38 schrieb mrcoffeeee notifications@github.com:

 Is this still planned? I would love to use effects in CSCore for XAudio2 too. Thats actually a real missing thing and would be great to get rid of SharpDX.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or unsubscribe.

mrcoffeeee commented 3 years ago

Sorry I misread the original post as I thought it covers that topic. But the Reverb from XAudio2.fx would be great as it offers a lot more parameters to edit. Do you plan to implement it some day?