如何做单声道到立体声转换? [英] how to do mono to stereo conversion?

查看:361
本文介绍了如何做单声道到立体声转换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用libswresample从任何PCM格式44.1,16位INT重新采样,立体声。

I am using libswresample to resample from any PCM format to 44.1kHz, 16bit int, stereo.

我是用所产生的音频流的一些音频音量分析玩弄,我想通了,万一我有44.1kHz的,16位INT单为源,我也大致表现公式:

I was playing around with some audio volume analyzing of the resulting audio stream and I figured out that in case I have 44.1kHz, 16bit int mono as the source, I have roughly the formular:

leftSample = sourceSample / sqrt(2);
rightSample = sourceSample / sqrt(2);

但我期待:

leftSample = sourceSample;
rightSample = sourceSample;

(如果源是立体声的,我只是有 leftSample = leftSourceSample; rightSample = rightSourceSample;

我的期望来自几个方面:

My expectation comes from several sources:


  1. 那是怎么我自己直接的解决方案可能早就

  2. 我搜索了一下四周,其他人似乎做同样的,例如这里

  3. 在一个很普通的播放增益实现(唯一一个我真的知道,使用基本无处不在,我想最初从mp3gain;一个副本可以看到的这里),它也做的:

switch ( num_channels) {
case  1: right_samples = left_samples;
case  2: break;
default: return GAIN_ANALYSIS_ERROR;
}

这是电除尘器。相关的,因为播放增益通过使用标准声(粉红噪声这种实现校准,可下载的这里),这是单声道。

This is esp. relevant because ReplayGain was calibrated by this implementation using a reference sound (a pink noise, can be downloaded here) which is in mono.

在播放增益的规范,它也被计算如下(见这里)。

In the ReplayGain specification, it is also calculated like this (see here).

我的困惑提出后,我试图执行播放增益自己,我偶然发现了这一点。

My confusion raised after I tried to implement ReplayGain myself and I stumbled upon this.

所以,一些问题:


  1. 为什么libswresample做到这一点?

  2. 这是预计在libswresample还是错误? (我试图从源头上理解(如这里 ),但我还没有完全理解这一切呢。)我加了一个bug报告这里

  3. 什么是正确的解决方案?

  4. 什么是其他球员在做什么?

  5. 是什么,如果你喂单一样本给它一个共同的声卡做什么?

  1. Why does libswresample do this?
  2. Is this expected in libswresample or a bug? (I'm trying to understand from the source (e.g. here) but I haven't fully understood it all yet.) I added a bug report here.
  3. What is the "right" solution?
  4. What are other players doing?
  5. What is a common soundcard doing if you feed mono samples to it?

(我也张贴在<一个这个问题href=\"http://avp.stackexchange.com/questions/4910/how-to-do-mono-to-stereo-conversion\">avp.stackexchange现在,也许这是一个更好的地方要问这个,不知道)

(I also posted this question on avp.stackexchange now; maybe that is a better place to ask about this, not sure.)

推荐答案

实施一个正确实施平移单声道信号转换为立体声场。如果您平移,而是一路向左或向右所有你想要的方式就好像它在中间被平移的信号强度是一样的,所以声像被设定为离开将是:

The implementation is one correct implementation of "panning" a mono signal into a stereo field. If you pan, instead all the way left or all the way right you want the signal strength to be the same as if it had been panned in the middle, so panned left would be:

//left panning
leftSample = sourceSample;
rightSample = 0;
//right panning
leftSample = 0;
rightSample = sourceSample;
//center panning (same power as hard left/right conversion/)
leftSample = sourceSample * sqrt(2)/2;
rightSample = sourceSample * sqrt(2)/2;

不过,如果你是从单声道转换为立体声,你的直觉是正确的。没有任何理由降低水平,因为你不会直接比较集中,以平移信号。去最好的办法是离开满员信号:

However, if you are converting from mono to stereo, your intuition is correct. There no reason to lower the level since you wont be comparing centered to panned signals. The best way to go is to leave the signal at full strength:

//mono to stereo conversion
leftSample = sourceSample;
rightSample = sourceSample;

这也有可能是他们留下一些后S / R转换增益变化,但水平显得随意。

It's also possible that they are leaving some post-s/r conversion gain change, but the level seem arbitrary.

这篇关于如何做单声道到立体声转换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