public WaveFormatExtensible(ESampleRate rate, EBitDepth bits, ESpeakerConfiguration channelMask, Guid subFormat) : base(rate, bits, channelMask, WaveFormatEncoding.Extensible, Marshal.SizeOf(typeof(WaveFormatExtensible))) { wValidBitsPerSample = (short)bits; dwChannelMask = (int)channelMask; this.subFormat = subFormat; }
public void SetSampleRate(ESampleRate sampleRate) { lock (lockObject) { switch (sampleRate) { case ESampleRate.Sps_49K: //设置49K Hz 采样率 g_CtrlByte0 &= 0xf0; g_CtrlByte0 |= 0x0e; MyDLLimport.USBCtrlTrans(0x94, g_CtrlByte0, 1); break; case ESampleRate.Sps_96K: //设置96K Hz 采样率 g_CtrlByte0 &= 0xf0; g_CtrlByte0 |= 0x04; MyDLLimport.USBCtrlTrans(0x94, g_CtrlByte0, 1); break; case ESampleRate.Sps_781K: //设置781K Hz 采样率 g_CtrlByte0 &= 0xf0; g_CtrlByte0 |= 0x0c; MyDLLimport.USBCtrlTrans(0x94, g_CtrlByte0, 1); break; case ESampleRate.Sps_12M5: // 设置12.5M Hz 采样率 g_CtrlByte0 &= 0xf0; g_CtrlByte0 |= 0x08; MyDLLimport.USBCtrlTrans(0x94, g_CtrlByte0, 1); break; case ESampleRate.Sps_100M: //设置100M Hz 采样率 g_CtrlByte0 &= 0xf0; g_CtrlByte0 |= 0x00; MyDLLimport.USBCtrlTrans(0x94, g_CtrlByte0, 1); break; default: break; } } }
protected WaveFormat(ESampleRate rate, EBitDepth bits, ESpeakerConfiguration channelMask, WaveFormatEncoding formatTag, int totalSize) { channels = ChannelsFromMask((int)channelMask); if (channels < 1) { throw new ArgumentOutOfRangeException(nameof(channelMask), "Channels must be 1 or greater"); } SampleRate = (int)rate; BitsPerSample = (short)bits; cbSize = 0; //blockAlign = (short)(channels * (bitsPerSample / 8)); //avgBytesPerSec = samplesPerSec * blockAlign; this.formatTag = formatTag; cbSize = (short)(totalSize - Marshal.SizeOf(typeof(WaveFormat))); }
public WaveFormat(ESampleRate rate, EBitDepth bits, ESpeakerConfiguration channelMask) : this(rate, bits, channelMask, WaveFormatEncoding.Pcm, Marshal.SizeOf(typeof(WaveFormat))) { }
/// <summary> /// Creates a new WaveFormatExtensible for PCM /// WMMEDIASUBTYPE_PCM("00000001-0000-0010-8000-00AA00389B71") /// </summary> public WaveFormatExtensible(ESampleRate rate, EBitDepth bits, ESpeakerConfiguration channelMask) : this(rate, bits, channelMask, new Guid("00000001-0000-0010-8000-00AA00389B71")) { }