jaakkopasanen / Impulcifer

Measurement and processing of binaural impulse responses for personalized surround virtualization on headphones.
MIT License
213 stars 14 forks source link

Processing Fails. #68

Closed JustCauseWhyNot closed 1 year ago

JustCauseWhyNot commented 1 year ago

I'm running into an issue. I've had quite a few issues getting to this point, but I've resolved them until now. I don't know how to fix this issue.

```py ❯ python recorder.py --play="data/sweep-seg-FL,FR-stereo-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" --record="data/my_hrir/headphones.wav" Traceback (most recent call last): File "/home/justcausewhynot/.local/bin/Impulcifer/recorder.py", line 260, in play_and_record(**create_cli()) File "/home/justcausewhynot/.local/bin/Impulcifer/recorder.py", line 202, in play_and_record input_device, output_device = get_devices( ^^^^^^^^^^^^ File "/home/justcausewhynot/.local/bin/Impulcifer/recorder.py", line 141, in get_devices input_device = get_device(input_device, 'input', host_api=host_api) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/justcausewhynot/.local/bin/Impulcifer/recorder.py", line 116, in get_device raise DeviceNotFoundError('Could not find any device which satisfies minimum channel count.') DeviceNotFoundError: Could not find any device which satisfies minimum channel count. ```
```py ❯ python -m sounddevice 0 HDA NVidia: S2719DGF (hw:0,3), ALSA (0 in, 2 out) 1 HDA NVidia: HDMI 1 (hw:0,7), ALSA (0 in, 8 out) 2 HDA NVidia: HDMI 2 (hw:0,8), ALSA (0 in, 8 out) 3 HDA NVidia: HDMI 3 (hw:0,9), ALSA (0 in, 8 out) 4 HD-Audio Generic: ALC892 Analog (hw:1,0), ALSA (2 in, 2 out) 5 HD-Audio Generic: ALC892 Alt Analog (hw:1,2), ALSA (2 in, 0 out) 6 sysdefault, ALSA (128 in, 128 out) 7 front, ALSA (0 in, 2 out) 8 surround40, ALSA (0 in, 2 out) 9 surround51, ALSA (0 in, 2 out) 10 surround71, ALSA (0 in, 2 out) 11 pipewire, ALSA (64 in, 64 out) 12 dmix, ALSA (0 in, 2 out) * 13 default, ALSA (64 in, 64 out) ```
jaakkopasanen commented 1 year ago

Which audio interface are you using?

JustCauseWhyNot commented 1 year ago

I am using a motu m2

jaakkopasanen commented 1 year ago

Something about sounddevice not recognizing the M2. You are able to use it to record in other applications, right? I see ALSA devices, you're on Linux, right?

JustCauseWhyNot commented 1 year ago

Yes for all.

JustCauseWhyNot commented 1 year ago

I've changed my default alsa card in /etc/asound.conf to the correct index for the motu m2. Unfortunately that didn't seem to cause any difference in terms of fixing the problem. I'm really confused as to why this problem is occurring.

JustCauseWhyNot commented 1 year ago

I'm trying to rebuild impulcifer, and making sure I follow instructions thoroughly. But when I try and run pip install -U -r requirments.txt it fails every time with, and here is a link to full output

      Failed to build numpy
      ERROR: Could not build wheels for numpy, which is required to install pyproject.toml-based projects

I've made sure to install python3.8, because I'm using gentoo it installs python for portage. But the python versions included have moved on past 3.8, and if I understand correctly the minimum python version supported by portage is python3_10.

JustCauseWhyNot commented 1 year ago

Ok I was able to fix that issue, but the original issue still exists.

JustCauseWhyNot commented 1 year ago

I've gotten past that hurdle now by running

command ```py python3.8 recorder.py --play="data/sweep-seg-FL,FR-stereo-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" --record="data/my_hrir/headphones.wav" --host_api=alsa --output_device=pipewire --input_device=pipewire ```

At this point though I'm having yet another problem. When I try, and run

command ```py python3.8 recorder.py --play="data/sweep-seg-FL,FC,FR,SR,BR,BL,SL-7.1-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" --record="data/my_hrir/FL,FC,FR,SR,BR,BL,SL.wav" --host_api=alsa --output_device=pipewire --input_device=pipewire ```

I get output of

