diff --git a/applications/Binaural-HRTF/HRTF_class/@itaHRTF/writeDAFFFile.m b/applications/Binaural-HRTF/HRTF_class/@itaHRTF/writeDAFFFile.m index 53ae2e630e58b031a56772f8af79d6420cb8e02d..1f71b73febba30b5c6980911c8ea49ae85725d49 100644 --- a/applications/Binaural-HRTF/HRTF_class/@itaHRTF/writeDAFFFile.m +++ b/applications/Binaural-HRTF/HRTF_class/@itaHRTF/writeDAFFFile.m @@ -46,24 +46,31 @@ theta_start_deg = rad2deg( min( this.channelCoordinates.theta ) ); theta_end_deg = rad2deg( max( this.channelCoordinates.theta ) ); theta_num_elements = size( uniquetol( this.channelCoordinates.theta ), 1 ); -phi_start_deg = rad2deg( min( mod( this.channelCoordinates.phi, 2*pi ) ) ); -phi_end_deg = rad2deg( max( mod( this.channelCoordinates.phi, 2*pi ) ) ); +phi_start_deg = rad2deg( min( mod( this.channelCoordinates.phi, 2 * pi ) ) ); +phi_end_deg = rad2deg( max( mod( this.channelCoordinates.phi, 2 * pi ) ) ); phi_num_elements = size( uniquetol( this.channelCoordinates.phi ), 1 ); assert( phi_num_elements ~= 0 ); alphares = ( phi_end_deg - phi_start_deg ) / phi_num_elements; % phi end does not cover entire circle in this case alphares_full_circle = ( phi_end_deg - phi_start_deg ) / ( phi_num_elements - 1 ); % phi end does not cover entire circle in this case if phi_end_deg + alphares_full_circle >= 360.0 - alpharange = [ phi_start_deg ( phi_end_deg + alphares_full_circle ) ]; % Account for full circle + alpharange = [ phi_start_deg 360 ]; % Account for full circle and force end of range to 360 deg alphares = alphares_full_circle; else alpharange = [ phi_start_deg phi_end_deg ]; end +assert( alpharange( 1 ) >= 0.0 ) +assert( alpharange( 2 ) <= 360.0 ) + assert( theta_num_elements ~= 0 ); betares = ( theta_end_deg - theta_start_deg ) / ( theta_num_elements - 1 ); % phi end does not cover entire circle betarange = 180 - [ theta_start_deg theta_end_deg ]; % Flip poles (DAFF starts at south pole) +assert( betarange( 2 ) >= 0.0 ) +assert( betarange( 1 ) <= 180.0 ) + + %% Assemble metadata metadata = daffv17_add_metadata( metadata, 'Generation script', 'String', 'writeDAFFFile.m' );