public bool UpdateVoiceInputDevice(string device)
        {
            if (string.IsNullOrEmpty(device))
            {
                return(false);
            }

            if (targetInputDevice is not null && targetInputDevice.FriendlyName == device)
            {
                //Tried to set to current device
                return(true);
            }

            MMDevice newInputDevice = GetInputDevice(device);

            if (newInputDevice is null)
            {
                //Device not found
                return(false);
            }

            CleanUpActiveStream();

            //Switch devices
            targetInputDevice?.Dispose();
            targetInputDevice = newInputDevice;

            ResetVoiceStream();

            return(true);
        }
Exemplo n.º 2
0
        public void Dispose()
        {
            foreach (var session in _sessions.Values)
            {
                session.SessionEnded  -= OnSessionEnded;
                session.VolumeChanged -= OnSessionVolumeChanged;
                session.Dispose();
            }

            _sessions.Clear();

            _callback.NotifyRecived        -= OnEndpointVolumeChanged;
            _sessionManager.SessionCreated -= OnSessionCreated;

            _endpointVolume?.UnregisterControlChangeNotify(_callback);
            _endpointVolume?.Dispose();
            _endpointVolume = null;
            _callback       = null;

            _sessionManager?.Dispose();
            _sessionManager = null;

            _device?.Dispose();
            _device = null;
        }
Exemplo n.º 3
0
        /// <summary>
        /// フェードアウトを実行するタスク
        /// </summary>
        private void FadeOutThread()
        {
            //自分自身のプロセスを取得する
            System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
            int pid = p.Id;

            MMDevice device = null;

            try
            {
                using (MMDeviceEnumerator DevEnum = new MMDeviceEnumerator())
                {
                    device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                }
                AudioSessionManager sessionManager = device.AudioSessionManager;
                for (float i = 100; i >= 0; i -= 1f)
                {
                    foreach (var item in sessionManager.Sessions)
                    {
                        if (item.ProcessID != (uint)pid)
                        {
                            item.SimpleAudioVolume.MasterVolume = (i / 100.0f);
                        }
                    }
                    Thread.Sleep(100);
                }
            }
            finally
            {
                if (device != null)
                {
                    device.Dispose();
                }
            }
        }
Exemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            endpointVolume.Dispose();
            device.Dispose();

            base.Dispose(disposing);
        }
Exemplo n.º 5
0
        /// <inheritdoc />
        public override bool CheckForChanges()
        {
            using (var enumer = new MMDeviceEnumerator())
            {
                var outputList    = enumer.EnumerateAudioEndPoints(DataFlow.Render, DeviceState.Active).ToList();
                var output        = enumer.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
                var inputList     = enumer.EnumerateAudioEndPoints(DataFlow.Capture, DeviceState.Active).ToList();
                var input         = enumer.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Communications);
                var changedOutput = Set(ref _outputDevice, output.FriendlyName);
                var changedInput  = Set(ref _inputDevice, input.FriendlyName);
                var changes       = new[]
                {
                    changedOutput,
                    Set(ref _outputVolume, (int)(output.AudioEndpointVolume.MasterVolumeLevelScalar * 100)),
                    Set(ref _outputIsMuted, output.AudioEndpointVolume.Mute),
                    SetList(ref _outputDeviceList, outputList.Select(x => x.FriendlyName)),

                    changedInput,
                    Set(ref _inputVolume, (int)(input.AudioEndpointVolume.MasterVolumeLevelScalar * 100)),
                    Set(ref _inputIsMuted, output.AudioEndpointVolume.Mute),
                    SetList(ref _inputDeviceList, inputList.Select(x => x.FriendlyName)),
                };

                if (!changes.Any(x => x))
                {
                    return(false);
                }

                if (changedOutput)
                {
                    if (_output != null)
                    {
                        _output.AudioEndpointVolume.OnVolumeNotification -= OutputOnOnVolumeNotification;
                    }
                    _output?.Dispose();
                    _output = output;
                    if (_output != null)
                    {
                        _output.AudioEndpointVolume.OnVolumeNotification += OutputOnOnVolumeNotification;
                    }
                }

                if (changedInput)
                {
                    if (_input != null)
                    {
                        _input.AudioEndpointVolume.OnVolumeNotification -= InputOnOnVolumeNotification;
                    }
                    _input?.Dispose();
                    _input = input;
                    if (_input != null)
                    {
                        _input.AudioEndpointVolume.OnVolumeNotification += InputOnOnVolumeNotification;
                    }
                }
            }

            RaiseChanged();
            return(true);
        }
