Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply the filters on the output devices #131

Closed
Mitra-M opened this issue Aug 10, 2016 · 6 comments
Closed

Apply the filters on the output devices #131

Mitra-M opened this issue Aug 10, 2016 · 6 comments
Labels

Comments

@Mitra-M
Copy link

Mitra-M commented Aug 10, 2016

Thank you very much for the implementation of the Lowpass, Highpass, Bandpass, and … filters.

Now ,I can apply the filters on the audio files, But I can not apply them on the output devices yet.

How can I do this?

@filoe
Copy link
Owner

filoe commented Aug 11, 2016

CSCore does not support creating custom audio driver effects. I'm sorry.

@filoe filoe added the question label Aug 11, 2016
@Mitra-M
Copy link
Author

Mitra-M commented Aug 12, 2016

I just want to get raw audio data from a device, and manipulate them, and then write them to the device.
I thought it might be possible.

Anyway, thank you.

@Mitra-M
Copy link
Author

Mitra-M commented Aug 15, 2016

1-get audio data from an input device
2-filter data (with/without saving data to a file)
3-write filtered data to an output device simultaneously

filoe, please tell me this is possible or not? (using cscore)

@filoe
Copy link
Owner

filoe commented Aug 15, 2016

Of course that is no problem.
Take a look at the following snippet, demonstrating the basic principle. Just copy paste it into a console app and call Foo():

static void Foo()
{
    //create a new soundIn instance for using input devices
    using (var soundIn = new WasapiCapture(true, AudioClientShareMode.Shared, 30))
    {
        //important: always initialize the soundIn instance before creating the
        //SoundInSource. The SoundInSource needs the WaveFormat of the soundIn,
        //which gets determined by the soundIn.Initialize method.
        soundIn.Initialize();

        //wrap a sound source around the soundIn instance
        //in order to prevent playback interruptions, set FillWithZeros to true
        //otherwise, if the SoundIn does not provide enough data, the playback stops
        IWaveSource source = new SoundInSource(soundIn) {FillWithZeros = true};

        //wrap a EchoEffect around the previously created "source"
        //note: disposing the echoSource will also dispose 
        //the previously created "source"
        using (var echoSource = new DmoEchoEffect(source))
        {
            //start capturing data
            soundIn.Start();

            //create a soundOut instance to play the data
            using (var soundOut = new WasapiOut())
            {
                //initialize the soundOut with the echoSource
                //the echoSource provides data from the "source" and applies the echo effect
                //the "source" provides data from the "soundIn" instance
                soundOut.Initialize(echoSource);

                //play
                soundOut.Play();

                Console.ReadKey();
            }
        }
    }
}

@Mitra-M
Copy link
Author

Mitra-M commented Aug 15, 2016

Excellent and perfect.
Wow , I think the cscore has the best and the fastest support in the world.

Thank you so much!

@filoe
Copy link
Owner

filoe commented Aug 21, 2016

Glad to hear that.

@filoe filoe closed this as completed Aug 21, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants