Open yancaproni opened 2 months ago
Hey Yan, sorry for the late reply, I was caught up in other business earlier. Here are all the codes you need, and if you need anything else just let me know.
Thanks again for your interest in my work! I hope this helps with your projects.
With best regards, Yuxiang
Yan Caproni @.***> 于2024年9月20日周五 06:56写道:
Hello @YuriWayne42 https://github.com/YuriWayne42 ! My name is Yan, I study acoustic engineering and I am trying to run your code. I've read your paper and it is really good, I am just having some problems with two missing functions that are making it really hard to generate the onset SH coefficients and the SH coefficients for the mesh.
It would be great to have this two functions or understand where I can get them:
onset_detect(data, threshold);
and
coord_rotation_top(arg1,arg2,arg3);
I think that's what I need to get to the DNN in python, right?
Have a nice day!
Yan Caproni
— Reply to this email directly, view it on GitHub https://github.com/YuriWayne42/hrtf_personalization_fromMesh/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3CZFAI4ZPHQVDVBYBCRHDZXP5ONAVCNFSM6AAAAABORZFGPCVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZTQNJRGU3DQMQ . You are receiving this because you were mentioned.Message ID: @.***>
-- With Regards, Yuxiang Wang
% this function will detect onset in a given HRIR function onset = onset_detect(hin,onset_threshold_dB)
% upsample input hrir for better resolution in onset detection upratio = 128; h = resample(hin,upratio,1);
% calculate linear onset threshold from dB value onset_threshold =10^(onset_threshold_dB/20) ;
% find peaks and compute the sample position [pk_val,pk_idx] = findpeaks(h,'Npeaks',4,'SortStr','descend'); %
% search backwards idx = pk_idx(1); while idx >= upratio if (h(idx) < pk_val(1)*onset_threshold) onset = idx; % onset is index where value is below the th onset = floor(onset/upratio); break; end idx = idx-1; end if(idx==0) error('error finding onset ...\n'); onset = 1; end
% % search forward % idx = 1; % while idx <= max_index % if abs(h(idx)) >= abs(max_val*onset_threshold) % onset_fwd = idx; % onset is index where value is below the th % onset_fwd = floor(onset_fwd/upratio); % break; % end % idx = idx+1; % end % % % compare backwards and forward onset, they should not be very different % if(abs(onset_fwd-onset_back)>error_th) % keyboard; % end
% search for other peaks and identify if there is a peak before max-peak, which should be considered for onset calculation idx_toconsider = pk_idx(2:end); b4_maxpeak = find(idx_toconsider<pk_idx(1)); % index of all peaks before the max peak if(~isempty(b4_maxpeak)) idx_b4_maxpeak = idx_toconsider(b4_maxpeak); val_b4_maxpeak = h(idx_b4_maxpeak); % ab_halfmaxpeak = find(max(val_b4_maxpeak) > pk_val(1)0.15); % any peak which is more than half of maxpeak val and it located before the max peak ab_halfmaxpeak = find(val_b4_maxpeak > pk_val(1)0.15); % any peak which is more than half of maxpeak val and it located before the max peak
if(~isempty(ab_halfmaxpeak))
% in case there are multiple such peaks which are more than half of maxpeak and are located before the max peak
% use theone with the smallest index
idx_touse = min(idx_b4_maxpeak(ab_halfmaxpeak));
% search backwards from that index
idx = idx_touse;
while idx >= upratio
if (h(idx) < h(idx_touse)*onset_threshold)
onset = idx; % onset is index where value is below the th
onset = floor(onset/upratio);
break;
end
idx = idx-1;
end
if(idx==0)
error('error finding onset ...\n');
onset = 1;
end
end
end
% rotate the mesh or sph location to the north pole %
function rotated_cart = coord_rotation_top(original_cart, azi, elev) original_cart = [original_cart, ones(size(original_cart,1),1)]; rotated_cart = makehgtform('yrotate', -(90-elev)/180pi, 'zrotate', -azi/180pi ) original_cart'; %'yrotate', -(90-elev)/180pi
rotated_cart = rotated_cart';
rotated_cart(:, 4) = [];
% [rotated_sph(:,1), rotated_sph(:,2) ]= cart2sph(rotated_cart(:,1),rotated_cart(:,2),rotated_cart(:,3)); % rotated_sph = rotated_sph/pi*180; %
end
Hello Yuri, I really appreciate your response! This code looks really really nice.
Unfortunately I am stuck in another part and would appreciate your help again. Now for the Python code, I need the directory for this model ("model_dir" variable) and I don't know for sure how I get this data. It needs a result_0X.mat file inside the path and none of the matlab codes can generate that.
Another issue is that apparently the "HUTUBS_matrix_measured.mat" is either corrupted or I need to use another approach to open the file. Neither matlab nor python can open or read it.
I really hope that you can help me with this or even if you have time, quickly explain me how to use the chain by email (yan.pereira@eac.ufsm.br). It would be really nice to see the code running.
Best regards and thank you again.
Yan Caproni
Hello @YuriWayne42 ! My name is Yan, I study acoustic engineering and I am trying to run your code. I've read your paper and it is really good, I am just having some problems with two missing functions that are making it really hard to generate the onset SH coefficients and the SH coefficients for the mesh.
It would be great to have this two functions or understand where I can get them:
onset_detect(data, threshold);
and
coord_rotation_top(arg1,arg2,arg3);
I think that's what I need to get to the DNN in python, right?
Have a nice day!
Yan Caproni