# How to account for phase and shift when composing a new signal based upon 2 or more recordings?

I have 2 signals that were independently recorded, and want to produce a new signal that would represent what would be recorded if both signal sources were emitting at the same time together. Specifically my case is that I have a recording of dolphins, and a recording of beluga whales and although both recordings were produced independently I would like a sound file with both biologics in the signal.

This post on a MATLAB forum link recommends to multiply the time ordered values together $$x_1(t) \times x_2(t)$$ to produce a new signal as a result of 'mixing'. This blog post link describes the addition of noise as an additive process between the signals. A question on this forum relevant question asks about the composition from multiple signals where the addition is prescribed. But these approaches do not account for phase and I would assume that this would be necessary. It also does not account for the fact that the time of the recording for the onset of each signal greatly affects the alignment of the signals where there is irregular activity. There is quite a large amount of variation in the acoustic activity where the start time changes whether these animal sounds overlap or not.

The approach I currently use, is to take the FFT of each $$x_i(t)$$ separately and then generate signals using iFFT from each FFT output. This produces separate signals that I then add together their values at every time point.

1. Is there a better way to do this?

2. In order to create a more realistic environment would I have to segment the different states of the signals (biologic activity and non-active states) in order to simulate the randomness in their activity. Would that be an approach seen elsewhere? In general a more simulation like approach to account for the stochastic changes in the state of the system where phase then is taken into account?

In EE, waveform mixing is used for wave modulation. It is implemented via mixer circuits whose operation principle can be loosely described as multiplication of currents. It does not apply to your scenario of SPL data acquisition and processing: you have no waves that modulate one another.

Your sound sources being independent and also removed at distances larger than a sound wavelength from each other (1.5 m at 1kHz in water), you can safely ignore phase effects and, specifically, acoustic interference. You can model the composite signal SPL as a linear combination of SPL's of your prerecorded signals.

• so I can add the time domain waveforms directly? I guess the onset for different starting times of the signals will be handled programmatically?
– Vass
Aug 5, 2020 at 3:42
• You adjust sample rates (if those are different) by resampling, calculate linear superposition coefficients for participating signals from physics and geometry of your scenario, and move on. Only take care to work with floating point values or otherwise beware of possible summation overflows for fixed point values. Aug 5, 2020 at 4:00
• just to make sure I understand; 1) 'linear superposition coefficients' this is just the 'a' and 'b' coefficients for the direct addition of the values at each time point? 2) working with floating point numbers, is that when the signal waveforms are between [0,1]? 3) what is the 'summation overflows for fixed point values'?, when the numbers go over the precision of the programming language?
– Vass
Aug 5, 2020 at 14:37
• 1) SPL_{composite_signal} = ax_1 + bx_2; 2) en.wikipedia.org/wiki/Floating-point_arithmetic , section 'Range of floating-point numbers', see also en.wikipedia.org/wiki/IEEE_754 ; 3) en.wikipedia.org/wiki/Fixed-point_arithmetic , section 'Precision loss and overflow' Aug 5, 2020 at 15:22
• If you have fixed-point data and decide to do processing with floating-point numbers, you simply convert fixed-point representation to floating-point representation (putting it bluntly, rather than, say, (short) SPL[0] = 10 you work with (float) SPL[0] = 10.0 ) Aug 5, 2020 at 15:29

I don't see why you can't simply put the two recordings in a DAW (e.g. Audacity) and export a downmix (taking care to gain down each track to achieve a non-clipping output as necessary). All the factors you mention are real, but are just as real in the case of two animals in the same waters as for two recordings being played back together.

If you do run into any issue of authenticity of the sound, I would think it would be caused by

1. differences in the acoustics of the recordings (try to record using the same equipment as much as possible)
2. noise in the recording cutting in and out making one aware of each recording cutting in and out (record an ambient noise track for each recording and crossfade from and to that instead of cutting in and out of silence)
3. Mention to us any other issue you have detected with your own ears instead of theorizing from a MATLAB forum etc. I don't think they are relevant, sorry.