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

📄 waveout.cs

📁 功能:基于windows mobile 的地图查看器。使用vs2005开发
💻 CS
📖 第 1 页 / 共 2 页
字号:


using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Windows.Forms;
using System.Diagnostics;



namespace GXSoundLibrary
{
	/// <summary>
	/// Encapsulation of Waveform Audio Interface functionality needed to play
	/// audio files.
	/// </summary>
	internal class WaveOut
	{
		/// <summary>
		/// This function retrieves the number of waveform output devices
		/// present in the system.
		/// </summary>
		/// <returns>The number of devices indicates success. Zero indicates
		/// that no devices are present or that an error occurred.</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern int waveOutGetNumDevs();
#else
		public static int waveOutGetNumDevs() { return 0; }
#endif

		/// <summary>
		/// This function opens a specified waveform output device for playback.
		/// </summary>
		/// <param name="phwi">Address filled with a handle identifying the open
		/// waveform-audio output device. Use the handle to identify the device
		/// when calling other waveform-audio output functions. This parameter
		/// might be NULL if the WAVE_FORMAT_QUERY flag is specified for
		/// fdwOpen.</param>
		/// <param name="uDeviceID">Identifier of the waveform-audio output device
		/// to open. It can be either a device identifier or a Handle to an open
		/// waveform-audio input device.</param>
		/// <param name="pwfx">Pointer to a WAVEFORMATEX structure that identifies
		/// the format of the waveform-audio data to be sent to the device. You
		/// can free this structure immediately after passing it to
		/// waveOutOpen.</param>
		/// <param name="dwCallback">Specifies the address of a fixed callback
		/// function, an event handle, a handle to a window, or the identifier of
		/// a thread to be called during waveform-audio playback to process
		/// messages related to the progress of the playback. If no callback
		/// function is required, this value can be zero.</param>
		/// <param name="dwInstance">Specifies user-instance data passed to the
		/// callback mechanism. This parameter is not used with the window
		/// callback mechanism.</param>
		/// <param name="fdwOpen">Flags for opening the device.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutOpen(ref IntPtr phwo, uint uDeviceID, Wave.WAVEFORMATEX pwfx, IntPtr dwCallback, uint dwInstance, uint fdwOpen); // not done here
#else
		public static Wave.MMSYSERR waveOutOpen(ref IntPtr phwo, uint uDeviceID, Wave.WAVEFORMATEX pwfx, IntPtr dwCallback, uint dwInstance, uint fdwOpen)
		{
		  return Wave.MMSYSERR.NOERROR;
	    }
#endif
		/// <summary>
		/// This function queries the current volume setting of a waveform
		/// output device.
		/// </summary>
		/// <param name="hwo">Handle to an open waveform-audio output device. This
		/// parameter can also be a device identifier.</param>
		/// <param name="pdwVolume">Pointer to a variable to be filled with the
		/// current volume setting. The low-order word of this location contains
		/// the left-channel volume setting, and the high-order word contains the
		/// right-channel setting. A value of 0xFFFF represents full volume, and
		/// a value of 0x0000 is silence.
		/// 
		/// If a device does not support both left and right volume control, the
		/// low-order word of the specified location contains the mono volume
		/// level.
		/// 
		/// The full 16-bit setting(s) set with the waveOutSetVolume function is
		/// returned, regardless of whether the device supports the full 16 bits
		/// of volume-level control.
		/// </param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutGetVolume(IntPtr hwo, ref uint pdwVolume);
#else
        public static Wave.MMSYSERR waveOutGetVolume(IntPtr hwo, ref uint pdwVolume)
		{
		  return Wave.MMSYSERR.NOERROR;
		}
#endif

		/// <summary>
		/// This function sets the volume of a waveform output device.
		/// </summary>
		/// <param name="hwo">Handle to an open waveform-audio output device.
		/// This parameter can also be a device identifier.</param>
		/// <param name="dwVolume">Specifies a new volume setting. The low-order
		/// word contains the left-channel volume setting, and the high-order word
		/// contains the right-channel setting. A value of 0xFFFF represents full
		/// volume, and a value of 0x0000 is silence.
		/// 
		/// If a device does not support both left and right volume control, the
		/// low-order word of dwVolume specifies the volume level, and the
		/// high-order word is ignored.</param>
		/// <returns>Error Condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutSetVolume(IntPtr hwo, uint dwVolume);
#else
        public static Wave.MMSYSERR waveOutSetVolume(IntPtr hwo, uint dwVolume)
		{
		  return Wave.MMSYSERR.NOERROR;
	    }
#endif
		/// <summary>
		/// This function prepares a waveform data block for playback.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device.</param>
		/// <param name="pwh">Pointer to a WAVEHDR structure that identifies the
		/// data block to be prepared. The buffer's base address must be aligned
		/// with the respect to the sample size.</param>
		/// <param name="cbwh">Size, in bytes, of the WAVEHDR structure.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutPrepareHeader(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh);
#else
        public static Wave.MMSYSERR waveOutPrepareHeader(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh)
	    {
		  return Wave.MMSYSERR.NOERROR;
	    }
#endif
		/// <summary>
		/// This function sends a data block to the specified waveform output device.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device.</param>
		/// <param name="pwh">Pointer to a WAVEHDR structure containing information
		/// about the data block.</param>
		/// <param name="cbwh">Size, in bytes, of the WAVEHDR structure.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutWrite(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh);
#else
        public static Wave.MMSYSERR waveOutWrite(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh)
		{
		  return Wave.MMSYSERR.NOERROR;
		}
#endif
		/// <summary>
		/// This function cleans up the preparation performed by
		/// waveOutPrepareHeader. The function must be called after the device
		/// driver is finished with a data block. You must call this function
		/// before freeing the data buffer.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device.</param>
		/// <param name="pwh">Pointer to a WAVEHDR structure identifying the data
		/// block to be cleaned up.</param>
		/// <param name="cbwh">Size, in bytes, of the WAVEHDR structure.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutUnprepareHeader(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh);
#else
        public static Wave.MMSYSERR waveOutUnprepareHeader(IntPtr hwo, Wave.WAVEHDR pwh, uint cbwh)
		{
		  return Wave.MMSYSERR.NOERROR;
		}
#endif

		/// <summary>
		/// This function closes the specified waveform output device.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device. If the
		/// function succeeds, the handle is no longer valid after this
		/// call.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutClose(IntPtr hwo);
#else
		public static Wave.MMSYSERR waveOutClose(IntPtr hwo)
		{
		  return Wave.MMSYSERR.NOERROR;
		}
#endif

		/// <summary>
		/// This function stops playback on a specified waveform output device
		/// and resets the current position to 0. All pending playback buffers
		/// are marked as done and returned to the application.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		[DllImport ("coredll.dll")]
		public static extern Wave.MMSYSERR waveOutReset(IntPtr hwo); 
#else
        public static Wave.MMSYSERR waveOutReset(IntPtr hwo)
		{
		  return Wave.MMSYSERR.NOERROR;
		}
#endif

		/// <summary>
		/// This function pauses playback on a specified waveform output device.
		/// The current playback position is saved. Use waveOutRestart to resume
		/// playback from the current playback position.
		/// </summary>
		/// <param name="hwo">Handle to the waveform-audio output device.</param>
		/// <returns>Error condition</returns>
#if SOUND_SUPPORT
		//[DllImport ("coredll.dll")]

⌨️ 快捷键说明

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