Question

Depuis quelques jours, j'essaye de créer un égaliseur en C#.J'ai vu NAudio assez longtemps, mais je n'ai trouvé aucun égaliseur fonctionnel qui fonctionnerait avec naudio.Maintenant, après quelques jours, je suis enfin là @stackoverflow et j'espère que vous connaissez un moyen de créer un égaliseur en utilisant c#.

PS :J'ai également essayé System.Media.SoundPlayer.Mais ce SoundPlayer ne prend même pas en charge tout ce qui a trait au DSP.Alors, existe-t-il une autre bibliothèque audio qui fonctionne avec de l'audio « pur » à l'extérieur ?

Était-ce utile?

La solution

Alors, existe-t-il une autre bibliothèque audio qui fonctionne avec de l'audio « pur » à l'extérieur ?

Oui il y en a un: https://cscore.codeplex.com

Selon le ÉgaliseurÉchantillon, vous pouvez utiliser l'égaliseur comme ça :

using CSCore;
using CSCore.Codecs;
using CSCore.SoundOut;
using CSCore.Streams;
using System;
using System.Threading;

...

private static void Main(string[] args)
{
    const string filename = @"C:\Temp\test.mp3";
    EventWaitHandle waitHandle = new AutoResetEvent(false);

    try
    {
        //create a source which provides audio data
        using(var source = CodecFactory.Instance.GetCodec(filename))
        {
            //create the equalizer.
            //You can create a custom eq with any bands you want, or you can just use the default 10 band eq.
            Equalizer equalizer = Equalizer.Create10BandEqualizer(source);

            //create a soundout to play the source
            ISoundOut soundOut;
            if(WasapiOut.IsSupportedOnCurrentPlatform)
            {
                soundOut = new WasapiOut();
            }
            else
            {
                soundOut = new DirectSoundOut();
            }

            soundOut.Stopped += (s, e) => waitHandle.Set();

            IWaveSource finalSource = equalizer.ToWaveSource(16); //since the equalizer is a samplesource, you have to convert it to a raw wavesource
            soundOut.Initialize(finalSource); //initialize the soundOut with the previously created finalSource
            soundOut.Play();

            /*
             * You can change the filter configuration of the equalizer at any time.
             */
            equalizer.SampleFilters[0].SetGain(20); //eq set the gain of the first filter to 20dB (if needed, you can set the gain value for each channel of the source individually)

            //wait until the playback finished
            //of course that is optional
            waitHandle.WaitOne();

            //remember to dispose and the soundout and the source
            soundOut.Dispose();
        }
    }
    catch(NotSupportedException ex)
    {
        Console.WriteLine("Fileformat not supported: " + ex.Message);
    }
    catch(Exception ex)
    {
        Console.WriteLine("Unexpected exception: " + ex.Message);
    }
}

Vous pouvez configurer l'égaliseur comme vous le souhaitez.Et comme il fonctionne à 100 % en temps réel, toutes les modifications sont appliquées instantanément.Si nécessaire, il existe également la possibilité d'accéder à la modification de chaque canal séparément.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top