/// <summary> /// Creates a new Opus encoder. /// </summary> /// <param name="srcSamplingRate">The sampling rate of the input stream.</param> /// <param name="srcChannelCount">The number of channels in the input stream.</param> public OpusEncoder(int srcSamplingRate, int srcChannelCount) { if (srcSamplingRate != 8000 && srcSamplingRate != 12000 && srcSamplingRate != 16000 && srcSamplingRate != 24000 && srcSamplingRate != 48000) { throw new ArgumentOutOfRangeException("srcSamplingRate", Log.PossibleBugMessage("sample rate must be one of the valid values", "3F2C6D2D-338E-495E-8970-42A3C98243A5")); } if (srcChannelCount != 1 && srcChannelCount != 2) { throw new ArgumentOutOfRangeException("srcChannelCount", Log.PossibleBugMessage("channel count must be 1 or 2", "8FE1EC0F-09E0-4CE6-AFD7-04199202D45D")); } int error; var encoder = OpusNativeMethods.opus_encoder_create(srcSamplingRate, srcChannelCount, (int)Application.Voip, out error); if ((OpusErrors)error != OpusErrors.Ok) { throw new OpusException(Log.PossibleBugMessage(string.Format("Exception occured while creating encoder: {0}", (OpusErrors)error), "D77ECA73-413F-40D1-8427-CFD8A59CD5F6")); } _encoder = new LockedValue <IntPtr>(encoder); PermittedFrameSizes = new int[PermittedFrameSizesMs.Length]; for (var i = 0; i < PermittedFrameSizesMs.Length; i++) { PermittedFrameSizes[i] = (int)(srcSamplingRate / 1000f * PermittedFrameSizesMs[i]); } }
public AudioFileWriter(string filename, [NotNull] WaveFormat format) { if (filename == null) { throw new ArgumentNullException("filename"); } if (format == null) { throw new ArgumentNullException("format"); } if (string.IsNullOrEmpty(Path.GetExtension(filename))) { filename += ".wav"; } var directory = Path.GetDirectoryName(filename); if (!string.IsNullOrEmpty(directory)) { Directory.CreateDirectory(directory); } _lock = new LockedValue <WaveFileWriter>( new WaveFileWriter(File.Open(filename, FileMode.CreateNew), format) ); }
public RnnoisePreprocessor() { _handle = new LockedValue <IntPtr>(IntPtr.Zero); Bind(v => v.BackgroundSoundRemovalEnabled, "BackgroundSoundRemovalEnabled", a => Enabled = a); Bind(v => v.BackgroundSoundRemovalAmount, "BackgroundSoundRemovalAmount", a => _wetMix = a); }
public void StartReceiver(LockedValue <bool> alive, Action <UdpMessage> callback) { _client.BeginReceive(x => { var res = new UdpMessage(); byte[] msg; try { msg = _client.EndReceive(x, ref res.EndPoint); } catch { callback(null); return; } ReadMsg(res, msg); callback(res); if (alive.Retrieve(y => y)) { StartReceiver(alive, callback); } }, _client); }
public WebRtcPreprocessor() { _nsLevel = VoiceSettings.Instance.DenoiseAmount; _handle = new LockedValue <IntPtr>(Dissonance_CreatePreprocessor(NoiseSuppressionLevel)); using (var handle = _handle.Lock()) SetFilterPreprocessor(handle.Value); }
public WebRtcPreprocessor(bool useMobileAec) { _useMobileAec = useMobileAec; _handle = new LockedValue <IntPtr>(IntPtr.Zero); NoiseSuppressionLevel = VoiceSettings.Instance.DenoiseAmount; AecSuppressionLevel = VoiceSettings.Instance.AecSuppressionAmount; AecmSuppressionLevel = VoiceSettings.Instance.AecmRoutingMode; }
public ServerApplication(LockedValue <bool> flag, string host) { _iDGenerator = new IDGenerator(); _host = host; _flag = flag; _clients = new LockedValue <List <UserTcpConnection> >(new List <UserTcpConnection>()); _rooms = new LockedValue <Dictionary <string, Room> >(new Dictionary <string, Room>()); var newRoom = new Room("default_room", ""); _rooms.Act(x => { x[newRoom.PublicName] = newRoom; }); }
public WebRtcPreprocessor(bool useMobileAec) { _useMobileAec = useMobileAec; _nsLevel = VoiceSettings.Instance.DenoiseAmount; _aecLevel = VoiceSettings.Instance.AecSuppressionAmount; _aecmLevel = VoiceSettings.Instance.AecmRoutingMode; _handle = new LockedValue <IntPtr>(CreatePreprocessor()); using (var handle = _handle.Lock()) SetFilterPreprocessor(handle.Value); }
static void Main() { var flag = new LockedValue <bool>(true); var hostAddress = Console.ReadLine(); var Server = new ServerApplication(flag, hostAddress); Task.Run(Server.Listen); Task.Run(Server.Process); Task.Run(Server.Broadcast); Console.ReadLine(); flag.SetValue(false); }
public OpusDecoder(int outputSampleRate, int outputChannelCount) { if (outputSampleRate != 8000 && outputSampleRate != 12000 && outputSampleRate != 16000 && outputSampleRate != 24000 && outputSampleRate != 48000) { throw new ArgumentOutOfRangeException("outputSampleRate", Log.PossibleBugMessage("sample rate must be one of the valid values", "548757DF-DC64-40C9-BEAD-9826B8245A7D")); } if (outputChannelCount != 1 && outputChannelCount != 2) { throw new ArgumentOutOfRangeException("outputChannelCount", Log.PossibleBugMessage("channel count must be 1 or 2", "BA56610F-1FA3-4D68-9507-7B0DFA0E28AB")); } int error; _decoder = new LockedValue <IntPtr>(OpusNativeMethods.opus_decoder_create(outputSampleRate, outputChannelCount, out error)); if ((OpusErrors)error != OpusErrors.Ok) { throw new OpusException(Log.PossibleBugMessage(string.Format("Exception occured while creating decoder: {0}", (OpusErrors)error), "6E09F275-99A1-4CD6-A36A-FA093B146B29")); } }