Example #1
0
		/// <summary>
		/// Closes the WAV file
		/// </summary>
		public void Dispose()
		{
			if (writer != null)
			{
				writer.Dispose();
				writer = null;
			}
		}
Example #2
0
		/// <summary>
		/// Constructs a new WaveRecorder
		/// </summary>
		/// <param name="destination">The location to write the WAV file to</param>
		/// <param name="source">The Source Wave Provider</param>
		public WaveRecorder(IWaveProvider source, string destination)
		{
			this.source = source;
			writer = new WaveFileWriter(destination, source.WaveFormat);
		}
Example #3
0
		/// <summary>
		/// Creates a Wave file by reading all the data from a WaveStream
		/// </summary>
		/// <param name="filename">The filename to use</param>
		/// <param name="stream">The source WaveStream</param>
		public static void CreateWaveFile(string filename, WaveStream stream)
		{
			using (var writer = new WaveFileWriter(filename, stream.WaveFormat))
			{
				var buffer = new byte[stream.WaveFormat.SampleRate*stream.WaveFormat.Channels*16];
				while (true)
				{
					int bytesRead = stream.Read(buffer, 0, buffer.Length);
					if (bytesRead == 0)
						break;
					writer.WriteData(buffer, 0, bytesRead);
				}
			}
		}