The time-dependent position of the center of mass x¯(t) of the swarm is calculated asx¯(t)=1N(t)j=1N(t)xj(t)where xj(t) is the 1D position (along the axis of oscillation of the marker) of midge j at time t and N(t) is the number of individuals in the swarm at time t. We calculated the phase-averaged position of the center of mass XS(t) by averaging x¯(t) over the period of oscillation of the marker T viaXS(t)=1Mi=0M1x¯(t+iT),(0<t<T)where M is the duration of the experiment in full periods T. When computing the phase-averaged position of the center of mass as a function of height XS(z,t), we binned individuals in 40-mm tall horizontal slabs, spaced 20 mm apart. We fit XS(t) and XS(z,t) using functions of the form AS sin (ωt − ϕ) to obtain AS and AS(z), the average and height-dependent amplitude of oscillation of the swarm, respectively, as well as ϕ and ϕ(z), the average and height-dependent phase of the swarm, respectively. Subsequently, we fit AS(z) and ϕ(z)/π with functions of the form S0ekiz and krz/π, respectively, to obtain values for kr and ki. The viscoelastic moduli G′ and G″ can be expressed in terms of kr and ki asG=ρω2kr2ki2(kr2+ki2)2andG=ρω22krki(kr2+ki2)2obtained by solving kriki=ρω2/(G+iG).

We approximate the average swarm mass density ρ for each measurement by calculating the average number density in a sphere of 100 mm radius centered at the instantaneous center of mass of the swarm (to avoid edge effects) and subsequently multiplying this average with the typical midge weight of 2.3 ± 0.2 mg. The swarm density varies by up to 30% between experiments, and while G' and G" are independent of ρ, the wave speed is not. The SD in G' and G" measured from different swarms is roughly 15%.