コード例 #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// as far as naudio is concerned, we are still "recording" (i.e., accepting waveIn
 /// data), but we want to stop writing the data to the file.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected virtual void TransitionFromRecordingToMonitoring()
 {
     RecordingState = RecordingState.Stopping;
     _fileWriterThread.Stop();
     RecordedTime      = _fileWriterThread.RecordedTimeInSeconds;
     _fileWriterThread = null;
     RecordingState    = RecordingState.Monitoring;
     if (Stopped != null)
     {
         Stopped(this, null);
     }
 }
コード例 #2
0
        /// ------------------------------------------------------------------------------------
        public virtual void BeginRecording(string waveFileName, bool appendToFile)
        {
            if (_recordingState == RecordingState.NotYetStarted)
            {
                BeginMonitoring();
            }

            if (_recordingState != RecordingState.Monitoring)
            {
                throw new InvalidOperationException("Can't begin recording while we are in this state: " + _recordingState.ToString());
            }

            lock (this)
            {
                if (_waveInBuffersChanged)
                {
                    CloseWaveIn();
                    BeginMonitoring();
                }

                _bytesRecorded = 0;

                WaveFileWriter writer;
                if (!File.Exists(waveFileName) || !appendToFile)
                {
                    writer = new WaveFileWriter(waveFileName, _recordingFormat);
                }
                else
                {
                    var buffer = GetAudioBufferToAppendTo(waveFileName);
                    writer = new WaveFileWriter(waveFileName, _recordingFormat);
                    writer.Write(buffer, 0, buffer.Length);
                }
                _fileWriterThread = new FileWriterThread(writer);

                _recordingStartTime = DateTime.Now;
                _prevRecordedTime   = 0d;
                RecordingState      = RecordingState.Recording;
            }
            if (RecordingStarted != null)
            {
                RecordingStarted(this, EventArgs.Empty);
            }
        }
コード例 #3
0
ファイル: AudioRecorder.cs プロジェクト: regnrand/libpalaso
		/// ------------------------------------------------------------------------------------
		public virtual void BeginRecording(string waveFileName, bool appendToFile)
		{
			if (_recordingState == RecordingState.NotYetStarted)
				BeginMonitoring();

			if (_recordingState != RecordingState.Monitoring)
			{
				throw new InvalidOperationException("Can't begin recording while we are in this state: " + _recordingState.ToString());
			}

			lock (this)
			{
				if (_waveInBuffersChanged)
				{
					CloseWaveIn();
					BeginMonitoring();
				}

				_bytesRecorded = 0;

				WaveFileWriter writer;
				if (!File.Exists(waveFileName) || !appendToFile)
					writer = new WaveFileWriter(waveFileName, _recordingFormat);
				else
				{
					var buffer = GetAudioBufferToAppendTo(waveFileName);
					writer = new WaveFileWriter(waveFileName, _recordingFormat);
					writer.Write(buffer, 0, buffer.Length);
				}
				_fileWriterThread = new FileWriterThread(writer);

				_recordingStartTime = DateTime.Now;
				_prevRecordedTime = 0d;
				RecordingState = RecordingState.Recording;
			}
			if (RecordingStarted != null)
				RecordingStarted(this, EventArgs.Empty);
		}
コード例 #4
0
ファイル: AudioRecorder.cs プロジェクト: regnrand/libpalaso
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// as far as naudio is concerned, we are still "recording" (i.e., accepting waveIn
		/// data), but we want to stop writing the data to the file.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected virtual void TransitionFromRecordingToMonitoring()
		{
			RecordingState = RecordingState.Stopping;
			_fileWriterThread.Stop();
			RecordedTime = _fileWriterThread.RecordedTimeInSeconds;
			_fileWriterThread = null;
			RecordingState = RecordingState.Monitoring;
			if (Stopped != null)
				Stopped(this, null);
		}