private void OnDeviceConnected() { var deviceChannels = _currentDevice.Channels .Where(x => x.Type == ChannelType.Signal) .ToDictionary(channelInfo => channelInfo.Name, channelInfo => new EegChannel(_currentDevice, channelInfo)); if (deviceChannels.ContainsKey("T3") && deviceChannels.ContainsKey("O1")) { T3O1SpectrumChannel = new SpectrumChannel(new BipolarDoubleChannel(deviceChannels["T3"], deviceChannels["O1"])); if (deviceChannels.ContainsKey("T4") && deviceChannels.ContainsKey("O2")) { T4O2SpectrumChannel = new SpectrumChannel(new BipolarDoubleChannel(deviceChannels["T4"], deviceChannels["O2"])); IndexChannel = new EegIndexChannel(deviceChannels["T3"], deviceChannels["T4"], deviceChannels["O1"], deviceChannels["O2"]); ChannelsChanged?.Invoke(this, null); } } }
private void OnDeviceConnected() { BatteryChannel = new BatteryChannel(_currentDevice); var deviceChannels = _currentDevice.Channels .Where(x => x.Type == ChannelType.Signal) .ToDictionary(channelInfo => channelInfo.Name, channelInfo => new EegChannel(_currentDevice, channelInfo)); if (deviceChannels.ContainsKey("T3") && deviceChannels.ContainsKey("O1")) { T3O1SignalChannel = new BipolarDoubleChannel(deviceChannels["T3"], deviceChannels["O1"]); T3O1SpectrumChannel = new SpectrumChannel(T3O1SignalChannel); if (deviceChannels.ContainsKey("T4") && deviceChannels.ContainsKey("O2")) { T4O21SignalChannel = new BipolarDoubleChannel(deviceChannels["T4"], deviceChannels["O2"]); T4O2SpectrumChannel = new SpectrumChannel(T4O21SignalChannel); IndexChannel = new EegIndexChannel(deviceChannels["T3"], deviceChannels["T4"], deviceChannels["O1"], deviceChannels["O2"]); IndexChannel.SetWeights(1.00, 1.00, 0.00, 0.00); IndexChannel.Delay = 0.0; IndexViewChannel = new EegIndexChannel(deviceChannels["T3"], deviceChannels["T4"], deviceChannels["O1"], deviceChannels["O2"]); IndexViewChannel.SetWeights(1.00, 1.00, 0.00, 1.00); IndexViewChannel.Delay = 0.0; AlphaLeftPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> { T3O1SpectrumChannel }, 8, 14, "AlphaLeft"); BetaLeftPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> { T3O1SpectrumChannel }, 14, 34, "BetaLeft"); AlphaRightPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> { T4O2SpectrumChannel }, 8, 14, "AlphaRight"); BetaRightPowerChannel = new SpectrumPowerChannel(new List <SpectrumChannel> { T4O2SpectrumChannel }, 14, 34, "BetaRight"); ChannelsChanged?.Invoke(this, null); } } }
public WrapperSpectrumPlayer(CSCorePlayer player, SpectrumChannel channel, ICollection <EventHandler <SingleBlockReadEventArgs> > inputStreamList) { this.player = player; this.player.PropertyChanged += (_, __) => PropertyChanged(_, __); this.soundOut = player.soundOut; fftProvider = new FftProvider(2, FftSize.Fft1024); if (channel != SpectrumChannel.Stereo) { if (channel == SpectrumChannel.Left) { if (this.player.notificationSource != null) { this.player.notificationSource.SingleBlockRead += InputStream_LeftSample; } inputStreamList.Add(InputStream_LeftSample); } if (channel == SpectrumChannel.Right) { if (this.player.notificationSource != null) { this.player.notificationSource.SingleBlockRead += InputStream_RightSample; } inputStreamList.Add(InputStream_RightSample); } } else { if (this.player.notificationSource != null) { this.player.notificationSource.SingleBlockRead += InputStream_Sample; } inputStreamList.Add(InputStream_Sample); } }
public SpectrumModel(SpectrumChannel spectrumChannel) { _spectrumChannel = spectrumChannel; WindowDuration = 8; Spectrum = new Spectrum("", new double[1024]); _calculationTask = () => { try { CalculateSpectrum(); } catch (Exception e) { Console.WriteLine(e.Message); } if (!_stopTask) { Thread.Sleep(50); } if (!_stopTask) { Task.Run(_calculationTask); } }; Task.Run(_calculationTask); }
public void SetChannels(SpectrumChannel channel) { _spectrumChannel = channel; }
public ISpectrumPlayer GetWrapperSpectrumPlayer(SpectrumChannel channel) { return(new WrapperSpectrumPlayer(instance, channel, inputStreamList)); }