Звук с эквалайзером [закрыто]
Вопрос
Уже несколько дней я пытаюсь создать эквалайзер с помощью C#.Смотрел NAudio довольно много времени, но так и не смог найти ни одного работающего эквалайзера, который бы работал с naudio.Теперь, спустя несколько дней, я наконец-то здесь, @stackoverflow, и, надеюсь, вы знаете, как создать эквалайзер с помощью C#.
ПС:Я также опробовал System.Media.SoundPlayer.Но этот SoundPlayer даже не поддерживает ничего, что связано с dsp.Итак, есть ли еще одна аудиобиблиотека, которая работает с «чистым» звуком снаружи?
Решение
Так есть другая аудио библиотека, которая работает с «чистым» аудио на улице?
Да есть один: https://cscore.codeplex.com
Согласно CrustizerSampample , вы можете использовать эквалайзерТаким образом:
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);
}
}
.
Вы можете настроить эквалайзер к тому, что вы хотите.И поскольку он работает на 100% в реальном времени, все изменения прилагаются мгновенно.При необходимости также есть возможность доступа к модификации каждого канала отдельно.