Exemplo n.º 6
0
        /// <summary>
        /// ウマ娘ウィンドウの音量が0になって再び0以上になるまで待機します。
        /// </summary>
        /// <param name="timeOutMillisecond">タイムアウト時間ミリ秒</param>
        private void WaitUmaWindowAvailable(Process process, int timeOutMillisecond)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            MMDevice device = null;

            try
            {
                //ウマ娘セッションの検索
                AudioSessionControl umamusumeSession = null;
                while (umamusumeSession == null)
                {
                    using (MMDeviceEnumerator DevEnum = new MMDeviceEnumerator())
                    {
                        device?.Dispose();
                        device = DevEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
                    }
                    AudioSessionManager sessionManager = device.AudioSessionManager;
                    var sessions = sessionManager.Sessions;
                    for (int j = 0; j < sessions.Count; j++)
                    {
                        if (sessions[j].GetProcessID == process.Id)
                        {
                            umamusumeSession = sessions[j];
                            break;
                        }
                    }
                }

                //0になるまで待機(0以外の間ループ)
                while (umamusumeSession.AudioMeterInformation.MasterPeakValue > 0.005)
                {
                    Thread.Sleep(10);
                    if (stopwatch.ElapsedMilliseconds > timeOutMillisecond)
                    {
                        return;
                    }
                }

                //0以上になるまで待機(0の間ループ)
                while (umamusumeSession.AudioMeterInformation.MasterPeakValue < 0.1)
                {
                    Thread.Sleep(10);
                    if (stopwatch.ElapsedMilliseconds > timeOutMillisecond)
                    {
                        return;
                    }
                }
            }
            finally
            {
                if (device != null)
                {
                    device.Dispose();
                }
            }
        }
Exemplo n.º 7
0
 private void disposeDevice(MMDevice device)
 {
     if (device != null)
     {
         device.AudioEndpointVolume.Dispose();
         device.Dispose();
     }
 }
 public void Dispose()
 {
     if (_Device != null)
     {
         _Device.AudioEndpointVolume.OnVolumeNotification -= AudioEndpointVolume_OnVolumeNotification;
         _Device.Dispose();
         _Device = null;
     }
 }
        private void FreePlaybackDevice()
        {
            string disposingPlaybackDeviceFriendlyName = _playbackDevice?.FriendlyName ?? "Unknown";

            _audioEndpointVolume?.Dispose();
            _playbackDevice?.Dispose();
            _playbackDevice = null;
            _logger.Information(string.Format("Playback device {0} unregistered as source device to fill Playback volume data model", disposingPlaybackDeviceFriendlyName));
        }
Exemplo n.º 10
0
        private static void DisposeDevice(MMDevice device)
        {
            if (device == null)
            {
                return;
            }

            device.AudioEndpointVolume.Dispose();
            device.Dispose();
        }
Exemplo n.º 11
0
        private void OutputDeviceStop()
        {
            if (play_device_ == null)
            {
                return;
            }

            play_device_.Dispose();
            play_device_ = null;
        }
Exemplo n.º 12
0
        public void Dispose()
        {
            // Don't dispose the enumerator as it is part of a service and have to be alive
            // while the Plugin is enabled.
            _capture?.Dispose();
            _endpoint?.Dispose();

            _capture  = null;
            _endpoint = null;
        }
