Until now we have considered only monaural sounds, however the very same principles apply to stereophonic sounds. The advantage of stereo sound is that it allows a sound to be “positioned” from left to right. The human ear determines the position of a sound, in part, by the relative intensities of the sound in the left and right ears. Stereo sounds have two independent channels, one for each ear.
Pan是指左右声道的位置,不同的乐器在乐队中的声相摆位也是不同的,不是所有乐器都放在左右声道的中间,这在实际操作中就会慢慢总结出它的规律。
The positioning of a sound in stereo is known as “panning” (the audio counterpart to the cinematographic term). Pan can be static, or it can change in different ways. Listen carefully to one of your favorite rock songs (it's easier using headphones). You will notice that, even if it was recorded in a studio, the pan is laid out as if it were on stage. You will likely hear the lead singer front and center (equal in both channels), a guitar moved to one side a bit and another guitar or bass moved in the other direction, or some similar stage configuration. The drumset is an interesting case, as individual drums may even have different pans. Pan is also put to artistic use in some songs. Sounds can sweep back and forth, or sounds that respond to each other can be placed on opposite sides. A famous example of the latter is the opera section of Queen's Bohemian Rhapsody.
It's tempting to think that we can move a sound by simply scaling each channel linearly. That is, if we want a sound that appears to be shifted to the left by 1/4 we can multiply the input sequency by 3/4 for the left channel and 1/4 for the right channel. However, this is not the case. The human ear doesn't perceive the amplitude directly, but rather the intensity (which is related to the square of the amplitude). In order to find a proper scaling, the sum of the squares of both sides must remain constant. Conveniently, we know the identity that:
sin^2(t) + cos^2(t) = 1
很容易认为我们可以移动声音通过简单地线性调节每个声道。也就是,如果我们想要一个声音左移1/4位置出现,我们可以对于左声道乘以输入序列3/4,并对右声道1/4。可是,情况并非如此。人的耳朵不是直接感知振幅,而是强度(和振幅的平方有关)。为了找出一个合适的调节,两边的平方和必须保持为常量。我们常知的恒等式:
sin^2(t) + cos^2(t) = 1
We consider t in the range [0,pi/2]. In this interval, sin(t) increases from 0 to 1 and cos(t) decrease from 1 to 0. Thus we can use one factor to scale each channel. Also, for simplification let us consider:
sin^2(u*pi/2) + cos^2(u*pi/2) = 1
我们考虑t在[0,pi/2]。在这个间隔里,sin(t)从0到1,而cos(t) 从1到0.因此我们可以使用一个因素来调节每个声道。为了简化让我们来考虑:
sin^2(u*pi/2) + cos^2(u*pi/2) = 1
In this form, we can simply work with u in the range [0,1]. Intuitively(直观地), we let 0 mean “all the way to the left”, 1 mean “all the way to the right”, and everything else is a floating point value inbetween determining how the sound is scaled in each channel. The sound in the left channel is scaled by cos(u*pi/2) and the right channel by sin(u*pi/2). Thus, to achieve the above example of moving a sound 1/4 to the left, we can use u = .25. The left channel contains the sound scaled by cos(.25*pi/2) = 0.9239, and the right channel by sin(.25*pi/2) = 0.3827.
在这个形式中,我们可以用u在[0,1]的范围来简化工作。直观地,我们设0表示“左声道”,1表示“右声道”,其他的是一个在此之间的浮点数来决定如何在各声道间调节声音。在左声道的声音通过cos(u*pi/2)来调节以及右声道通过sin(u*pi/2)来调节。因此,要实现以上向左移动1/4的声音例子,我们可以使用u=.25。左声道包含了通过cos(.25*pi/2) = 0.9239调节的声音,右声道则包含了通过sin(.25*pi/2) = 0.3827调节的声音。
Of course, to achieve truly real-sounding stereo effects, there are other factors to consider like change in delay times caused by moving the source, or changes in acoustical properties of the room based on the position of the sound. We will not consider such factors, but it is important to know of their existence. Students should take special note that the input of the pan calculation if a mono sequence, and that the operation transforms the mono signal into a stereo signal. This means that such a routine should return a new array, rather than modifying the source array.
当然,为了实现真正实际音响的立体声效果,还要考虑其他的因素如由移动声源产生的延迟时间的改变,或者是在房间中基于声音位置的声学性质的改变。我们将不会考虑这些因素,但是很重要要了解它们的存在。学生应该特别注意位置计算的输入是否为单声道学列,并且该操作将单声道信号转换为立体声信号。这意味着这样的程序应该返回一个新数组,而是修改源数组。