public IEnumerable <DeviceInfo> EnumerateDevices() { if (mode == Mode.Record) { uint count = waveInGetNumDevs(); for (uint i = 0; i < count; ++i) { WAVEINCAPS caps = new WAVEINCAPS(); if (waveInGetDevCaps(i, ref caps, 48) == 0) { yield return(new DeviceInfo() { index = (int)i, name = caps.szPname }); } } } else if (mode == Mode.Play) { uint count = waveOutGetNumDevs(); for (uint i = 0; i < count; ++i) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); if (waveOutGetDevCaps(i, ref caps, 48) == 0) { yield return(new DeviceInfo() { index = (int)i, name = caps.szPname }); } } } }
public static WAVEOUTCAPS WaveOutGetDevCaps(uint DeviceID) { WAVEOUTCAPS Caps = new WAVEOUTCAPS(); waveOutGetDevCaps(DeviceID, ref Caps, (uint)Marshal.SizeOf(Caps)); return(Caps); }
/// <summary>Get the output device name from device id</summary> /// <param name="deviceId">device id</param> /// <param name="prodName">returns device name</param> /// <returns>MMSYSERR</returns> public MMSYSERR GetOutputDeviceName(uint deviceId, ref string prodName) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); MMSYSERR result = waveOutGetDevCaps(deviceId, out caps, (uint)Marshal.SizeOf(caps)); if (result != MMSYSERR.NOERROR) { return(result); } //WAVEOUTCAPS2 often does not return product name GUID, as it is not //a required field, so is most often left blank.. //The only way to get full string in vista/w7 that I have come across is //by enumerating devices with directsound, but that would mean referencing //the library, so.. deal with it prodName = new string(caps.szPname); if (prodName.Contains("(") && !(prodName.Contains(")"))) { prodName = prodName.Substring(0, prodName.IndexOf("(")); } else if (prodName.Contains(")")) { if (prodName.IndexOf(")") > 8) { prodName = prodName.Substring(0, prodName.IndexOf(")") + 1); } } return(MMSYSERR.NOERROR); }
public Native(WAVEOUTCAPS managed) { wMid = managed.wMid; wPid = managed.wPid; vDriverVersion = managed.vDriverVersion; managed.szPname.CopyTo(MemoryMarshal.CreateSpan(ref szPname[0], szPnameLength)); dwFormats = managed.dwFormats; wChannels = managed.wChannels; wReserved1 = managed.wReserved1; dwSupport = managed.dwSupport; }
public WaveOutDeviceCapabilities(int device) { this._Capabilities = new WAVEOUTCAPS(); int result = waveOutGetDevCaps(device, this._Capabilities, Marshal.SizeOf(this._Capabilities)); if (result != WaveError.MMSYSERR_NOERROR) { throw new SoundCoreException(WaveError.GetMessage(result), result); } }
internal static WAVEOUTCAPS?GetPlaybackDeviceCapabilities(uint device) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); UIntPtr deviceID = new UIntPtr(device); if (waveOutGetDevCaps(deviceID, out caps, (uint)Marshal.SizeOf(caps)) != 0) { return(null); } return(caps); }
public static string[] GetSoundDevices() { uint devices = waveOutGetNumDevs(); string[] result = new string[devices]; WAVEOUTCAPS caps = new WAVEOUTCAPS(); for (uint i = 0; i < devices; i++) { waveOutGetDevCaps(i, ref caps, (uint)Marshal.SizeOf(caps)); result[i] = caps.szPname; } return result; }
public static string[] GetSoundDevices() { uint devices = waveOutGetNumDevs(); string[] result = new string[devices]; WAVEOUTCAPS caps = new WAVEOUTCAPS(); for (uint i = 0; i < devices; i++) { waveOutGetDevCaps(i, ref caps, (uint)Marshal.SizeOf(caps)); result[i] = caps.szPname; } return(result); }
/// <summary> /// Get the name of the specified playback device. /// </summary> /// <param name="deviceId">ID of the device</param> /// <param name="prodName">Destination string assigned the name</param> /// <returns>MMSYSERR.NOERROR if successful</returns> public Wave.MMSYSERR GetDeviceName(uint deviceId, ref string prodName) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); Wave.MMSYSERR result = waveOutGetDevCaps(deviceId, caps, caps.Size); if (result != Wave.MMSYSERR.NOERROR) { return(result); } prodName = caps.szPname; return(Wave.MMSYSERR.NOERROR); }
public Native(WAVEOUTCAPS managed) { wMid = managed.wMid; wPid = managed.wPid; vDriverVersion = managed.vDriverVersion; fixed(char *pszPname = szPname) { managed.szPname.AsSpan().CopyTo(new Span <char>(pszPname, szPnameLength)); } dwFormats = managed.dwFormats; wChannels = managed.wChannels; wReserved1 = managed.wReserved1; dwSupport = managed.dwSupport; }
/// <summary> /// Retrieves the capabilities of a device. /// </summary> /// <param name="deviceId">The DeviceID for which to retrieve the capabilities.</param> /// <returns>The capabilities of the device.</returns> private static WaveOutDeviceCaps GetDeviceCaps(int deviceId) { WAVEOUTCAPS wocaps = new WAVEOUTCAPS(); NativeMethods.waveOutGetDevCaps(new IntPtr(deviceId), ref wocaps, Marshal.SizeOf(wocaps.GetType())); WaveOutDeviceCaps caps = new WaveOutDeviceCaps(); caps.DeviceId = (int)deviceId; caps.Channels = wocaps.wChannels; caps.DriverVersion = (int)wocaps.vDriverVersion; caps.Manufacturer = GetManufacturer(wocaps.wMid); caps.Name = wocaps.szPname; caps.ProductId = wocaps.wPid; caps.Capabilities = wocaps.dwSupport; return(caps); }
public static List <string> EnumOutputDevices() { List <string> OutputDeviceNames = new List <string>(); int waveOutDevicesCount = waveOutGetNumDevs(); //get total if (waveOutDevicesCount > 0) { for (int uDeviceID = 0; uDeviceID < waveOutDevicesCount; uDeviceID++) { WAVEOUTCAPS waveOutCaps = new WAVEOUTCAPS(); waveOutGetDevCaps(uDeviceID, ref waveOutCaps, Marshal.SizeOf(typeof(WAVEOUTCAPS))); string devnameandid = "Device ID " + uDeviceID + ": " + waveOutCaps.szPname; OutputDeviceNames.Add(devnameandid.Trim()); } } return(OutputDeviceNames); }
/// <summary> /// Gets the dev caps playback. /// </summary> /// <returns></returns> public static WAVEOUTCAPS[] GetDevCapsPlayback() { var waveOutDevicesCount = waveOutGetNumDevs(); if (waveOutDevicesCount > 0) { var list = new WAVEOUTCAPS[waveOutDevicesCount]; for (var uDeviceID = 0; uDeviceID < waveOutDevicesCount; uDeviceID++) { var waveOutCaps = new WAVEOUTCAPS(); waveOutGetDevCaps(uDeviceID, ref waveOutCaps, Marshal.SizeOf(typeof(WAVEOUTCAPS))); list[uDeviceID] = waveOutCaps; } return(list); } else { return(null); } }
static void Main(string[] args) { var deviceCount = waveOutGetNumDevs(); Console.WriteLine("Найдено {0} устаройств вывода: ", deviceCount); for (var i = 0; i < deviceCount; ++i) { var wOutCaps = new WAVEOUTCAPS(); waveOutGetDevCaps(new UIntPtr((uint)i), ref wOutCaps, (uint)Marshal.SizeOf(typeof(WAVEOUTCAPS))); Console.WriteLine("Имя:\"{0}\" Каналов:{1}", wOutCaps.SzPname, wOutCaps.WChannels); } Console.WriteLine(); deviceCount = waveInGetNumDevs(); Console.WriteLine("Найдено {0} устаройств ввода: ", deviceCount); for (var i = 0; i < deviceCount; ++i) { var wInCaps = new WAVEINCAPS(); waveInGetDevCaps(new UIntPtr((uint)i), ref wInCaps, (uint)Marshal.SizeOf(typeof(WAVEOUTCAPS))); Console.WriteLine("Имя:\"{0}\" Каналов:{1}", wInCaps.SzPname, wInCaps.WChannels); } Console.WriteLine("\nДля выхода нажмите Enter."); Console.ReadLine(); }
public static extern uint waveOutGetDevCaps(UIntPtr hWaveOut, ref WAVEOUTCAPS pwoc, uint cbwoc);
public static extern uint waveOutGetDevCaps(uint DeviceID, ref WAVEOUTCAPS pwoc, uint cbwoc);
public static extern int waveOutGetDevCaps(IntPtr hwo, ref WAVEOUTCAPS pwoc, uint cbwoc);
/// <summary> /// Get the name of the specified playback device. /// </summary> /// <param name="deviceId">ID of the device</param> /// <param name="prodName">Destination string assigned the name</param> /// <returns>MMSYSERR.NOERROR if successful</returns> public Wave.MMSYSERR GetDeviceName(uint deviceId, ref string prodName) { WAVEOUTCAPS caps = new WAVEOUTCAPS(); Wave.MMSYSERR result = waveOutGetDevCaps(deviceId, caps, caps.Size); if (result != Wave.MMSYSERR.NOERROR) return result; prodName = caps.szPname; return Wave.MMSYSERR.NOERROR; }
private static extern uint waveInGetDevCaps(uint hwo, ref WAVEOUTCAPS pwoc, int cbwoc);
public static extern uint waveOutGetDevCaps(uint hwo,ref WAVEOUTCAPS pwoc,int cbwoc);
private static extern uint waveInGetDevCaps(uint hwo,ref WAVEOUTCAPS pwoc,int cbwoc);
public static extern MMSYSERROR waveOutGetDevCaps(IntPtr uDeviceID, ref WAVEOUTCAPS pwoc, int cbwoc);
public static extern int waveOutGetDevCaps(IntPtr uDeviceID, out WAVEOUTCAPS pwoc, int cbwoc);
private static extern MMSYSERR waveOutGetDevCaps(uint uDeviceID, out WAVEOUTCAPS pwoc, uint cbwoc);
public static Native ConvertToUnmanaged(WAVEOUTCAPS managed) => new(managed);
public static extern uint waveOutGetDevCaps(int uDeviceID, ref WAVEOUTCAPS pwoc, int cbwoc);
public static AudioCapabilities CreateForOutput(WAVEOUTCAPS caps) { AudioCapabilities aud = new AudioCapabilities(true, (short)caps.wMid, (short)caps.wPid, (short)caps.vDriverVersion, caps.szPname, (int)caps.dwFormats, (short)caps.wChannels, (int)caps.dwSupport); return aud; }
private static extern int waveOutGetDevCaps(int device, WAVEOUTCAPS caps, int size);
private static extern uint waveOutGetDevCaps(int hwo, ref WAVEOUTCAPS pwoc, /*uint*/ int cbwoc);
static extern int waveOutGetDevCaps(UIntPtr uDeviceID, out WAVEOUTCAPS waveOutCaps, uint sizeOfwaveOutCaps);
public static WAVEOUTCAPS[] GetWaveOutCapabilities() { int numDevices = GetNumberOfWaveOutDevices(); WAVEOUTCAPS[] caps = new WAVEOUTCAPS[numDevices]; for (int i = 0; i < numDevices; i++) { WAVEOUTCAPS newCaps = new WAVEOUTCAPS(); IntPtr devID = new IntPtr(i); winmm.waveOutGetDevCaps(devID, ref newCaps, Marshal.SizeOf(newCaps)); caps[i] = newCaps; } return caps; }
private static extern uint waveOutGetDevCaps(uint uDeviceID, ref WAVEOUTCAPS pwic, uint cbwic);
public static extern uint waveOutGetDevCaps(int index, ref WAVEOUTCAPS pwoc, int cbwoc);
internal static extern MMSYSERR waveOutGetDevCaps(IntPtr uDeviceID, ref WAVEOUTCAPS caps, int cbwoc);
public static List<string> EnumOutputDevices() { List<string> OutputDeviceNames = new List<string>(); int waveOutDevicesCount = waveOutGetNumDevs(); //get total if (waveOutDevicesCount > 0) { for (int uDeviceID = 0; uDeviceID < waveOutDevicesCount; uDeviceID++) { WAVEOUTCAPS waveOutCaps = new WAVEOUTCAPS(); waveOutGetDevCaps(uDeviceID, ref waveOutCaps, Marshal.SizeOf(typeof(WAVEOUTCAPS))); string devnameandid = "Device ID " + uDeviceID + ": " + waveOutCaps.szPname; OutputDeviceNames.Add(devnameandid.Trim()); } } return OutputDeviceNames; }