Exemplo n.º 13
0
        public void Dispose()
        {
            // Client up our MM objects in reverse order
            if (iAudioEndpointVolumeMixerCallback != null && iAudioEndpointVolume != null)
            {
                iAudioEndpointVolume.UnregisterControlChangeNotify(iAudioEndpointVolumeMixerCallback);
            }

            if (iAudioEndpointVolumeMixerCallback != null)
            {
                iAudioEndpointVolumeMixerCallback.NotifyRecived -= iVolumeChangedHandler;
                iAudioEndpointVolumeMixerCallback = null;
            }

            if (iAudioEndpointVolume != null)
            {
                iAudioEndpointVolume.Dispose();
                iAudioEndpointVolume = null;
            }

            if (_mMdevice != null)
            {
                _mMdevice.Dispose();
                _mMdevice = null;
            }

            if (iMultiMediaNotificationClient != null)
            {
                iMultiMediaNotificationClient.DefaultDeviceChanged -= iDefaultDeviceChangedHandler;
                iMultiMediaNotificationClient.Dispose();
                iMultiMediaNotificationClient = null;
            }

            if (_mMdeviceEnumerator != null)
            {
                _mMdeviceEnumerator.Dispose();
                _mMdeviceEnumerator = null;
            }
            Stop();
            Close();
        }
Exemplo n.º 14
0
        public void Dispose()
        {
            if (!_disposing)
            {
                _disposing = true;

                _capture?.Dispose();
                _inputDevice?.Dispose();

                _localOutput?.Dispose();
                _localOutput = null;
            }
        }
Exemplo n.º 15
0
 private static AudioSessionManager2 GetDefaultAudioSessionManager2(
     DataFlow dataFlow)
 {
     using (MMDeviceEnumerator deviceEnumerator = new MMDeviceEnumerator())
     {
         using (MMDevice defaultAudioEndpoint = deviceEnumerator.GetDefaultAudioEndpoint(dataFlow, Role.Multimedia))
         {
             AudioSessionManager2 audioSessionManager2 = AudioSessionManager2.FromMMDevice(defaultAudioEndpoint);
             deviceEnumerator.Dispose();
             defaultAudioEndpoint.Dispose();
             return(audioSessionManager2);
         }
     }
 }
Exemplo n.º 16
0
        static void Main(string[] args)
        {
            //自分自身のプロセスを取得する
            System.Diagnostics.Process p = System.Diagnostics.Process.GetCurrentProcess();
            int pid = p.Id;

            MMDevice device = null;

            try
            {
                using (MMDeviceEnumerator DevEnum = new MMDeviceEnumerator())
                {
                    device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
                }
                float MasterVolumeLevel            = device.AudioEndpointVolume.MasterVolumeLevelScalar;
                AudioSessionManager sessionManager = device.AudioSessionManager;
                for (float i = 100; i >= 0; i -= 1f)
                {
                    foreach (var item in sessionManager.Sessions)
                    {
                        if (item.ProcessID != (uint)pid)
                        {
                            item.SimpleAudioVolume.MasterVolume = ((float)i / 100.0f);
                        }
                    }
                    System.Threading.Thread.Sleep(50);
                }
                //元の音量に戻す
                foreach (var item in sessionManager.Sessions)
                {
                    if (item.ProcessID != (uint)pid)
                    {
                        item.SimpleAudioVolume.MasterVolume = ((float)100 / 100.0f);
                    }
                }
                device.AudioEndpointVolume.MasterVolumeLevelScalar = MasterVolumeLevel;
            }
            finally
            {
                //後処理
                if (device != null)
                {
                    device.Dispose();
                }
            }
        }
Exemplo n.º 17
0
        private void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }

            if (disposing)
            {
                _defaultEndpointVolumeController.AudioEndpointVolume.OnVolumeNotification -=
                    AudioEndpointVolume_OnVolumeNotification;
                _defaultEndpointVolumeController.Dispose();
                AudioMMDevices.Dispose();
                AudioMMDevices = null;
            }

            _disposed = true;
        }
Exemplo n.º 18
0
        private void CheckForDeviceChange()
        {
            MMDevice current_device = audio_device_enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

            if (((WasapiLoopbackCapture)waveIn)?.CaptureState == CaptureState.Stopped ||
                default_device == null ||
                default_device.ID != current_device.ID ||
                (((WasapiLoopbackCapture)waveIn)?.CaptureState != CaptureState.Capturing && (Time.GetSecondsSinceEpoch() - startTime) > 20))    //Check if it has taken over 20 seconds to start the capture which may indicate that there has been an issue
            {
                Global.logger.LogLine($"CaptureState is {((WasapiLoopbackCapture)waveIn)?.CaptureState}");
                UpdateAudioCapture(current_device);
            }
            else
            {
                current_device.Dispose();
            }

            current_device = null;
        }
