CICM / HoaLibrary-Light

:globe_with_meridians: High Order Ambisonics library
http://hoalibrary.mshparisnord.fr/en
GNU General Public License v3.0
100 stars 10 forks source link

Changing Hrtf filters #1

Closed Toby990 closed 8 years ago

Toby990 commented 9 years ago

Hi, I know where hrtf impulses are stored and that there are in harmonics domain. I'd like to try this measurments https://dev.qu.tu-berlin.de/projects/measurements/repository/show/2010-11-kemar-anechoic, but don't know if they are in the same domain and if not how to convert them.

I need some pointers, articles which describe hrtf impulses, so I could understand it. The way hoa-library use these impulses is some kind of standard?

I hope you could help me.

pierreguillot commented 9 years ago

Hi, The way we use the hrtfs is not a standard. We convert the impulses into 1 big matrix in the harmonics domain, here a pseudo code :

harmos[0] = 1.f; for(i = 0; i < number of harmonics; i++) { if(i != 0) { harmos[i-1] = 0.f; harmos[i] = 1.f; } decoder.process(harmos, channels); for(j = 0; j < number of samples by impulse; j++) { left = 0.; right = 0.; for(k = 0; k < number of channels; k++) { right += channels[k] * impulse_r[k][j]; // << inpulse right [channels, sample index] left += channels[k] * impulse_l[k][j]; // << inpulse left [channels, sample index] } matrix[j * number of harmonics + i] = value_left; matrix[(j + number of samples by impulse) * number of harmonics + i] = value_right; } }

If you want to change the HTRF you'll have to change the matrix in the hrtf.hpp file and the macro in the decoder.hpp file if the impulse size or the order are different. for 2D :

define HOA_NBIN_I 512 (the size of the impulses)

define HOA_NBIN_H 11 (the number of harmonics for order 5)

for 3D :

define HOA_NBIN_I 512 (the size of the impulses)

define HOA_NBIN_H 16 (the number of harmonics for order 3)

Toby990 commented 9 years ago

Ok, but I don't understand use of impulses. How the HRIR for particular azimuth angle is considered?

pierreguillot commented 9 years ago

Each impulse matches with a "virtual" loudspeaker (or output channel). You have to configure the decoder with the angles of the impulses. If you just want to try several hrtfs, you can create a PD or Max patch and use the c.convolve~ external to apply the filters : For example : capture d ecran 2015-04-13 a 20 05 47

pierreguillot commented 9 years ago

"I have found a thesis (www.ambisonia.com/Members/DrWig/bwphdthesis.pdf) where (chapter 4, page 104) is an equation 4.2. Are these operations exactly the same to what you wrote in pseudo code?"

Hi, Yes, this seems to be the same thing. We compute the harmonic coefficients of each set of samples (I mean that all the first samples of the impulse responses give a first set of coefficients, and all the second samples give a second set, etc.) for the two ears and we fill a matrix with the results (cf speudo code) . Then, the only complex thing that we do is in the "perform" method where we take advantage of the matrix optimizations of the blas library to perform the convolutions.

pierreguillot commented 9 years ago

Hi if you have Xcode, you can have a look at https://github.com/CICM/HoaLibrary-Tools. The subject class generates the HRIRs. Cheers