output ``` Traceback (most recent call last): File "recorder.py", line 260, in play_and_record(**create_cli()) File "recorder.py", line 198, in play_and_record fs, data = read_wav(play) File "/home/justcausewhynot/.local/bin/Impulcifer/utils.py", line 23, in read_wav raise FileNotFoundError(f'File in path "{os.path.abspath(file_path)}" does not exist.') FileNotFoundError: File in path "/home/justcausewhynot/.local/bin/Impulcifer/data/sweep-seg-FL,FC,FR,SR,BR,BL,SL-7.1-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav" does not exist. ```

Maybe related to the output above but when run python impulcifer.py --test_signal="data/sweep-6.15s-48000Hz-32bit-2.93Hz-24000Hz.pkl" --dir_path="data/my_hrir" --plot The output I get is

output ```Creating impulse response estimator... Running room correction... Running headphone compensation... Creating headphone equalization... Creating frequency response target... Opening binaural measurements... /home/justcausewhynot/.local/bin/Impulcifer/venv/lib/python3.8/site-packages/scipy/stats/_stats_mstats_common.py:130: RuntimeWarning: invalid value encountered in double_scalars slope = r_num / ssxm /home/justcausewhynot/.local/bin/Impulcifer/venv/lib/python3.8/site-packages/scipy/stats/_stats_mstats_common.py:140: RuntimeWarning: invalid value encountered in sqrt t = r * np.sqrt(df / ((1.0 - r + TINY)*(1.0 + r + TINY))) /home/justcausewhynot/.local/bin/Impulcifer/venv/lib/python3.8/site-packages/scipy/stats/_stats_mstats_common.py:142: RuntimeWarning: invalid value encountered in double_scalars sterrest = np.sqrt((1 - r**2) * ssym / ssxm / df) Traceback (most recent call last): File "impulcifer.py", line 556, in main(**create_cli()) File "impulcifer.py", line 84, in main write_readme(os.path.join(dir_path, 'README.md'), hrir, fs) File "impulcifer.py", line 417, in write_readme peak_ind, knee_point_ind, noise_floor, window_size = ir.decay_params() File "/home/justcausewhynot/.local/bin/Impulcifer/impulse_response.py", line 120, in decay_params n = int(len(squared) / self.fs / wd) # Number of time windows ValueError: cannot convert float NaN to integer ```
JustCauseWhyNot commented 1 year ago

I'd just like to clarify is that I'm trying to create a 7.1 surround sound personalized wav file for that if I understand correctly will also include autoeq in the file itself.

JustCauseWhyNot commented 1 year ago

I'm doing all that I know to try and get this to work. I'm really doing what I can to make sure I don't have to create an issue, but no matter what I seemingly do the project hits a road bump. At this moment I've completely reinstalled impulcifer along with all it's dependencies. I'm making sure to use venv not virutalenv, I'm using python3.18. When I run python recorder.py --play=data/sweep-seg-FL,FR-stereo-6.15s-48000Hz-32bit-2.93Hz-24000Hz.wav --record=data/my_hrir/headphones.wav --host_api=alsa it does seem to record correctly, but maybe there's an underlying problem I can't detect. The command also doesn't work if I run it without --host_api=alsa All that said I believe I've "solved" the recording issue, but also it could be the reason I'm having issues in the above post about failing with math.

It seems as though I may have regressed in my progress towards getting this script to run though. Because now when I run ❯ python impulcifer.py --test_signal=data/sweep-6.15s-48000Hz-32bit-2.93Hz-24000Hz.pkl --dir_path=/home/justcausewhynot/.local/bin/Impulcifer/data/my_hrir --plot I get an error with a earlier line of code.

error ``` Opening binaural measurements... Traceback (most recent call last): File "impulcifer.py", line 556, in main(**create_cli()) File "impulcifer.py", line 81, in main hrir = open_binaural_measurements(estimator, dir_path) File "impulcifer.py", line 388, in open_binaural_measurements raise ValueError('No HRIR recordings found in the directory.') ValueError: No HRIR recordings found in the directory. ```

Please offer any help you can give. I'm really trying to solve this on my own, but I just haven't.

JustCauseWhyNot commented 1 year ago

Do I need speakers in order to use impulcifer? I thought I just needed headphones, and binaural microphones. I now think it does in fact require a pair of speakers. If that's so I'm a dunce, and apologize for this issue.

JustCauseWhyNot commented 1 year ago

I'll just close this issue for now. Let me know if I'm wrong about needing speakers in order to use impulcifer.

jaakkopasanen commented 1 year ago

You indeed need speakers. The whole purpose of Impulcifer is to measure the transfer function from speakers to ears to replicate that with headphones.

JustCauseWhyNot commented 1 year ago

Appreciate the answer, and apologies for the unnecessary issue. I will get speakers eventually then.