求助~~ 麦克风和混音mixer只能选择一个。。如用同时捕捉这两路输入。

starcbh 2006-02-17 03:33:23
麦克风和混音mixer只能选择一个。。如用同时捕捉这两路输入??

~~~~~~~~~~~~~~~~~
...全文
217 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
lserlohn 2006-03-22
  • 打赏
  • 举报
回复
应该可以吧,我觉得只要你能够采集到这两路音频,写一个Transform Filter,两个输入Pin一个输出Pin,中间过程的处理,我倒是有个一例子


mix(sample_buffer_t &samples)
{
sample_t buf[NCHANNELS];
int ch, nsample;

int in_ch = in_mode.channels;
int out_ch = out_mode.channels;
int in_nch = in_mode.nchans();
int out_nch = out_mode.nchans();
int in_order[6];
int out_order[6];

memcpy(in_order, in_mode.order, sizeof(in_order));
memcpy(out_order, out_mode.order, sizeof(out_order));

sample_t max;
sample_t factor;
sample_t s;
sample_t *sptr;

sample_t in_levels_loc[NCHANNELS];
sample_t out_levels_loc[NCHANNELS];

memset(in_levels_loc, 0, sizeof(in_levels_loc));
memset(out_levels_loc, 0, sizeof(out_levels_loc));

sample_t release_factor;

if (release < 1.0)
release = 1.0;

release_factor = pow(release, double(NSAMPLES) / 48000);

///////////////////////////////////////
// Reorder matrix

mixer_matrix_t m;
memset(&m, 0, sizeof(m));
int ch1, ch2;
for (ch1 = 0; ch1 < in_nch; ch1++)
for (ch2 = 0; ch2 < out_nch; ch2++)
m[ch1][ch2] = matrix[in_order[ch1]][out_order[ch2]] * in_gains[in_order[ch1]] * out_gains[out_order[ch2]];

///////////////////////////////////////
// Adjust gain

///////////////////////////////////////
// Adjust gain

if (auto_gain && !normalize)
if (gain * release_factor > master)
gain = master;
else
gain *= release_factor;

///////////////////////////////////////
// Input levels

// optimize: expand channels cycle
for (ch = 0; ch < in_nch; ch++)
{
max = 0;
sptr = samples[ch];
for (nsample = 0; nsample < NSAMPLES2/8; nsample++)
{
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
}
in_levels_loc[ch] = max;
}

max = in_levels_loc[0];
for (ch = 1; ch < in_nch; ch++)
if (max < in_levels_loc[ch]) max = in_levels_loc[ch];

///////////////////////////////////////
// DRC

// drc_power means level increase at -50dB
if (drc_on)
if (drc_level * release_factor > pow(max/in_mode.level, -log10(drc_power)*20/50))
drc_level = pow(max/in_mode.level, -log10(drc_power)*20/50);
else
drc_level *= release_factor;
else
drc_level = 1.0;

///////////////////////////////////////
// Mix samples

// optimize: do not multiply by nulls (most of matrix)
factor = gain * drc_level * out_mode.level / in_mode.level;
memset(buf, 0, sizeof(buf));
for (nsample = 0; nsample < NSAMPLES2; nsample++)
{
for (ch = 0; ch < out_nch; ch++)
{
buf[ch] = 0;
for (ch2 = 0; ch2 < in_nch; ch2++)
buf[ch] += samples[ch2][nsample] * m[ch2][ch];
}
for (ch = 0; ch < out_nch; ch++)
samples[ch][nsample] = buf[ch] * factor;
}

///////////////////////////////////////
// Output levels

memset(out_levels_loc, 0, sizeof(out_levels_loc));
for (ch = 0; ch < out_nch; ch++)
{
max = 0;
sptr = samples[ch];
for (nsample = 0; nsample < NSAMPLES2/8; nsample++)
{
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
if (fabs(*sptr) > max) max = fabs(*sptr); sptr++;
}
out_levels_loc[ch] = max;
}

max = out_levels_loc[0];
for (ch = 1; ch < out_nch; ch++)
if (max < out_levels_loc[ch]) max = out_levels_loc[ch];

///////////////////////////////////////
// Auto Gain Control

if (auto_gain)
{
if (max > out_mode.level)
{
factor = out_mode.level / max;
gain *= factor;
if (gain < min_gain)
{
factor *= min_gain / gain;
gain = min_gain;
}

max *= factor;

sptr = (float *)samples;
nsample = out_nch * NSAMPLES2 / 8;

while (nsample--)
{
*sptr++ *= factor; *sptr++ *= factor;
*sptr++ *= factor; *sptr++ *= factor;
*sptr++ *= factor; *sptr++ *= factor;
*sptr++ *= factor; *sptr++ *= factor;
}
}
}

///////////////////////////////////////
// Clip
// should be rare

if (max > out_mode.level)
{
sptr = (sample_t *)samples;
nsample = out_nch * NSAMPLES2;

while (nsample--)
{
s = *sptr;
if (s > +out_mode.level) *sptr = +out_mode.level;
if (s < -out_mode.level) *sptr = -out_mode.level;
sptr++;
}
}

///////////////////////////////////////
// Normalize output levels

for (ch = 0; ch < NCHANNELS; ch++)
{
if (CH_MASK(in_order[ch]) & in_ch)
{
in_levels_loc[ch] /= in_mode.level;
in_levels_loc[ch] *= in_gains[in_order[ch]];
if (in_levels_loc[ch] > in_levels[in_order[ch]])
in_levels[in_order[ch]] = in_levels_loc[ch];
}

if (CH_MASK(out_order[ch]) & out_ch)
{
out_levels_loc[ch] /= out_mode.level;
if (out_levels_loc[ch] > out_levels[out_order[ch]])
out_levels[out_order[ch]] = out_levels_loc[ch];
}
}

具体的你到Sourceforge.net上搜索一个叫matrix mixer的例子看看好了,我是搞视频混合的,对这个也不是太了解。
zcd_jimy 2006-03-22
  • 打赏
  • 举报
回复
个人认为是不行的, 在windows中, 录音选择音源时, 都是只能选其中一个.
如果非要这样, 那肯定要声卡支持同时采集两路音源.
cx0928 2006-02-22
  • 打赏
  • 举报
回复
可以考虑使用硬件混响器
ccxian123 2006-02-21
  • 打赏
  • 举报
回复
采集两个出来,再混合应该可以的。
zhaojian999 2006-02-21
  • 打赏
  • 举报
回复
我觉得也不行
蒋晟 2006-02-21
  • 打赏
  • 举报
回复
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/enumerating_capture_devices.asp
DentistryDoctor 2006-02-18
  • 打赏
  • 举报
回复
这个不行吧。

2,543

社区成员

发帖
与我相关
我的任务
社区描述
专题开发/技术/项目 多媒体/流媒体开发
社区管理员
  • 多媒体/流媒体开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