Exemplo n.º 19
0
        protected virtual void Dispose(bool cleanup)
        {
            if (disposed)
            {
                return;
            }

            if (cleanup)
            {
                socket?.Dispose();
                audioIeee?.Dispose();
                inFileWriter?.Dispose();
                outFileWriter?.Dispose();
                capture?.Dispose();
                device?.Dispose();
            }

            disposed = true;
        }
Exemplo n.º 20
0
        private void UpdateAudioCapture(MMDevice defaultDevice)
        {
            if (waveIn != null)
            {
                waveIn.StopRecording();
                waveIn.Dispose();
            }

            default_device?.Dispose();
            default_device = defaultDevice;

            // Here you decide what you want to use as the waveIn.
            // There are many options in NAudio and you can use other streams/files.
            // Note that the code varies for each different source.
            waveIn = new WasapiLoopbackCapture(default_device);

            waveIn.DataAvailable += OnDataAvailable;

            waveIn.StartRecording();
        }
Exemplo n.º 21
0
        private void CleanUp()
        {
            logger.Debug("AudioSource::CleanUp()");

            if (captureDevice != null)
            {
                captureDevice.Dispose();
                captureDevice = null;
            }

            if (audioClient != null)
            {
                audioClient.Dispose();
                audioClient = null;
            }

            if (frameEventWaitHandle != null)
            {
                frameEventWaitHandle.Dispose();
                frameEventWaitHandle = null;
            }
        }
Exemplo n.º 22
0
        private void buttonAudioSetup_Click(object sender, EventArgs e)
        {
            try
            {
                MMDevice device = null;

                var deviceEnum = new MMDeviceEnumerator();
                if (deviceEnum.HasDefaultAudioEndpoint(DataFlow.Render, Role.Console))
                {
                    device = deviceEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Console);
                }

                string deviceId = device.ID;
                NAudio.Wave.WaveFormat deviceFormat = device.AudioClient.MixFormat;

                device.Dispose();

                signalGenerator = new SignalGenerator(16000, 2);
                var signalFormat = signalGenerator.WaveFormat;

                audioRenderer = new MfAudioRenderer();
                AudioRendererArgs audioArgs = new AudioRendererArgs
                {
                    DeviceId      = "",
                    SampleRate    = signalFormat.SampleRate,
                    BitsPerSample = signalFormat.BitsPerSample,
                    Encoding      = (WaveEncodingTag)signalFormat.Encoding,
                    Channels      = signalFormat.Channels,
                };

                audioRenderer.Setup(audioArgs);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }
Exemplo n.º 23
0
        public void Dispose()
        {
            channelMemoryA?.Clear();
            channelMemoryB?.Clear();

            channelWriterA?.Dispose();
            channelWriterB?.Dispose();

            channelStreamA?.Dispose();
            channelStreamB?.Dispose();

            channelCapture?.Dispose();
            channelDevice?.Dispose();

            deviceList?.ForEach(device => device.Dispose());
            deviceList?.Clear();

            fileTimer?.Stop();
            fileTimer?.Dispose();

            propertiesWindow?.Dispose();

            GC.SuppressFinalize(this);
        }
Exemplo n.º 24
0
 public void Dispose()
 {
     Recorder?.Dispose();
     _mmDevice?.Dispose();
 }
Exemplo n.º 25
0
 public void Dispose()
 {
     _capture.Dispose();
     _renderFix?.Dispose();
     Device.Dispose();
 }
