简体   繁体   English

从第二个声卡捕获音频时出现问题

[英]Problems capturing audio from the second sound card

I have written a program that captures sound via waveInOpen() in Wuindows. 我编写了一个程序,该程序可以在Wuindows中通过waveInOpen()捕获声音。 It works great on the michrophone-device on the main-board, but when I try to capture from the second sound-card, I get only [static] noise. 它在主板上的麦克风电话设备上效果很好,但是当我尝试从第二张声卡捕获时,我只会得到[静态]噪声。 Recording with SoundRecorder works great on both cards. 与SoundRecorder记录在两张卡的伟大工程。 Does any1 know if there are any known problems with waveInOpen() and multiple input-devices? any1是否知道waveInOpen()和多个输入设备是否存在任何已知问题?

The code that opens the input-device looks like this: 打开的输入装置的代码如下所示:

void Audio::OpenDevice(const int device,
        const Audio::SamplingRate samplingRate) 
        throw (Exception, std::exception)
{
 switch(samplingRate)
 {
...
 case AUDIO_16BIT_44KHZ_STEREO:
  bits_per_sample_ = 16;
  hertz_ = 44100;
  channels_ = 2;
  break;
...
 default:
  throw Exception("Audio::OpenDevice(): Invalid enum value");
 }

 // Open the device
 const UINT_PTR dev = (-1 == device) ? (UINT_PTR)WAVE_MAPPER : (UINT_PTR)device;
 WAVEFORMATEX wf = {0};
 wf.wFormatTag = WAVE_FORMAT_PCM;
 wf.nChannels = channels_;
 wf.wBitsPerSample = bits_per_sample_;
 wf.nSamplesPerSec = hertz_;
 wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8;
`
 const MMRESULT result = waveInOpen(&hwi_, dev, &wf, 
  (DWORD_PTR)OnWaveEvent, (DWORD_PTR)this, CALLBACK_FUNCTION);
 if (MMSYSERR_NOERROR != result)
  throw Exception("waveInOpen()");

 std::cout << "Audio: Sampling at " << hertz_ << " hertz from " 
  << channels_ << " channel(s) with " << bits_per_sample_
  << " bits per sample. "
  << std::endl;
}

Did you check the microphone gain settings, mixer settings, that the microphone hardware you're using is compatible with the input you have it hooked to, etc? 您是否检查了麦克风增益设置,混音器设置,所使用的麦克风硬件是否与您所连接的输入兼容,等等? Hooking most microphones to a line in connection does not work well. 将大多数麦克风钩到连接的线路上效果不佳。 The microphone doesn't have enough output voltage to drive that kind of input. 麦克风没有足够的输出电压来驱动这种输入。

My guess (purely a guess) is that the bit depth or sample rate is somehow incorrect. 我的猜测(纯粹是猜测)是位深度或采样率不正确。 If you are using 16/44100, then I would assume it is supported (pretty common). 如果您使用的是16/44100,那么我认为它是受支持的(非常常见)。 But maybe the sound card is not set for those rates. 但是,也许没有为这些费率设置声卡。 I have an external Edirol sound card that I have to physically turn on and off when I change bit depth (and adjust a separate switch on it). 我有一个外部Edirol声卡,当我更改位深度(并调整其上的单独开关)时,必须物理地打开和关闭它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM