this is my code
i think it<s not that much good but if it can do it’s work is ok
<code>import wave
import numpy as np
def applyITDILD(sigMono, fs, ITD, ILD):
sigMono = mono file
fs=48000;
ITD = int(input("put the ITD="));
# sigMono: Mono signal
# fs: Sample rate
# ITD: ITD in micro second
# ILD: ILD in dB
numSampleITD = np.round(48000 * ITD * 1e-6)
if numSampleITD > 0:
sigStereo[:, 0] = sigMono.copy() # Left channel of stereo
sigStereo[:, 1] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Right channel of stereo
else:
sigStereo[:, 0] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Left channel of stereo
sigStereo[:, 1] = sigMono.copy() # Right channel of stereo
return sigStereo;
ILD=gainL;
ILD=gainR;
# Determine gainL and gainR based on ILD [dB]
gainL=int(input('gainL='));
gainR=int(input('gainR='));
sigStereo[:, 0] = sigStereo[:, 0] * gainL;
sigStereo[:, 1] = sigStereo[:, 1] * gainR;
return sigStereo:
with wave.open("ITDILD0.wavfile") as wav_file:
print(wav_file)
</code>
<code>import wave
import numpy as np
def applyITDILD(sigMono, fs, ITD, ILD):
sigMono = mono file
fs=48000;
ITD = int(input("put the ITD="));
# sigMono: Mono signal
# fs: Sample rate
# ITD: ITD in micro second
# ILD: ILD in dB
numSampleITD = np.round(48000 * ITD * 1e-6)
if numSampleITD > 0:
sigStereo[:, 0] = sigMono.copy() # Left channel of stereo
sigStereo[:, 1] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Right channel of stereo
else:
sigStereo[:, 0] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Left channel of stereo
sigStereo[:, 1] = sigMono.copy() # Right channel of stereo
return sigStereo;
ILD=gainL;
ILD=gainR;
# Determine gainL and gainR based on ILD [dB]
gainL=int(input('gainL='));
gainR=int(input('gainR='));
sigStereo[:, 0] = sigStereo[:, 0] * gainL;
sigStereo[:, 1] = sigStereo[:, 1] * gainR;
return sigStereo:
with wave.open("ITDILD0.wavfile") as wav_file:
print(wav_file)
</code>
import wave
import numpy as np
def applyITDILD(sigMono, fs, ITD, ILD):
sigMono = mono file
fs=48000;
ITD = int(input("put the ITD="));
# sigMono: Mono signal
# fs: Sample rate
# ITD: ITD in micro second
# ILD: ILD in dB
numSampleITD = np.round(48000 * ITD * 1e-6)
if numSampleITD > 0:
sigStereo[:, 0] = sigMono.copy() # Left channel of stereo
sigStereo[:, 1] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Right channel of stereo
else:
sigStereo[:, 0] = np.hstack((np.zeros(numSampleITD), sigMono.copy()[:-numSampleITD])) # Left channel of stereo
sigStereo[:, 1] = sigMono.copy() # Right channel of stereo
return sigStereo;
ILD=gainL;
ILD=gainR;
# Determine gainL and gainR based on ILD [dB]
gainL=int(input('gainL='));
gainR=int(input('gainR='));
sigStereo[:, 0] = sigStereo[:, 0] * gainL;
sigStereo[:, 1] = sigStereo[:, 1] * gainR;
return sigStereo:
with wave.open("ITDILD0.wavfile") as wav_file:
print(wav_file)
itd is delay time to get th stereo
ild is gain make up to localize the sound
i want it to run and output the sound result
when run it it has problem with sigStereo
New contributor
ST4rt is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.