Exemplo n.º 26
0
        static void Main(string[] args)
        {
            MMDevice device = null;

            try
            {
                //ウマ娘セッションの検索
                using (MMDeviceEnumerator DevEnum = new MMDeviceEnumerator())
                {
                    device = DevEnum.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
                }
                //master情報
                Console.WriteLine("FriendlyName:" + device.FriendlyName);
                Console.WriteLine("DeviceFriendlyName:" + device.DeviceFriendlyName);
                Console.WriteLine("IconPathRaw:" + Environment.ExpandEnvironmentVariables(device.IconPath));

                //アイコンパス文字列の取得
                string[] iconPathSplited = device.IconPath.Split(',');
                if (iconPathSplited.Length >= 2)
                {
                    string expandPath = Environment.ExpandEnvironmentVariables(iconPathSplited.First());
                    int    IDraw      = int.Parse(iconPathSplited.Last());
                    uint   ID         = (uint)Math.Abs(IDraw);
                    Console.WriteLine("IconPath:" + GetStringFromDll(expandPath, ID));
                    int err = Marshal.GetLastWin32Error();
                }

                Console.WriteLine("");

                AudioSessionManager sessionManager = device.AudioSessionManager;
                var sessions = sessionManager.Sessions;
                for (int j = 0; j < sessions.Count; j++)
                {
                    if (string.IsNullOrEmpty(sessions[j].DisplayName))
                    {
                        AudioSessionControl aaa = sessions[j];
                        continue;
                    }
                    if (sessions[j].DisplayName.First() == '@')
                    {
                        string[] displayNameSplited = sessions[j].DisplayName.Split(',');
                        string   expandPath         = Environment.ExpandEnvironmentVariables(displayNameSplited.First().Substring(1));
                        int      IDraw = int.Parse(displayNameSplited.Last());
                        uint     ID    = (uint)Math.Abs(IDraw);
                        Console.WriteLine("DisplayName:" + GetStringFromDll(expandPath, ID));
                        int err = Marshal.GetLastWin32Error();
                    }
                    else
                    {
                        Console.WriteLine("DisplayName:" + sessions[j].DisplayName);
                    }

                    Console.WriteLine("IconPath:" + sessions[j].IconPath);
                    Console.WriteLine("");
                }
            }
            finally
            {
                if (device != null)
                {
                    device.Dispose();
                }
            }

            Console.Read();
        }
Exemplo n.º 27
0
 private void FinalizeAudioDevice()
 {
     audioDevice.AudioEndpointVolume.OnVolumeNotification -= AudioEndpointVolume_OnVolumeNotification;
     audioDevice.Dispose();
     logger.Info("Stopped monitoring the audio device.");
 }
Exemplo n.º 28
0
 public override void Disable()
 {
     _playbackDevice.Dispose();
 }
Exemplo n.º 29
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     _musicPlayer.Dispose();
     _audioDevice.Dispose();
     _audioDevice = null;
 }
