public SoundEffectsControl() { // Required for Windows Form Designer support InitializeComponent(); if (IsDesignMode) { return; } Player = new AudioPlayer(Handle); Player.BeforePlay += Player_BeforePlay; CurrentPreset = null; SetDefaultValues(); Player.ChangeAudioDevice(); }
public PadControl(string audiodevice, float volume, string audioFilePath, int midiNote, MidiController?volumeSilderContr) { InitializeComponent(); int audiodeviceID = -1; int callbackdeviceID = -1; for (int i = 0; i < WaveOut.DeviceCount; i++) { if (WaveOut.GetCapabilities(i).ProductName == audiodevice) { audiodeviceID = i; } if (WaveOut.GetCapabilities(i).ProductName == ApplicationSettings.CallbackDeviceID) { callbackdeviceID = i; } } _player = new AudioPlayer("", callbackdeviceID); _player.OnSoundStateChange += _player_OnSoundStateChange; _player.OnAudioTrackChange += _player_OnAudioTrackChange; _player.ChangeAudioDevice(audiodeviceID); _player.ChangeAudioTrack(audioFilePath); ChangeVolume(Convert.ToInt32(volume * 100), false); this._pushButtonMidiNote = midiNote; if (this._pushButtonMidiNote != -1) { GlobalStaticContext.RegisterPadWithMidiNote(this, midiNote); } if (volumeSilderContr.HasValue) { this._volumeSliderMidiController = volumeSilderContr.Value; GlobalStaticContext.RegisterPadWithMidiController(this, volumeSilderContr.Value); } }
private void Wc_OnPacketArrival(object sender, CaptureEventArgs e) { if (Disposing || IsDisposed || !IsHandleCreated) { return; } if (e.Packet == null || e.Packet.Data == null || e.Packet.Data.Length == 0) { return; } if (e.Packet.LinkLayerType != LinkLayers.Ethernet) { return; } Packet packet = null; try { packet = Packet.ParsePacket(e.Packet.LinkLayerType, e.Packet.Data); } catch (Exception) { return; } var ep = packet as EthernetPacket; if (ep == null) { return; } if (ep.Type != EthernetPacketType.IpV4 && ep.Type != EthernetPacketType.IpV6) { return; } var ip = ep.PayloadPacket as IpPacket; if (ip == null) { return; } var tp = ip.PayloadPacket as TcpPacket; if (tp == null) { return; } if (tp.PayloadData.Length == 0) { return; } IPAddress srcIp = ip.SourceAddress; IPAddress dstIp = ip.DestinationAddress; int srcPort = tp.SourcePort; int dstPort = tp.DestinationPort; BeginInvoke((Action)(() => { lock (PacketsStateStatusLabelLock) { if (ep.Type == EthernetPacketType.IpV6) { Ip6PacketsCount++; } else { Ip4PacketsCount++; } PacketsStatusLabel.Text = string.Format("Packets: {0} IPv4, {1} IPv6", Ip4PacketsCount, Ip6PacketsCount); } })); uint sequenceNumber = tp.SequenceNumber; // --------------------------------------------------------------------------- var sourceIsLocal = IpAddresses.Contains(ip.SourceAddress); var destinationIsLocal = IpAddresses.Contains(ip.DestinationAddress); var direction = TrafficDirection.Local; if (sourceIsLocal && !destinationIsLocal) { direction = TrafficDirection.Out; } else if (!sourceIsLocal && destinationIsLocal) { direction = TrafficDirection.In; } // IPHeader.Data stores the data being carried by the IP datagram. if (SettingsManager.Options.LogEnable) { var index = -1; if (OptionsPanel.SearchPattern != null && OptionsPanel.SearchPattern.Length > 0) { index = ClassLibrary.Text.Helper.IndexOf(tp.PayloadData, OptionsPanel.SearchPattern, 0); } if (index > -1) { // Play "Radio2" sound if "LogEnabled" and "LogSound" check-boxes are checked. if (SettingsManager.Options.LogSound) { var stream = GetIntroSound("Radio2"); if (stream != null) { var player = new AudioPlayer(Handle); player.ChangeAudioDevice(SettingsManager.Options.PlaybackDevice); player.Load(stream); player.Play(); } } // --------------------------------------------- var writer = OptionsPanel.Writer; if (writer != null) { writer.WriteLine("{0:HH:mm:ss.fff}: {1} {2}: {3}:{4} -> {5}:{6} Data[{7}]", DateTime.Now, ep.Type.ToString().ToUpper(), destinationIsLocal ? "In" : "Out", ip.SourceAddress, tp.SourcePort, ip.DestinationAddress, tp.DestinationPort, tp.PayloadData.Length ); var block = JocysCom.ClassLibrary.Text.Helper.BytesToStringBlock( ep.PayloadData, false, true, true); block = JocysCom.ClassLibrary.Text.Helper.IdentText(4, block, ' '); writer.WriteLine(block); writer.WriteLine(""); } } } // ------------------------------------------------------------ // If direction specified, but wrong type then return. if (MonitorItem.FilterDirection != TrafficDirection.None && direction != MonitorItem.FilterDirection) { return; } // If port is specified but wrong number then return. if (MonitorItem.FilterDestinationPort > 0 && tp.DestinationPort != MonitorItem.FilterDestinationPort) { return; } // If process name specified. if (!string.IsNullOrEmpty(MonitorItem.FilterProcessName)) { //var ipGlobalProperties = IPGlobalProperties.GetIPGlobalProperties(); //var tcpListenters = ipGlobalProperties.GetActiveTcpListeners(); //var udpListenters = ipGlobalProperties.GetActiveUdpListeners(); //var tcpConnInfoArray = ipGlobalProperties.GetActiveTcpConnections(); //var myEnum = tcpConnInfoArray.GetEnumerator(); //while (myEnum.MoveNext()) //{ // var tcpInfo = (TcpConnectionInformation)myEnum.Current; // Console.WriteLine("Port {0} {1} {2} ", tcpInfo.LocalEndPoint, tcpInfo.RemoteEndPoint, tcpInfo.State); // //usedPort.Add(TCPInfo.LocalEndPoint.Port); //} } var pluginType = MonitorItem.GetType(); var voiceItem = (VoiceListItem)Activator.CreateInstance(pluginType); voiceItem.Load(ip, tp); // If data do not contain XML message then return. if (!voiceItem.IsVoiceItem) { return; } var allowToAdd = true; // If message contains sequence number... if (sequenceNumber > 0) { lock (SequenceNumbersLock) { // Cleanup sequence list by removing oldest numbers.. while (SequenceNumbers.Count > 10) { SequenceNumbers.RemoveAt(0); } // If number is not unique then... if (SequenceNumbers.Contains(sequenceNumber)) { // Don't allow to add the message. allowToAdd = false; } else { // Store sequence number for the future checks. SequenceNumbers.Add(sequenceNumber); } } } if (allowToAdd) { // If default capture filter. if (!IsDetailFilter) { // Restrict filter to improve speed. SetFilter(voiceItem, true); } // Add wow item to the list. Use Invoke to make it Thread safe. this.Invoke((Action <VoiceListItem>)addVoiceListItem, new object[] { voiceItem }); } }
public void ChangeAudioDevice(int audioDev) { _player.ChangeAudioDevice(audioDev); }