⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wave.cs

📁 功能:基于windows mobile 的地图查看器。使用vs2005开发
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.IO;
using System.Runtime.InteropServices;
using Windows;

namespace GXSoundLibrary
{
	/// <summary>
	/// Defines functionality common to playing and recording wave files via
	/// the Waveform Audio Interface, though only the former is supported
	/// in this demo.
	/// </summary>
	public class Wave
	{
		/// <summary>
		/// Can be used instead of a device id to open a device.
		/// </summary>
		public const uint WAVE_MAPPER = unchecked((uint)(-1));

		/// <summary>
		/// Identifies the callback window as the method of receiving.
		/// feedback from the sound system.
		/// </summary>
		public const uint CALLBACK_WINDOW  = 0x10000;

		/// <summary>
		/// Offset within the file to the RIFF header format tag.
		/// </summary>
		private const int WF_OFFSET_FORMATTAG = 20;

		/// <summary>
		/// Offset within the file to the RIFF header number of channels.
		/// 1 for mono, 2 for stereo.
		/// </summary>
		private const int WF_OFFSET_CHANNELS = 22;

		/// <summary>
		/// Offset within the file to the RIFF header sample rate.
		/// </summary>
		private const int WF_OFFSET_SAMPLESPERSEC = 24;

		/// <summary>
		/// Offset within the file to the RIFF header byte rate.
		/// </summary>
		private const int WF_OFFSET_AVGBYTESPERSEC = 28;

		/// <summary>
		/// Offset within the file to the RIFF header block alignment.
		/// </summary>
		private const int WF_OFFSET_BLOCKALIGN = 32;

		/// <summary>
		/// Offset within the file to the RIFF header sample bit depth.
		/// </summary>
		private const int WF_OFFSET_BITSPERSAMPLE = 34;

		/// <summary>
		/// Offset within the file to the PCM data
		/// Offset 2 for wBitsPerSample
		/// + 4 for the subchunk id "data"
		/// + 4 for the subchunk length
		/// </summary>
		public const int WF_OFFSET_DATA = 44;

		/// <summary>
		/// Base error information.
		/// </summary>
		private const int WAVERR_BASE = 32;

		/// <summary>
		/// Base error information.
		/// </summary>
		private const int MMSYSERR_BASE = 0;

		/// <summary>
		/// Defines all system errors.
		/// </summary>
		public enum MMSYSERR : int
		{
			NOERROR = 0,
			ERROR = (MMSYSERR_BASE + 1),
			BADDEVICEID = (MMSYSERR_BASE + 2),
			NOTENABLED = (MMSYSERR_BASE + 3),
			ALLOCATED = (MMSYSERR_BASE + 4),
			INVALHANDLE = (MMSYSERR_BASE + 5),
			NODRIVER = (MMSYSERR_BASE + 6),
			NOMEM = (MMSYSERR_BASE + 7),
			NOTSUPPORTED = (MMSYSERR_BASE + 8),
			BADERRNUM = (MMSYSERR_BASE + 9),
			INVALFLAG = (MMSYSERR_BASE + 10),
			INVALPARAM = (MMSYSERR_BASE + 11),
			HANDLEBUSY = (MMSYSERR_BASE + 12),
			INVALIDALIAS = (MMSYSERR_BASE + 13),
			BADDB = (MMSYSERR_BASE + 14),
			KEYNOTFOUND = (MMSYSERR_BASE + 15),
			READERROR = (MMSYSERR_BASE + 16),
			WRITEERROR = (MMSYSERR_BASE + 17),
			DELETEERROR = (MMSYSERR_BASE + 18),
			VALNOTFOUND = (MMSYSERR_BASE + 19),
			NODRIVERCB = (MMSYSERR_BASE + 20),
			LASTERROR = (MMSYSERR_BASE + 20)
		}

