public OneEuroFilter(double minCutoff, double beta) { firstTime = true; this.minCutoff = minCutoff; this.beta = beta; xFilt = new LowpassFilter(); dxFilt = new LowpassFilter(); dcutoff = 1; }
static void Filter() { var mic = new Mic(); var lowpassFilter = new LowpassFilter(); var equalizer = new Equalizer(); var highpassFilter = new HighpassFilter(); var speaker = new Speaker(); var cable1 = new Cable(); var cable2 = new Cable(); var cable3 = new Cable(); var cable4 = new Cable(); mic.OutputJacks[0].Connect(cable1); lowpassFilter.InputJacks[0].Connect(cable1); lowpassFilter.OutputJacks[0].Connect(cable2); equalizer.InputJacks[0].Connect(cable2); equalizer.OutputJacks[0].Connect(cable3); highpassFilter.InputJacks[0].Connect(cable3); highpassFilter.OutputJacks[0].Connect(cable4); speaker.InputJacks[0].Connect(cable4); mic.TurnOn(); speaker.TurnOn(); foreach (Equalizer.Frequencies frequency in Enum.GetValues(typeof(Equalizer.Frequencies))) { equalizer.SetFilter(frequency, 16); } while (true) { Console.ReadLine(); } }
public AudioProcessor(Publisher publisher, string outlet = null) { using WasapiCapture capture = new WasapiLoopbackCapture(CAPTURE_LATENCY); capture.Initialize(); channelNum = capture.WaveFormat.Channels; systemSampleRate = capture.WaveFormat.SampleRate; using SoundInSource captureSource = new SoundInSource(capture) { FillWithZeros = false }; using SimpleNotificationSource notificationSource = new SimpleNotificationSource(FluentExtensions.ToSampleSource(captureSource)) { Interval = PROCESS_WINDOW_LENGTH }; InitializeMonoBuffers(monoBuffers, channelNum, notificationSource.BlockCount); blockBuffer = new float[notificationSource.BlockCount * channelNum]; lpf = new LowpassFilter(systemSampleRate, LFE_CUTOFF); MonoPulseDetector = new SimplePulseDetector(monoBuffers, lfeProvided: false, biQuadFilter: lpf); localisationer = new Localisationer(monoBuffers); if (channelNum > 2) { LFEPulseDetector = new SimplePulseDetector(monoBuffers, lfeProvided: true); } capture.DataAvailable += (s, e) => { while (notificationSource.Read(blockBuffer, 0, notificationSource.BlockCount * channelNum) > 0) { monoBuffers = Deinterlacing(monoBuffers, blockBuffer, channelNum); if (LFEPulseDetector != null) { bool m = MonoPulseDetector.Predict(); bool l = LFEPulseDetector.Predict(); if (m || l) { double angle = localisationer.GetLoudestAngle(); #if DEBUG Console.Clear(); Console.WriteLine($"LFE Level: {LFEPulseDetector.CurrentReading:F3}, LFE Threshold: {LFEPulseDetector.CurrentThreshold:F3}"); Console.WriteLine($"Mixed Level: {MonoPulseDetector.CurrentReading:F3}, Mixed Threshold: {MonoPulseDetector.CurrentThreshold:F3}"); Console.WriteLine($"Impulse Detected - Mono:{m}, LFE:{l}, Angle: {angle:F3}, Hit Count:{hitCount}"); #endif if (publisher != null && outlet != null) { publisher.Publish(outlet, $"{m}|{l}|{angle:F3}"); } hitCount++; } } else { if (MonoPulseDetector.Predict()) { double angle = localisationer.GetLoudestAngle(); #if DEBUG Console.Clear(); Console.WriteLine($"Level: {MonoPulseDetector.CurrentReading:F3}, Threshold: {MonoPulseDetector.CurrentThreshold:F3}"); Console.WriteLine($"Impulse Detected - Mono, Angle:{angle:F3}, Hit Count:{hitCount}"); #endif if (publisher != null && outlet != null) { publisher.Publish(outlet, $"True|False|{angle:F3}"); } hitCount++; } } } }; StartCapturingAndHold(capture); }
//constructor public Filters(double trendcutoff, double denoisecutoff, double tiltcutoff, double tiltpeakcutoff) { Trend = new LowpassFilter(trendcutoff); Denoise = new LowpassFilter(denoisecutoff); Tilt = new LowpassFilterCutoff(tiltcutoff, tiltpeakcutoff); }
public YM2608() { // γ«γγΌγ lpf = new LowpassFilter(SampleFreq); }