コード例 #1
0
        private void Start()
        {
            Stop();
            try
            {
                _waveFormat = new WaveFormat(SoundAlert.Properties.Settings.Default.SettingSamplesPerSecond, SoundAlert.Properties.Settings.Default.SettingBitsPerSample, SoundAlert.Properties.Settings.Default.SettingChannels);
                _recorder   = new WaveInRecorder(SoundAlert.Properties.Settings.Default.SettingAudioInputDevice, _waveFormat, SoundAlert.Properties.Settings.Default.SettingBytesPerFrame * SoundAlert.Properties.Settings.Default.SettingChannels, 3, new BufferDoneEventHandler(DataArrived));

                textBoxConsole.AppendText(DateTime.Now.ToString() + " : Audio input device polling started\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Device = " + SoundAlert.Properties.Settings.Default.SettingAudioInputDevice.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Channels = " + SoundAlert.Properties.Settings.Default.SettingChannels.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Bits per sample = " + SoundAlert.Properties.Settings.Default.SettingBitsPerSample.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Samples per second = " + SoundAlert.Properties.Settings.Default.SettingSamplesPerSecond.ToString() + "\r\n");
                textBoxConsole.AppendText(DateTime.Now + " : Frame size = " + SoundAlert.Properties.Settings.Default.SettingBytesPerFrame.ToString() + "\r\n");
            }
            catch (Exception ex)
            {
                //textBoxConsole.AppendText(DateTime.Now + " : " + ex.InnerException.ToString() + "\r\n");
            }
        }
コード例 #2
0
        private void Stop()
        {
            if (_recorder != null)
            {
                try
                {
                    _recorder = null;
                    _recorder.Dispose();
                }
                catch
                {
                    _recorder = null;
                }
                finally
                {
                    _recorder = null;
                }
            }

            textBoxConsole.AppendText(DateTime.Now.ToString() + " : Audio input device polling stopped\r\n");
        }