		/// <summary>
		/// Defines all wave errors.
		/// </summary>
		private enum WAVERR : int
		{
			NONE = 0,
			BADFORMAT = WAVERR_BASE + 0,
			STILLPLAYING = WAVERR_BASE + 1,
			UNPREPARED = WAVERR_BASE + 2,
			SYNC = WAVERR_BASE + 3,
			LASTERROR = WAVERR_BASE + 3
		}

		/// <summary>
		/// Wave format definition: Invalid format
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_INVALIDFORMAT = 0x00000000;

		/// <summary>
		/// Wafe format definition: 11.025 kHz, Mono, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_1M08 = 0x00000001;

		/// <summary>
		/// Wafe format definition: 11.025 kHz, Stereo, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_1S08 = 0x00000002;

		/// <summary>
		/// Wafe format definition: 11.025 kHz, Mono, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_1M16 = 0x00000004;

		/// <summary>
		/// Wafe format definition: 11.025 kHz, Stereo, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_1S16 = 0x00000008;

		/// <summary>
		/// Wafe format definition: 22.05 kHz, Mono, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_2M08 = 0x00000010;

		/// <summary>
		/// Wafe format definition: 22.05 kHz, Stereo, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_2S08 = 0x00000020;

		/// <summary>
		/// Wafe format definition: 22.05 kHz, Mono, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_2M16 = 0x00000040;

		/// <summary>
		/// Wafe format definition: 22.05 kHz, Stereo, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_2S16 = 0x00000080;

		/// <summary>
		/// Wafe format definition: 44.1 kHz, Mono, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_4M08 = 0x00000100;

		/// <summary>
		/// Wafe format definition: 44.1 kHz, Stereo, 8-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_4S08 = 0x00000200;

		/// <summary>
		/// Wafe format definition: 44.1 kHz, Mono, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_4M16 = 0x00000400;

		/// <summary>
		/// Wafe format definition: 44.1 kHz, Stereo, 16-bit
		/// Used by WAVEOUTCAPS.dwFormats
		/// </summary>
		public const uint WAVE_FORMAT_4S16 = 0x00000800;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is pitch modification supported?
		/// </summary>
		public const uint WAVECAPS_PITCH = 0x0001;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is playback rate modification supported?
		/// </summary>
		public const uint WAVECAPS_PLAYBACKRATE = 0x0002;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is volume modification supported?
		/// </summary>
		public const uint WAVECAPS_VOLUME = 0x0004;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is left/right volume modification
		/// supported?
		/// </summary>
		public const uint WAVECAPS_LRVOLUME = 0x0008;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is the driver synchronous?
		/// </summary>
		public const uint WAVECAPS_SYNC = 0x0010;

		/// <summary>
		/// Used by WAVEOUTCAPS.dwSupport: is sample-accurate position information
		/// supported?
		/// </summary>
		public const uint WAVECAPS_SAMPLEACCURATE = 0x0020;

		/// <summary>
		/// Used by WAVEHDR.dwFlags.  Specifies that a buffer is finished.
		/// </summary>
		public const int WHDR_DONE = 0x00000001;

		/// <summary>
		/// Used by WAVEHDR.dwFlags.  Specifies that a buffer is prepared.
		/// </summary>
		public const int WHDR_PREPARED = 0x00000002;

		/// <summary>
		/// Used by WAVEHDR.dwFlags.  Specifies that a buffer is the first in a loop.
		/// </summary>
		public const int WHDR_BEGINLOOP = 0x00000004;

		/// <summary>
		/// Used by WAVEHDR.dwFlags.  Specifies that a buffer is the last in a loop.
		/// </summary>
		public const int WHDR_ENDLOOP = 0x00000008;

		/// <summary>
		/// Used by WAVEHDR.dwFlags.  Specifies that a buffer is queued for playback.
		/// </summary>
		public const int WHDR_INQUEUE = 0x00000010;

		/// <summary>
		/// Specifies that the wave data is raw PCM.  This is the only type supported

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -