/// <summary> /// Checks, if there is a mic-configuration /// </summary> /// <returns></returns> public static bool IsMicConfig() { SRecordDevice[] Devices = CSound.RecordGetDevices(); if (Devices == null) { return(false); } for (int dev = 0; dev < Devices.Length; dev++) { for (int inp = 0; inp < Devices[dev].Inputs.Count; inp++) { if (Devices[dev].Inputs[inp].PlayerChannel1 != 0 || Devices[dev].Inputs[inp].PlayerChannel2 != 0) { return(true); } } } return(false); }
/// <summary> /// Try to assign automatically player 1 and 2 to usb-mics. /// </summary> public static bool AutoAssignMics() { //Look for (usb-)mic //SRecordDevice[] Devices = new SRecordDevice[CSound.RecordGetDevices().Length]; SRecordDevice[] Devices = CSound.RecordGetDevices(); if (Devices == null) { return(false); } for (int dev = 0; dev < Devices.Length; dev++) { //Has Device some signal-names in name -> This could be a (usb-)mic if (Regex.IsMatch(Devices[dev].Name, @"Usb|Wireless", RegexOptions.IgnoreCase)) { //Check if there are inputs. if (Devices[dev].Inputs.Count >= 1) { //Check if there is one or more channels if (Devices[dev].Inputs[0].Channels >= 2) { //Set this device to player 1 MicConfig[0].DeviceName = Devices[dev].Name; MicConfig[0].DeviceDriver = Devices[dev].Driver; MicConfig[0].InputName = Devices[dev].Inputs[0].Name; MicConfig[0].Channel = 1; //Set this device to player 2 MicConfig[1].DeviceName = Devices[dev].Name; MicConfig[1].DeviceDriver = Devices[dev].Driver; MicConfig[1].InputName = Devices[dev].Inputs[0].Name; MicConfig[1].Channel = 2; return(true); } } } } //If no usb-mics found -> Look for Devices with "mic" or "mik" for (int dev = 0; dev < Devices.Length; dev++) { //Has Device some signal-names in name -> This could be a mic if (Regex.IsMatch(Devices[dev].Name, @"Mic|Mik", RegexOptions.IgnoreCase)) { //Check if there are inputs. if (Devices[dev].Inputs.Count >= 1) { bool micfound = false; //Check if there is one or more channels if (Devices[dev].Inputs[0].Channels >= 1) { //Set this device to player 1 MicConfig[0].DeviceName = Devices[dev].Name; MicConfig[0].DeviceDriver = Devices[dev].Driver; MicConfig[0].InputName = Devices[dev].Inputs[0].Name; MicConfig[0].Channel = 1; micfound = true; } if (Devices[dev].Inputs[0].Channels >= 2) { //Set this device to player 2 MicConfig[1].DeviceName = Devices[dev].Name; MicConfig[1].DeviceDriver = Devices[dev].Driver; MicConfig[1].InputName = Devices[dev].Inputs[0].Name; MicConfig[1].Channel = 2; micfound = true; } if (micfound) { return(true); } } } } return(false); }