Skip to content

Commit 7bb6e8a

Browse files
committed
Adds comments explaining the mysterious p_hit normalization in room.cpp
1 parent 8234c7b commit 7bb6e8a

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pyroomacoustics/libroom_src/room.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -832,9 +832,10 @@ bool Room<D>::scat_ray(
832832
// of scat_per_slot
833833
if (travel_dist_at_mic < distance_thres && scat_trans.maxCoeff() > energy_thres)
834834
{
835-
836-
//output[k].push_back(Hit(travel_dist_at_mic, scat_trans));
837-
//microphones[k].log_histogram(output[k].back(), hit_point);
835+
// The (r_sq * p_hit) normalization factor is necessary to equalize the energy
836+
// of the IR computed with ray tracing to that of the image source method.
837+
// Ref: D. Schroeder, "Physically based real-time auralization of interactive virtual environments",
838+
// section 5.4, eq. 5.54.
838839
double r_sq = double(travel_dist_at_mic) * travel_dist_at_mic;
839840
auto p_hit = (1 - sqrt(1 - mic_radius_sq / std::max(mic_radius_sq, r_sq)));
840841
Eigen::ArrayXf energy = scat_trans / (r_sq * p_hit) ;
@@ -944,6 +945,10 @@ void Room<D>::simul_ray(
944945
// because the ray will continue its way
945946
float travel_dist_at_mic = travel_dist + distance;
946947

948+
// The (r_sq * p_hit) normalization factor is necessary to equalize the energy
949+
// of the IR computed with ray tracing to that of the image source method.
950+
// Ref: D. Schroeder, "Physically based real-time auralization of interactive virtual environments",
951+
// section 5.4, eq. 5.54.
947952
double r_sq = double(travel_dist_at_mic) * travel_dist_at_mic;
948953
auto p_hit = (1 - sqrt(1 - mic_radius_sq / std::max(mic_radius_sq, r_sq)));
949954
energy = transmitted / (r_sq * p_hit);

0 commit comments

Comments
 (0)