using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace LumiSoft.Media.Wave.Native { /// /// The waveOutProc function is the callback function used with the waveform-audio output device. /// /// Handle to the waveform-audio device associated with the callback. /// Waveform-audio output message. /// User-instance data specified with waveOutOpen. /// Message parameter. /// Message parameter. internal delegate void waveOutProc(IntPtr hdrvr,int uMsg,int dwUser,int dwParam1,int dwParam2); /// /// The waveInProc function is the callback function used with the waveform-audio input device. /// /// Handle to the waveform-audio device associated with the callback. /// Waveform-audio input message. /// User-instance data specified with waveOutOpen. /// Message parameter. /// Message parameter. internal delegate void waveInProc(IntPtr hdrvr,int uMsg,int dwUser,int dwParam1,int dwParam2); /// /// This class provides windows wav methods. /// internal class WavMethods { /// /// The waveInAddBuffer function sends an input buffer to the given waveform-audio input device. When the buffer is filled, the application is notified. /// /// Handle to the waveform-audio input device. /// Pointer to a WAVEHDR structure that identifies the buffer. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInAddBuffer(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); /// /// Closes the specified waveform input device. /// /// Handle to the waveform-audio input device. If the function succeeds, the handle is no longer valid after this call. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInClose(IntPtr hWaveOut); /// /// Queries a specified waveform device to determine its capabilities. /// /// Identifier of the waveform-audio input device. It can be either a device identifier or a Handle to an open waveform-audio output device. /// Pointer to a WAVEOUTCAPS structure to be filled with information about the capabilities of the device. /// Size, in bytes, of the WAVEOUTCAPS structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern uint waveInGetDevCaps(uint hwo,ref WAVEOUTCAPS pwoc,int cbwoc); /// /// Get the waveInGetNumDevs function returns the number of waveform-audio input devices present in the system. /// /// Returns the waveInGetNumDevs function returns the number of waveform-audio input devices present in the system. /// [DllImport("winmm.dll")] public static extern int waveInGetNumDevs(); /// /// The waveInOpen function opens the given waveform-audio input device for recording. /// /// Pointer to a buffer that receives a handle identifying the open waveform-audio input device. /// Identifier of the waveform-audio input device to open. It can be either a device identifier or a handle of an open waveform-audio input device. You can use the following flag instead of a device identifier. /// Pointer to a WAVEFORMATEX structure that identifies the desired format for recording waveform-audio data. You can free this structure immediately after waveInOpen returns. /// Pointer to a fixed callback function, an event handle, a handle to a window, /// or the identifier of a thread to be called during waveform-audio recording to process messages related /// to the progress of recording. If no callback function is required, this value can be zero. /// For more information on the callback function, see waveInProc. /// User-instance data passed to the callback mechanism. /// Flags for opening the device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInOpen(out IntPtr hWaveOut,int uDeviceID,WAVEFORMATEX lpFormat,waveInProc dwCallback,int dwInstance,int dwFlags); /// /// Prepares a waveform data block for recording. /// /// Handle to the waveform-audio input device. /// 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. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInPrepareHeader(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); /// /// Stops input on a specified waveform output device and resets the current position to 0. /// /// Handle to the waveform-audio input device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInReset(IntPtr hWaveOut); /// /// Starts input on the given waveform-audio input device. /// /// Handle to the waveform-audio input device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInStart(IntPtr hWaveOut); /// /// Stops input on the given waveform-audio input device. /// /// Handle to the waveform-audio input device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInStop(IntPtr hWaveOut); /// /// Cleans up the preparation performed by waveInPrepareHeader. /// /// Handle to the waveform-audio input device. /// Pointer to a WAVEHDR structure identifying the data block to be cleaned up. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveInUnprepareHeader(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); /// /// Closes the specified waveform output device. /// /// Handle to the waveform-audio output device. If the function succeeds, the handle is no longer valid after this call. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutClose(IntPtr hWaveOut); /// /// Queries a specified waveform device to determine its capabilities. /// /// Identifier of the waveform-audio output device. It can be either a device identifier or a Handle to an open waveform-audio output device. /// Pointer to a WAVEOUTCAPS structure to be filled with information about the capabilities of the device. /// Size, in bytes, of the WAVEOUTCAPS structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern uint waveOutGetDevCaps(uint hwo,ref WAVEOUTCAPS pwoc,int cbwoc); /// /// Retrieves the number of waveform output devices present in the system. /// /// The number of devices indicates success. Zero indicates that no devices are present or that an error occurred. [DllImport("winmm.dll")] public static extern int waveOutGetNumDevs(); /// /// Retrieves the current playback position of the specified waveform output device. /// /// Handle to the waveform-audio output device. /// Pointer to an MMTIME structure. /// Size, in bytes, of the MMTIME structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutGetPosition(IntPtr hWaveOut,out int lpInfo,int uSize); /// /// Queries the current volume setting of a waveform output device. /// /// Handle to an open waveform-audio output device. This parameter can also be a device identifier. /// 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. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutGetVolume(IntPtr hWaveOut,out int dwVolume); /// /// The waveOutOpen function opens the given waveform-audio output device for playback. /// /// Pointer to a buffer that receives 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. /// Identifier of the waveform-audio output device to open. It can be either a device identifier or a handle of an open waveform-audio input device. /// 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. /// Pointer to 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. /// User-instance data passed to the callback mechanism. /// Flags for opening the device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutOpen(out IntPtr hWaveOut,int uDeviceID,WAVEFORMATEX lpFormat,waveOutProc dwCallback,int dwInstance,int dwFlags); /// /// Pauses playback on a specified waveform output device. /// /// Handle to the waveform-audio output device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutPause(IntPtr hWaveOut); /// /// Prepares a waveform data block for playback. /// /// Handle to the waveform-audio output device. /// 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. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutPrepareHeader(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); /// /// Stops playback on a specified waveform output device and resets the current position to 0. /// /// Handle to the waveform-audio output device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutReset(IntPtr hWaveOut); /// /// Restarts a paused waveform output device. /// /// Handle to the waveform-audio output device. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutRestart(IntPtr hWaveOut); /// /// Sets the volume of a waveform output device. /// /// Handle to an open waveform-audio output device. This parameter can also be a device identifier. /// 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. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutSetVolume(IntPtr hWaveOut,int dwVolume); /// /// Cleans up the preparation performed by waveOutPrepareHeader. /// /// Handle to the waveform-audio output device. /// Pointer to a WAVEHDR structure identifying the data block to be cleaned up. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutUnprepareHeader(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); /// /// Sends a data block to the specified waveform output device. /// /// Handle to the waveform-audio output device. /// Pointer to a WAVEHDR structure containing information about the data block. /// Size, in bytes, of the WAVEHDR structure. /// Returns value of MMSYSERR. [DllImport("winmm.dll")] public static extern int waveOutWrite(IntPtr hWaveOut,IntPtr lpWaveOutHdr,int uSize); } }