Exemplo n.º 30
0
        public override EffectLayer Render(IGameState gamestate)
        {
            try
            {
                //if (current_device != null)
                //current_device.Dispose();
                MMDevice current_device = audio_device_enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

                if (((WasapiLoopbackCapture)waveIn)?.CaptureState == CaptureState.Stopped || default_device == null || default_device.ID != current_device.ID)
                {
                    UpdateAudioCapture(current_device);
                }
                else
                {
                    current_device.Dispose();
                }

                current_device = null;

                // The system sound as a value between 0.0 and 1.0
                float system_sound_normalized = default_device.AudioEndpointVolume.MasterVolumeLevelScalar;

                // Scale the Maximum amplitude with the system sound if enabled, so that at 100% volume the max_amp is unchanged.
                // Replaces all Properties.MaxAmplitude calls with the scaled value
                float scaled_max_amplitude = Properties.MaxAmplitude * (Properties.ScaleWithSystemVolume ? system_sound_normalized : 1);

                float[] freqs = Properties.Frequencies.ToArray(); //Defined Frequencies

                double[] freq_results = new double[freqs.Length];

                if (previous_freq_results == null || previous_freq_results.Length < freqs.Length)
                {
                    previous_freq_results = new float[freqs.Length];
                }

                //Maintain local copies of fft, to prevent data overwrite
                Complex[] _local_fft          = new List <Complex>(_ffts).ToArray();
                Complex[] _local_fft_previous = new List <Complex>(_ffts_prev).ToArray();

                EffectLayer equalizer_layer = new EffectLayer();

                if (Properties.DimBackgroundOnSound)
                {
                    bool hasSound = false;
                    foreach (var bin in _local_fft)
                    {
                        if (bin.X > 0.0005 || bin.X < -0.0005)
                        {
                            hasSound = true;
                            break;
                        }
                    }

                    if (hasSound)
                    {
                        equalizer_layer.Fill(Properties.DimColor);
                    }
                }

                using (Graphics g = equalizer_layer.GetGraphics())
                {
                    int wave_step_amount = _local_fft.Length / Effects.canvas_width;

                    switch (Properties.EQType)
                    {
                    case EqualizerType.Waveform:
                        for (int x = 0; x < Effects.canvas_width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                            g.DrawLine(new Pen(brush), x, Effects.canvas_height_center, x, Effects.canvas_height_center - fft_val / scaled_max_amplitude * 500.0f);
                        }
                        break;

                    case EqualizerType.Waveform_Bottom:
                        for (int x = 0; x < Effects.canvas_width; x++)
                        {
                            float fft_val = _local_fft.Length > x * wave_step_amount ? _local_fft[x * wave_step_amount].X : 0.0f;

                            Brush brush = GetBrush(fft_val, x, Effects.canvas_width);

                            g.DrawLine(new Pen(brush), x, Effects.canvas_height, x, Effects.canvas_height - Math.Abs(fft_val / scaled_max_amplitude) * 1000.0f);
                        }
                        break;

                    case EqualizerType.PowerBars:

                        //Perform FFT again to get frequencies
                        FastFourierTransform.FFT(false, (int)Math.Log(fftLength, 2.0), _local_fft);

                        while (flux_array.Count < freqs.Length)
                        {
                            flux_array.Add(0.0f);
                        }

                        int startF = 0;
                        int endF   = 0;

                        float threshhold = 300.0f;

                        for (int x = 0; x < freqs.Length - 1; x++)
                        {
                            startF = freqToBin(freqs[x]);
                            endF   = freqToBin(freqs[x + 1]);

                            float flux = 0.0f;

                            for (int j = startF; j <= endF; j++)
                            {
                                float curr_fft = (float)Math.Sqrt(_local_fft[j].X * _local_fft[j].X + _local_fft[j].Y * _local_fft[j].Y);
                                float prev_fft = (float)Math.Sqrt(_local_fft_previous[j].X * _local_fft_previous[j].X + _local_fft_previous[j].Y * _local_fft_previous[j].Y);

                                float value     = curr_fft - prev_fft;
                                float flux_calc = (value + Math.Abs(value)) / 2;
                                if (flux < flux_calc)
                                {
                                    flux = flux_calc;
                                }

                                flux = flux > threshhold ? 0.0f : flux;
                            }

                            flux_array[x] = flux;
                        }

                        //System.Diagnostics.Debug.WriteLine($"flux max: {flux_array.Max()}");

                        float bar_width = Effects.canvas_width / (float)(freqs.Length - 1);

                        for (int f_x = 0; f_x < freq_results.Length - 1; f_x++)
                        {
                            float fft_val = flux_array[f_x] / scaled_max_amplitude;

                            fft_val = Math.Min(1.0f, fft_val);

                            if (previous_freq_results[f_x] - fft_val > 0.10)
                            {
                                fft_val = previous_freq_results[f_x] - 0.15f;
                            }

                            float x      = f_x * bar_width;
                            float y      = Effects.canvas_height;
                            float width  = bar_width;
                            float height = fft_val * Effects.canvas_height;

                            previous_freq_results[f_x] = fft_val;

                            Brush brush = GetBrush(-(f_x % 2), f_x, freq_results.Length - 1);

                            g.FillRectangle(brush, x, y - height, width, height);
                        }

                        break;
                    }
                }

                var hander = NewLayerRender;
                if (hander != null)
                {
                    hander.Invoke(equalizer_layer.GetBitmap());
                }
                return(equalizer_layer);
            }
            catch (Exception exc)
            {
                Global.logger.Error("Error encountered in the Equalizer layer. Exception: " + exc.ToString());
                return(new EffectLayer());
            }
        }