# Clip wav by PSD

I have the following two things.

sequence_1: Sound file in the wave format.

PSD_1: Some PSD (Power Spectral Density).

I want that the PSD(sequence_1) < PSD_1 for all indices.

Does anyone have an idea how to achieve this? I try to do this with tensorflow in python. But the answer can also be more general. I think I need something like an equalizer over time but I don't know how to do that.

edit2: Motivation: PSD_1 is a hearing threshold of the original signal. I want to do some stuff with the signal but don't want it to be audiable (so PSD of the signal needs to be less than the PSD of the hearing threshold) But the hearing threshold is computed in the time frequency domain.

clarification: I can not just invert the PSD. Because PSD is not an invertible function.

edit: I formalize it more here.

• PSD(sequence_1) gives a strength for a specific window of time and frequency.
• The PSD_1 has the same dimensions.
• Now for a given time t and a given frequency f, I want that PSD(sequence_1)[t][f] < PSD_1[t][f].
• Say without loss of generality the PSD(sequence_1)[t][f] > PSD_1[t][f].
• Now I want to change sequence_1 such that PSD(fun(sequence_1))[t][f] < PSD_1[t][f] holds.
• Therefore I need to change sequence_1 more or less at time t.
• What function [fun(sequence_1)] achieves this? I thought about an equalizer as this can lower certain frequencies. But I'm not an audio expert. I need to implement it. So a library or a formula telling me how to do it would be great.
• Additionally I only want to lower the frequency in a minimal manner. So the optimal outcome would be: PSD(fun(sequence_1))[t][f] == PSD_1[t][f]
• It's not really clear what you're describing here. Could you elaborate on the mathematical operation you want? Maybe describing the purpose of all this would help, too. You can't "clip" a time-domain sequence by a PSD. That operation is not defined. – Marcus Müller Aug 28 '19 at 15:01
• your edit helps, but it's really still not clear what the boundary conditions for all these are: What's the purpose of all this? For example, you could do the DFT of your signals, scale the overshooting elements of the DFT and IDFT back to time domain, and then move on to the next part of signal, and that would fix your specifiec short-time PSD estimate. However, this is highly undesirable as it leads to nondiscontinuities. So, without knowing why you do this, it's hard to advise. – Marcus Müller Aug 28 '19 at 16:36
• Can you invert PSD? I know I can invert DFT but PSD?. PSD(x) takes abs(dft(x)) and does some stuff with it. This tf.abs(dft) can not be inverted in my opinion. – Reto Weber Aug 28 '19 at 16:40
• And the use case: The PSD_1 is a hearing threshold of the original signal. And I do some stuff with the signal but don't want it to be audiable. So I try to keep the signal below the hearing threshold. But the hearing threshold is computed in the time frequency domain. – Reto Weber Aug 28 '19 at 16:44
• aaaaaaaah! That makes the world of a difference! Add that info to your question! – Marcus Müller Aug 28 '19 at 16:50