/// <summary> /// Builds a custom tone based on the string definition passed in. example: '480,30,620,40,25,5,25,5,2' /// </summary> /// <param name="definition">The definition of the tone to split up. Example: '480,30,620,40,25,5,25,5,2'</param> public CustomTone(string definition) { var parts = definition.Split(','); if (parts.Length == 9) { ToneType = CustomToneType.DualWithCadence; Freq1 = int.Parse(parts[0]); Frq1Dev = int.Parse(parts[1]); Freq2 = int.Parse(parts[2]); Frq2Dev = int.Parse(parts[3]); Ontime = int.Parse(parts[4]); Ontdev = int.Parse(parts[5]); Offtime = int.Parse(parts[6]); Offtdev = int.Parse(parts[7]); Repcnt = int.Parse(parts[8]); } else if (parts.Length == 5) { ToneType = CustomToneType.Dual; Freq1 = int.Parse(parts[0]); Frq1Dev = int.Parse(parts[1]); Freq2 = int.Parse(parts[2]); Frq2Dev = int.Parse(parts[3]); if (parts[4] == "L") { Mode = ToneDetection.Leading; } else if (parts[4] == "T") { Mode = ToneDetection.Trailing; } else { throw new VoiceException("Custom tone is invalid"); } } else if (parts.Length == 3) { ToneType = CustomToneType.Single; Freq1 = int.Parse(parts[0]); Frq1Dev = int.Parse(parts[1]); if (parts[2] == "L") { Mode = ToneDetection.Leading; } else if (parts[2] == "T") { Mode = ToneDetection.Trailing; } else { throw new VoiceException("Custom tone is invalid"); } } else { throw new VoiceException("Custom tone is invalid"); } }
internal static void AddDualTone(int devh, int tid, int freq1, int fq1Dev, int freq2, int fq2Dev, ToneDetection mode) { var dialogicMode = mode == ToneDetection.Leading ? TN_LEADING : TN_TRAILING; if (dx_blddt((uint)tid, (uint)freq1, (uint)fq1Dev, (uint)freq2, (uint)fq2Dev, dialogicMode) == -1) { throw new VoiceException("unable to build dual tone"); } if (dx_addtone(devh, 0, 0) == -1) { var err = ATDV_ERRMSGP(devh); throw new VoiceException(err); } }