Relationship between Frequency response, magnitude spectrum and gain
ok let me give you a practical (discrete-time) example. 

Consider a system with input-output relation of the form
$$ y[n] = x[n] + 0.5  x[n-1] + 0.25 x[n-2] $$

This input-output relation satisfies linearity and time-invariance properties and hence defines an LTI (linear time invariant) system and therefore it has an impulse response $h[n]$ found to be : 
$$h[n] = \delta[n] + 0.5 \delta[n-1] + 0.25 \delta[n-2] $$

Which signifies an FIR (finite impulse response) filter. Now since the system has an impulse response, then taking its Fourier transform will give us the system's so called complex valued Frequency Response function, denoted as $H(\omega)$ :

$$H(\omega) = \sum_n h[n] e^{-j \omega n} $$

For the above system, the frequency response can be shown to be:

$$ H(\omega) = 1 + 0.5 e^{-j \omega} + 0.25 e^{-j2\omega} $$

The magnitude of $H(\omega)$ signifies the (linear) gain that the LTI system applies to its input at the frequency $\omega$. For example, if $ |H(\omega)| = 0$ the system completely attenuates the input at that frequency, or if $H(\omega) = 1$ the signal passes unaltered and if $ |H(\omega)| = 10 $ then the system applies a linear gain of $10$ which corresponds to a dB scale of $20$ at that frequency.

Let's find the magnitude of the frequency response $H(\omega)$ :

$$
\begin{align}
H(\omega) &amp;= 1 + 0.5 e^{-j \omega} + 0.25 e^{-j2\omega} \\
&amp;= 1 + 0.5 (\cos(\omega)-j\sin(\omega) ) + 0.25 (\cos(2\omega)-j\sin(2\omega) ) \\
&amp;= [ 1 + 0.5 \cos(\omega) + 0.25 \cos(2\omega)] -j [0.5 \sin(\omega) + 0.25 \sin(2\omega) ] \\
&amp;= A(\omega) - j B(\omega) \\
|H(\omega)| &amp;= \sqrt{ A^2(\omega) + B^2(\omega) } \\
|H(\omega)| &amp;= \sqrt{ [ 1 + 0.5 \cos(\omega) + 0.25 \cos(2\omega)]^2 + [0.5 \sin(\omega) + 0.25 \sin(2\omega) ]^2 } \\
\end{align}
$$

with the help of a computer you can evaluate this frequency response magnitude at any frequency you want and compute the gain of that filter that it applies to any input frequency at that frequency. Below figure shows the Frequency Response magnitude of this system (evaluated and plotted using Matlab)



As you can see, the gain is about $1.8$ at frequencies close to zero radian per sample, and the gain is about unity at frequencies close to $0.5 \pi$ radians per sample. Most often but not always, this gain is defined in terms of a dB (deci Bell) scale (instead of a linear one) using the formula:

$$ \text{Gain_dB} = 20 \log_{10}( \text{Gain_linear}) = 20 \log_{10}( |H(\omega)|) $$

which is plotted in the figure below:



AS you can see, at the frequency about $0.5 \pi$ radians per sample, where the linear gain is about $1$, the corresponding deciBell gain is about $0$ dB.