Channels and panning - Quefumas/gensound GitHub Wiki
Here I concentrate some idioms for handling channels and panning. Even though the discussion deals mostly with Stereo, Gensound is built to handle any number of channels.
Stereo Signal from an empty Signal
If we previously define signals for the various channels, they can be combined in more than one way:
s = Signal() # start with a fresh Signal
s[0] = l_signal
s[1] = r_signal
s += center_signal*Gain(-3) # add center signal, and compensate
Adding channels to a mono Signal
sig = ... # start with mono Signal
sig[1] = ... # add a new R channel (previous content of sig now occupies L channel)
sig += ... # this mixes into both channels now
Mixing into mono
w = WAV(kushaura)
w_mono = w[0] + w[1] # mix into mono
w_mono *= 0.5 # attenuate to compensate
Reorder channels
w = WAV(kushaura)
w[0], w[1] = w[1], w[0]
Repan
Relocate channels using sig = ... # create Signal with 3 channels for example
sig *= Repan(1, 2, 2, 0, None, 1)
# now sig has 6 channels:
# channels 0,5 are copies from the previous channel 1;
# channels 1,2 are copies from the previous channel 2;
# channel 3 is a copy of previous channel 0;
# and channel 4 is empty.
TODO this Transform needs treatment both for bugs and for usability, also better example.
Pan mono Signals into stereo
Using the Pan
Transform, it's easy to pan mono signals into a stereo soundscape.
ch1 *= Pan(-50) # this results in a stereo Signal
ch2 *= Pan(50) # panning ranges from -100 (hard L) to 100 (hard R)
master = ch1 + ch2 # stereo signal with both channels panned as desired
TODO debug this Transform
Change Pan Law
If using Pan
, the pan law can be changed as follows:
Pan.panLaw = -4.5 # default is -3; most setups required between -3 and -6
Multichannel Panning
Override the scheme
argument of Pan
to customize the panning behaviour, or expand it to include more channels.
It can be given any function returning a tuple/list of dB values according to the desired number of output channels.
This function is then fed with the first argument of Pan
, which may also be parametric (Curve
).
It can also be designed to receive more than one argument, thus allowing the panning behaviour to be multidimensional (for example, instead of one-dimensional L-R panning, one could place the audience in a rectangular room surrounded by multiple speakers, in which case it would make more sense to represent Panning locations as 2-dimensional (x,y)
coordinates). More on this later.
TODO This is already possible but not well-documented