]> git.sesse.net Git - nageru-docs/blob - audio.rst
Write about CasparCG integration.
[nageru-docs] / audio.rst
1 Audio
2 =====
3
4 Audio is the most important part of video. It is also the most
5 neglected part in most amateur productions; it is easy to care
6 about full-HD productions but never remember to give the speaker
7 a microphone. Your stream can live with blurry or murky pictures,
8 but it cannot live with people not hearing what's being said.
9
10 Nageru aims to give the operator meaningful, useful controls for
11 processing and mixing audio, with a focus on voice. There are two
12 modes for audio processing, namely *simple* and *multichannel*;
13 they are selectable from the audio menu.
14
15 Be aware that a mix that sounds good on a PA system will not
16 necessarily sound good on a stream; PA systems often have rather
17 different audio characteristics than a set of home speakers or
18 headphones, and there will also frequently be other sounds in the
19 room that remove some of the typical “dryness”. However, for simple
20 use, reusing such a mix isn't the worst choice you can make.
21
22
23 Simple mode
24 -----------
25
26 **Simple** audio mode is the default, and was the only mode available
27 up until Nageru 1.4.0. Despite its name, it contains a powerful
28 audio processing chain; however, in many cases, you won't need to
29 understand or twiddle any of the knobs available.
30
31 Simple mode allows input from only a single source, and that source
32 has to be one of the capture cards. (You choose which one by right-clicking
33 on its channel and selecting it as audio source.) The two typical
34 cases where this is useful are:
35
36   * When you simply take in audio from one of the cameras,
37     possibly by way of external microphone, or
38   * When you have an external mixer and can embed its output
39     in one of the video inputs.
40
41 If you want more than one audio source at a time, or if you want
42 to use ALSA inputs, you will need to use multichannel mode; it is
43 more complicated, but it is a strict superset of what the simple mode
44 can do. (In fact, simple mode constructs a multichannel setup
45 behind-the-scenes and then runs the multichannel audio code.)
46
47
48 .. _audio-meters:
49
50 Audio meters
51 ------------
52
53 .. image:: images/level-meters.png
54
55 When setting overall audio levels, there are two important goals:
56 To keep a reasonable **perceived loudness**, and to **avoid clipping**.
57 Both are more subtle to measure than one would initially assume,
58 and there are many ways to misstep. In particular, pretty much any
59 naïve way of measuring loudness will fail; human hearing is, for instance,
60 much more sensitive in some frequencies than others.
61
62 `EBU R128 <https://tech.ebu.ch/loudness>`_ provides solid solutions
63 to both problems. It specifies a precise algorithm to calculate a
64 both *momentary* loudness (over short and medium time intervals;
65 Nageru uses the short measurement), and a *loudness range* over an
66 arbitrary amount of time. The loudness is measured in LU (loudness
67 units), which is a relative unit very much like decibels; there's
68 also LUFS (loudness unit relative to full scale), which is number of
69 LU compared to a given reference.
70
71 EBU R128 specifies a *target loudness* (0 LU) of -23 LUFS +/- 1 LU;
72 if you keep your stream within this and don't have a huge range
73 in general, it will have a reasonable loudness on most viewers'
74 setups. The left meter shows the momentary loudness (over the short
75 400 ms intervals), and the right meter shows the loudness range,
76 with the target shown as a box. If you are within the target,
77 the box turns green; otherwise, it is red. Both meters show
78 1 LU as one segment, with the highest value being +9 LU
79 (compared to the reference level) and the lowest being -18 LU.
80
81 Even if the overall loudness is correct, one needs to avoid clipping;
82 if samples go outside the allowed range, it will sound as clicking
83 or popping (or if many do, as extreme distortion). However,
84 just measuring the value of every single sample is not good enough;
85 since the client might do its own resampling and processing,
86 we also need to account for *inter-sample peaks*. Nageru, in line
87 with R128 recommendations, oversamples the audio by 4x and writes
88 the highest peak (in dBFS) below the left meter. Anything above
89 the R128 limit of -0.1 dBFS will make the meter turn red to alert
90 the operator that clipping has occurred. (In practice, this should
91 rarely happen due to the limiter; see the next section.)
92
93 You can click the reset (RST) button to reset all the meters, including
94 the peak measurement.
95
96 Finally, the very top contains a **correlation meter** measuring
97 the correlation between the left and right channel, which is
98 useful for checking the stereo image. It goes from -1 at the very
99 left (the channels are exact opposites of each other), via 0 in
100 the middle (the channels are totally uncorrelated), to +1 at
101 the very right (the channels are exactly the same). All of these
102 are indications of common issues:
103
104   * A correlation meter that sits at exactly zero typically means
105     either the left or the both channel (or both) is silent.
106   * A correlation meter that sits at exactly +1 typically means
107     you are sending a mono stream. This could be intentional
108     (if you e.g. have only a single microphone), but if not,
109     it could indicate either a loose connector or stereo channels
110     panned wrong.
111   * Finally, a correlation meter that sits at negative values
112     for longer periods of time indicate that one of the channels
113     is inverted (the phase is wrong), and could sound odd on
114     speaker setups. However, certain kinds of reverb or other
115     effects could also cause this, so it could be benign.
116
117 A healthy stereo stream will usually have a correlation somewhere
118 around 0.7–0.8, and this section is marked in green.
119
120 .. _audio-strip:
121
122 The audio strip
123 ---------------
124
125 .. image:: images/audio-strip.png
126
127 The audio strip contains controls for the processing chain for the audio from
128 start to end, left to right. Note that by default, everything is enabled;
129 if you have a pre-made audio mix that you are confident that you
130 want 1:1 into the stream, you can start Nageru with the “--flat-audio”
131 flag, that instead starts with everything disabled.
132
133 The first step in the pipeline is a **lo-cut** (or equivalently,
134 highpass) filter. The exact cutoff frequency is a bit a matter
135 of taste (and also depends on the speaker), but the main point
136 is that it gets rid of low-frequency hum and a lot of the background
137 noise that is not related to the speaker's voice. (If you were
138 producing music, you'd probably want it there to make room for
139 music *under* it, but the you'd want it higher than the default 120 Hz.)
140
141 Next comes a chain of no less than four compressors. They are
142 based on the same basic structure, but have very different settings,
143 and fill very different roles.
144
145 The first compressor is the **gain staging**, or auto-leveler;
146 it is very slow, with 500 ms attack time and 20 second release time.
147 Its purpose is to set the overall level for the next compressor
148 in the chain (so that it is slightly over its threshold);
149 if you have a pretty consistent input signal, you can uncheck
150 the “Auto” box and just set a static value manually.
151
152 The second compressor is the **actual compressor**. It is much
153 faster, with typical voice settings (5 ms attack, 40 ms release).
154 It has the effect of making the voice sound a bit tighter,
155 more level and overall better; if you have multiple things
156 in the mix, it will also bring them somewhat closer together.
157 (In general, a compressor gives the signal less dynamic range
158 by making it quieter, which allows you to gain it more up in
159 a later stage, so that it can get louder overall. It's a bit
160 paradoxical if you're not used to it.)
161
162 You can adjust the threshold if you wish, or disable the compressor
163 altogether if your signal is already mastered. Note that if the
164 gain staging is not set so that this compressor gets an input signal
165 that's loud enough, it won't do anything to it.
166
167 At this point, the mastering section begins; for simple audio,
168 the distinction won't matter, but for multichannel, the previous
169 effects are separate per-bus and the remaining are applied
170 after the mix. (More on this below.) The mastering section begins
171 with a **limiter**, basically a compressor with very high ratio.
172 It's there as an emergency brake for really loud sounds
173 that got through the other compressors—a classic example is a
174 speaker suddenly coughing, or a very loud bass drum. This prevents
175 both clipping and blowing out the speakers' ears.
176
177 At this point, the audio signal is *almost* where we'd like it
178 to be, but the overall sound level might not be quite right.
179 All the previous compressors have been working in the objective
180 domain, but as explained in the :ref:`previous section <audio-meters>`,
181 this does not necessarily correspond to the desired overall
182 audio loudness. (Their default levels have been calibrated so
183 that they end up around 0 LU for typical speech content,
184 but they could easily miss by a few LU in many cases.)
185
186 Thus, there's a final **makeup gain** at the end to compensate
187 for these issues. When the “Auto” checkbox is ticked, which is
188 by default, it will very slowly (filter constant of 30 seconds)
189 adjust itself so that the overall level goes toward 0 LU,
190 ie., the reference level. It is so slow because the R128 calculations
191 inherently must go over a certain amount of time (what we want
192 to change with this gain is the *overall* sound level,
193 not the *immediate* one). In periods where the makeup gain is
194 far off, such as when the stream is all silent, it doesn't update
195 at all. As with the other knobs, you can uncheck the “Auto”
196 checkbox and tune this yourself if you want to.
197
198
199 Multichannel mode
200 -----------------
201
202 **Multichannel mode** expands on simple audio mode by allowing you
203 to have multiple *buses* of audio. (In a sense, it could more accurately
204 be called “multibus mode” instead, but the name would be too confusing.)
205 A bus in Nageru is a pair of channels (left/right), sourced from
206 a video capture or ALSA card. The channel mapping is flexible; my USB
207 sound card has 18 channels, for instance, and you can use that to make
208 several buses. Each bus has a name (for instance, something like
209 “Blue microphone” or “Speaker PC”), which is just for convenience;
210 Nageru doesn't care what you write here, but the labels are useful
211 for the operator.
212
213
214 Input mappings
215 ''''''''''''''
216
217 .. image:: images/input-mapping.png
218
219 The input mapping dialog should be pretty much self-explanatory;
220 you can use the + button to add a new bus, and the - button to remove
221 the currently selected one (you select by clicking on it). The up and
222 down buttons rearrange the order by moving the currently selected bus
223 up or down, if possible. Note that you can create a mono bus by
224 assigning the same input channel to the left and right inputs.
225
226 Because mappings can be tedious to setup, you wouldn't want to set up
227 a complicated one every time you started Nageru. Therefore, mappings
228 can be saved and loaded from disk; the stored file is a
229 `protocol buffer <https://developers.google.com/protocol-buffers/>`_
230 in textual format. You can also load one at start with the
231 “--input-mapping” parameter, which also implies multichannel mode
232 (--multichannel).
233
234 Nageru strives to keep the mapping consistent even
235 in the face of a changed environment—for instance, if you unplug and
236 replug a USB sound card, Nageru will attempt to keep your buses mapped to
237 that card still mapped. (While the card unplugged, the main display will show
238 the relevant buses as “(disconnected)”.) Similarly, if an ALSA device
239 is taken by another program on startup and cannot be accessed by Nageru,
240 it will mark it as “(busy)” and try again in the background. However,
241 there are edge cases where Nageru simply cannot do the right thing,
242 for instance if you unplug two identical cards and plug them back
243 in the reverse order; USB cards don't carry any kind of serial number
244 or other forms of unique identification.
245
246
247 The audio views
248 '''''''''''''''
249
250 .. image:: images/audio-view-selector.png
251
252 Once multichannel mode is active, a little selector shows up to the right,
253 just below the level meters. The arrows (or equivalently, the PgUp/PgDown
254 keys on the keyboard) allow you to select between two views:
255
256   * In the **compact audio view** (which is the default), each bus is
257     represented only by its label, its peak meter (see below) and its
258     fader. This takes up little screen estate, and allows the video channels
259     to be visible. This is the typical view you'd use once you've set up
260     everything and are actually doing live video editing; the controls
261     from the full audio view are still in effect, but you cannot see or
262     interact with them.
263
264   * The **full audio view** contains a lot more controls, but leaves no
265     room for the video channels. These are useful when you are doing initial
266     setup of your mix, or if you want to go back and tune something.
267     The full audio view will be described in detail in the following section;
268     the interpretation of the corresponding controls in the compact audio view
269     is the same.
270
271 .. image:: images/audio-bus-controls.png
272
273 There's one set each of these controls for every bus. The most
274 important parts of the mix are given the most screen estate,
275 so even though the way through the signal chain is left-to-right
276 top-to-bottom, we'll go over it in the opposite direction.
277
278 By far the most important part is the audio level, so the **fader** naturally is
279 very prominent. (Note that the scale is nonlinear; you want more resolution
280 in the most important area.) Changing a fader with the mouse or keyboard is
281 possible, and probably most people will be doing that, but Nageru also
282 supports USB faders (see :ref:`midi-control`). There's a mute button
283 if you just want to silence a bus temporarily; it has exactly the same
284 effect as pulling the fader all the way down, ie., it will make the bus
285 go all silent.
286
287 Then there's the **peak meter** to the left of that. For each bus, unlike
288 for the meters used for mastering (see :ref:`audio-meters`),
289 you don't want to know loudness; you want to know recording levels,
290 so this is a peak meter, *not* a loudness meter. (There's some holdoff
291 so you can see the actual peaks over a short period.) In particular,
292 you don't want the bus to send clipped data to the master
293 (which would happen if you set it too high); Nageru can handle
294 this situation pretty well (unlike most digital mixers, it mixes in
295 full 32-bit floating-point so there's no internal clipping,
296 and the limiter described in :ref:`audio-strip` will usually save you)
297 but it's still not a good place to be in, so if you peak,
298 the **historical peak label** under the meter will go red if it happens.
299 If you want to reset it, click on it using the mouse.
300
301 The peak meter doubles as an input peak check during
302 setup; if you turn off all the effects and set the fader to neutral, you can
303 see if the input hits peak or not, and then adjust it down. Left and right
304 channel are shown separately, so you can see if they are approximately
305 the same level or even completely mono.
306
307 The **compressor** is well-known from the simple audio mode, but in this view,
308 it also has a **reduction meter**, so that you can see whether it kicks in or not.
309 (This is also nonlinear, and each step is marked with number of decibels
310 the compressor had to reduce the signal.) Most casual users
311 would want to just leave the gain staging and compressor settings alone, but
312 a skilled audio engineer will know how to adjust these to each speaker's
313 antics—some speak at a pretty even volume and thus can get a bit of
314 headroom, while some are much more variable and need tighter settings.
315
316 Finally (or, well, first), there's the EQ section. The **lo-cut** is again
317 well-known from the simple audio mode (the filter is separate for each
318 bus, the cutoff **frequency** is the same across all buses),
319 but there's now also a simple **three-band EQ** per bus. Simply ask the speaker
320 to talk normally for a bit, and tweak the controls until it sounds good.
321 People have different voices and different ways of holding the microphone,
322 and if you have a reasonable ear, you can use the EQ to your advantage to
323 make them sound a little more even on the stream. Either that, or just
324 put it in neutral, and the entire EQ code will be bypassed.
325
326 .. _midi-control:
327
328 MIDI controllers
329 ----------------
330
331 If you are doing audio work beyond just setting up a mix and letting it
332 stay there, dragging controls with the mouse can feel limiting. There's
333 a wide range of controllers out there that have physical faders and knobs
334 you can twiddle for a much more tactical feel; all the way up from about
335 $50 to more than $5000. (For reference, Nageru has been tested with the
336 `Akai MIDImix <http://www.akaipro.com/product/midimix>`_ and the
337 `Korg nanoKONTROL2 <http://www.korg.com/us/products/computergear/nanokontrol2/>`_,
338 and both work fine, although the nanoKONTROL2 needs some one-time Korg-specific
339 SysEx commands before the lights and buttons will work with Nageru.)
340 Nageru supports these in multichannel mode only.
341
342 For historical reasons, these speak the MIDI protocol as if they
343 were instruments, and thus, Nageru refers to them as **MIDI controllers**.
344 However, you won't really notice; they come with USB plugs to transport
345 the MIDI data, so you just plug them in and have Nageru automatically
346 talk to them. (For simplicity, Nageru will assume *any* MIDI device
347 connected to your machine is such a controller.)
348
349 Since different controllers have different numbers of faders, knobs,
350 buttons and lights, you will need to make a mapping. However, just like
351 with the audio input mapping, this can be done once and then saved
352 to disk for later loading. (You can load a given mapping on startup
353 using the “--midi-mapping” flag.) The dialog, loaded with the included
354 preset for the Akai MIDImix, looks like this:
355
356 .. image:: images/midi-controller-setup.png
357
358 There are three types of controls, which correspond to different types
359 of MIDI events:
360
361   * **Controllers** map directly to MIDI controllers (the value in the
362     dialog is the controller number), which are continuous
363     values that can take on values from 0 to 127. (Unfortunately, MIDI
364     was made in the 80s, where 7-bit precision was seen as enough.)
365     They are typically used for faders and knobs.
366
367   * **Buttons** are one-shot events that map to MIDI note-on events,
368     and the value in the dialog is the MIDI note number (also from
369     0 to 127). They are similar to mouse buttons in that they don't
370     have an on or off state (the MIDI note-off events are ignored).
371     A typical example would be a mute button that can be pressed to
372     either mute or unmute a channel.
373
374   * **Lights** are *output* events where Nageru can send feedback
375     to the controller (and by extension, the user), represented by
376     MIDI note-on and note-off events (to turn the light on or off).
377     A typical example would be a mute light, that is on when a
378     channel is muted.
379
380 In addition, each event can be *per-bus* or *global*. It can be a bit
381 confusing that even the global events can be set once per-bus,
382 but this is merely a convenience, allowing you to bind multiple
383 physical controls to the same global controller; for global controllers,
384 the bus number(s) you use for your mapping do not matter.
385
386 The combination of controller type and per-bus/global constitutes
387 a **mapping group**, clearly marked and collapsible in the UI.
388
389
390 Creating and updating mappings
391 ''''''''''''''''''''''''''''''
392
393 Unless you have a reference sheet for your MIDI controller, specifying which
394 controller and number numbers the different physical knobs and faders
395 emit, inputting these numbers by hand can be a frustrating procedure.
396 (Actually, even with a reference sheet, it probably is.) Thus, the preferred
397 way is by autosensing; simply select the given mapping with the mouse
398 and use the control you want to bind it to, and Nageru automatically
399 fills it in.
400
401 Also, most devices support many channels, with very similar structure
402 in their controller and/or note numbers. Once you've filled out one
403 and then started filling out another one, Nageru can guess for you;
404 if it thinks it can make a reasonable guess (ie., find a consistent
405 offset from its left or right neighbor), the “Guess bus” and/or
406 “Guess group” buttons will be clickable. This can save considerable
407 amounts of time, although it is advisable to check Nageru's guess for
408 at least the first guessed channel. In particular, some controllers
409 do not have a consistent offset between channels on all the controllers
410 (making “Guess bus” give the wrong answer), just on the controller groups,
411 so there, you must limit yourself to guessing only a single controller
412 group (using “Guess group”).
413
414 Lights currently cannot be learned, so some trial and error is needed.
415 (However, if there are buttons associated with the light, a good place
416 to start is using the same note number.) However, just like the input
417 controllers, they can be guessed once you have all the mapping you want
418 for a neighboring bus and partial information about the current one.
419
420
421 Controller banks, and UI visibility
422 '''''''''''''''''''''''''''''''''''
423
424 Many MIDI controllers do not have enough faders and knobs for every
425 Nageru function you might want to control; some even contain only
426 one fader or one knob. Thus, Nageru supports assigning a physical
427 control to multiple functions, through **controller banks**.
428 If a mapping is assigned to a controller bank, it is only active
429 when that bank is active. The act of switching banks is in itself
430 an action that can be initiated from the MIDI controller; in fact,
431 that is currently the only way to switch them.
432
433 A typical example would be having a knob that in bank 1 is assigned
434 to gain, and in bank 2 to cutoff (which happens to be a global control,
435 as described in the previous section). This way, one can switch between
436 the two banks and have both functions accessible from the MIDI controller.
437 Similarly, buttons can be reused by assigning them to multiple banks.
438
439 Note that when switching banks, the associated controller(s) is
440 *not* immediately updated; this happens only when you move the control.
441 Otherwise, a bank switch would cause a host of unwanted changes,
442 as it is unlikely that you would want the control in the exact
443 same position for the two controllers. (There is a similar problem
444 when starting up Nageru for the first time, where the controllers
445 are not necessarily in the place matching Nageru's startup settings.)
446 Some more expensive controllers support *motorized faders*, where
447 the host can simply tell the control to move to the right place
448 and thus solve the problem, but Nageru does not currently support them.
449
450 .. image:: images/highlight.png
451
452 To help you know which bank is active (or even that you have a MIDI
453 controller connected at all), the currently mapped controller have
454 a green **activity highlight**. When you switch banks, the highlight
455 also updates—a controller is only highlighted if its mapping is
456 active in the currently selected bank. This way, it is easy to see
457 which controllers are currently controllable by MIDI, and which ones
458 that are not.