2013-08-17 4 views
0

레코드 프로그램에 NAudio를 사용하고 싶습니다만 예기치 않은 제한이 있습니다. NAudio.Wave.WaveIn.GetCapabilities (deviceNumber)는 WaveInCapabilities 구조체를 반환하지만 해당 구조체의 일부 필드 만 공개됩니다.NAudio에서 입력 장치 지원 형식 가져 오기

특히 장치에서 지원하는 형식을 알아야합니다. 해당 정보는 다음 위치에 있습니다.

private SupportedWaveFormat supportedFormats;

공개로 변경하고 NAaudio.dll을 빌드 할 수 있지만 필드가 비공개로 표시된 이유가 있는지 궁금합니다. 아니면 그 정보를 찾을 수있는 다른 곳이 있습니까? 웹에 대한 예제가 있었다

답변

1

, 내가 그것을 편집, 나를 다른 장치에서 모든 capabilites을 얻기 위해이 작동합니다 (그것은 아주 추한하지만 ... 작동) :

using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Runtime.InteropServices; 
using System.Collections; 
namespace _4ch_stream 
{ 
    class clsRecDevices 
    { 


     [StructLayout(LayoutKind.Sequential, Pack = 4)] 
     public struct WaveInCaps 
     { 
      public short wMid; 
      public short wPid; 
      public int vDriverVersion; 
      [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)] 
      public char[] szPname; 
      public uint dwFormats; 
      public short wChannels; 
      public short wReserved1; 
     } 

     [DllImport("winmm.dll")] 
     public static extern int waveInGetNumDevs(); 
     [DllImport("winmm.dll", EntryPoint = "waveInGetDevCaps")] 
     public static extern int waveInGetDevCapsA(int uDeviceID, 
          ref WaveInCaps lpCaps, int uSize); 
     public ArrayList arrLst = new ArrayList(); 
     //using to store all sound recording devices strings 

     static int devcount = waveInGetNumDevs(); 
     public static short[] Mid = new short[devcount]; 
     public static short[] Pid = new short[devcount]; 
     public static int[] DriverVersion = new int[devcount]; 
     public static uint[] Formats = new uint[devcount]; 
     public static short[] Channels = new short[devcount]; 
     public static short[] Reserved1 = new short[devcount]; 

     public int Count 
     //to return total sound recording devices found 
     { 
      get { return arrLst.Count; } 
     } 
     public string this[int indexer] 
     //return spesipic sound recording device name 
     { 
      get { return (string)arrLst[indexer]; } 
     } 
     public clsRecDevices() //fill sound recording devices array 
     { 
      int waveInDevicesCount = waveInGetNumDevs(); //get total 
      if (waveInDevicesCount > 0) 
      { 
       for (int uDeviceID = 0; uDeviceID < waveInDevicesCount; uDeviceID++) 
       { 
        WaveInCaps waveInCaps = new WaveInCaps(); 
        waveInGetDevCapsA(uDeviceID, ref waveInCaps, 
             Marshal.SizeOf(typeof(WaveInCaps))); 
        arrLst.Add(new string(waveInCaps.szPname).Remove(
           new string(waveInCaps.szPname).IndexOf('\0')).Trim()); 
        Mid[uDeviceID] = waveInCaps.wMid; 
        Pid[uDeviceID] = waveInCaps.wPid; 
        Formats[uDeviceID] = waveInCaps.dwFormats; 
        Channels[uDeviceID] = waveInCaps.wChannels; 
        Reserved1[uDeviceID] = waveInCaps.wReserved1; 
        //clean garbage 
       } 
      } 
     } 
    } 
} 

희망을 도움이되었습니다.

+0

감사합니다. 필자는 형식을 공개하고 재구성하는 작업 만 완료했습니다. – TomJeffries