simulating directional interference to evaluate model performance I have a model for audio processing. The model receives as input, a source, convolved with a room impulse response (RIR). I would like to test the performance of the model against inputs containing directional interference. The sources and interferences are simply audio recordings (for example human speech, a dig bark, car engine, etc.). both source and interference are convolved with two different RIRs (with respect to angle) and then a gain $A$ is applied to the noise in order to control the desired SIR. 

The signals power: $P_s(t)=mean(x^2(t))$

The interference (noise) power: $P_n(t)=mean(n^2(t))$

The amplified interference power: $P_{An}(t)=mean(A^2n^2(t))=A^2mean(n^2(t))=A^2P_n(t)$

And if we want to isolate $A$, we have:
$$SIR=10 \log\left(\frac{P_s(t)}{A^2P_N(t)}\right)$$
$$A=\sqrt{\frac{P_s(t)}{10^{\frac{SNR}{10}}P_N(t)}}$$

Now, considering I am working from a dataset of audio files with variable length, will this not cause a problem due to the averaging process? For example, if the interference is of length $T_1$ and the source is of length $T_2&gt;T_1$. The interference will be of worst than the desired SIR in the interval $0&lt;t&lt;T_1$ and better in the interval $T_1&lt;t&lt;T_2$. 


Is my thought process correct?
Is there a known method of dealing with such a problem? 
How do I set the correct SNR for such an experiment?
You do need to be careful how exactly you define the SNR. I think you are actually talking about SIR (signal to interference ratio). The way you describe it, it sounds like you plan to just compute the power (time averaged energy) emitted by the signal and interference and use that to get after the SIR. This would be fine but, as you mentioned, sometimes the interference is not present. I might think about using a different definition such as instantaneous SIR, since it sounds like sometimes you have signal + interference and sometimes it is just signal. For this reason, I'm not convinced that computing the power as you described is the right thing to do. 

I would suggest doing this: take the source audio file and interference audio file, figure out which is longer, zero pad the shorter one so they are of equal length. Now compute the metric, "sample-by-sample SIR", by doing $\frac{s[n]^2}{i[n]^2}$. Just be careful when $i[n]=0$. This is where knowledge of the noise (real noise, not interference) would be helpful so that you could ideally report SINR (signal to interference plus noise ratio) and avoid the denominator being $0$ problem.