public NAudio(Options.MainConfig config) { this.input = new WaveInEvent() { DeviceNumber = Utility.Audio.NAudio.Instance.WaveInDeviceId }; this.input.DataAvailable += new EventHandler <WaveInEventArgs>(InputDataAvailable); this.input.WaveFormat = new WaveFormat(SAMPLE_RATE, WaveIn.GetCapabilities(Utility.Audio.NAudio.Instance.WaveInDeviceId).Channels); }
public static void Initialize(Options.MainConfig config) { if (IsInitialized) { return; } // get sound device and record device // TRANSLATORS: Log message. In AudioManager. Logger.Log(T._("- get sound device ...")); // TRANSLATORS: Log message. In AudioManager. Logger.Log(T._("- get record device ...")); Utility.Audio.NAudio.Initialize(config.DeviceSoundEffect, config.DeviceRead); if (Utility.Audio.NAudio.Instance.WaveOutDeviceId < 0) { // TRANSLATORS: Error message. In AudioManager. {0} is name of sound device. {1} is list of available sound device(s). throw new Exception(T._("Sound device \"{0}\" is not found.\nAvailable sound devices:\n{1}", config.DeviceSoundEffect, " * " + string.Join("\n * ", Utility.Audio.NAudio.Instance.WaveOutDevices))); } if (Utility.Audio.NAudio.Instance.WaveInDeviceId < 0) { // TRANSLATORS: Error message. In AudioManager. {0} is name of recording device. {1} is list of available recording device(s). throw new Exception(T._("Recording device \"{0}\" is not found.\nAvailable recording devices:\n{1}", config.DeviceRead, " * " + string.Join("\n * ", Utility.Audio.NAudio.Instance.WaveInDevices))); } IsInitialized = true; }