We study the model high-temperature superconductor HgBa2CuO 4+δ with electronic Raman scattering and optical ellipsometry over a wide doping range. The resonant Raman condition which enhances the scattering cross section of "two-magnon" excitations is found to change strongly with doping, and it corresponds to a rearrangement of inter-band optical transitions in the 1-3 eV range seen by ellipsometry. This unexpected change of the resonance condition allows us to reconcile the apparent discrepancy between Raman and x-ray detection of magnetic fluctuations in superconducting cuprates. Intriguingly, the strongest variation occurs across the doping level where the antinodal superconducting gap reaches its maximum.PACS numbers: 74.25.nd, 74.72.Gh, 74.72.Kf Magnetic fluctuations might play an essential role in the mechanism of high-temperature superconductivity in the cuprates [1]. Upon doping the insulating parent compounds, the fluctuations evolve from antiferromagnetic (AF) magnon excitations up to a few hundred meV. As this energy is in principle sufficient to support superconductivity at very high temperatures, the observation of similar "paramagnon" excitations by resonant inelastic x-ray scattering (RIXS) in superconducting cuprates [2] is a revealing result. Recent electronic Raman scattering (ERS) measurements further suggest that the high-energy magnetic fluctuations exhibit a pronounced change concurrent with the formation of Cooper pairs [3], corroborating a close connection between them.Here we address a major puzzle that has arisen from the comparison of the doping dependent RIXS and ERS cross sections. Both techniques use inelastic photon scattering to probe fundamental excitations in solids, but with very different incident photon energies in the xray and visible-light range, and they can detect magnetic fluctuations in the cuprates via the creation of single- [4] and two-magnon [5] excitations, respectively. In the undoped AF insulating compounds, the superexchange energies J determined by RIXS and ERS agree reasonably well [4,5] and are furthermore consistent with inelastic neutron scattering (INS) measurements [6]. A comparison between these measurements at finite doping, however, reveals an important discrepancy: while the energy and spectral weight of the (para)magnon excitations observed by RIXS exhibit little change [2,7], both of these quantities decrease substantially in ERS data [8][9][10][11]. The latter observation has created the impression that the AF spin fluctuations become overdamped near and above optimal doping [9]. This, in turn, has served as a major argument against magnetically driven Cooper pairing in the overdoped regime [12,13]. Together with the decrease of well-defined high-energy magnetic signal with doping in INS measurements [14], this has cast doubt on the interpretation of the RIXS results [15].The RIXS cross section in the cuprates is known to exhibit a non-trivial photon energy dependence [16,17], and the detection of magnetic excitations is greatly enhanced by a r...