Commit f4ee8472 authored by Saskia Wepner's avatar Saskia Wepner

Merge branch 'master' of git.rwth-aachen.de:ita/toolbox

parents d8a5e39b 344e8168
......@@ -50,7 +50,8 @@ function cThis = interp(this,varargin)
sArgs = struct('order',50,'eps',1e-5,'shiftToEar',false,'shiftAxis','y','shiftOffset',[-0.0725 0.0725]);
sArgs = ita_parse_arguments(sArgs,varargin,2);
if ~isa(varargin{1},'itaCoordinates'),error('itaHRTF:interp', ' An itaCoordinate object is needed!')
if isempty(varargin) || ~isa(varargin{1},'itaCoordinates')
error('itaHRTF:interp', ' An itaCoordinate object is needed!')
end
field_in = varargin{1};
......
......@@ -117,6 +117,7 @@ classdef itaHRTF < itaAudio
methods % Special functions that implement operations that are usually performed only on instances of the class
%% Input
function this = itaHRTF(varargin)
iniAudio = [];
% initialize itaHRTF with itaAudio properties (only for nargin == 1)
if nargin > 1 || (nargin == 1 && (ischar(varargin{1}) || isa(varargin{1},'itaAudio')))
iniAudio = [];
......@@ -1017,7 +1018,7 @@ classdef itaHRTF < itaAudio
end
end
% function this = interp(varargin)
this = interp(varargin);
%
% Function to calculate HRTFs for arbitrary field points using a N-th order
% spherical harmonics (SH) interpolation / range extrapolation, as described in [1],
......@@ -1055,7 +1056,8 @@ classdef itaHRTF < itaAudio
% Version: 2016-02-05
this = reduce_spatial(this,coords,varargin);
% Function to spatially reduce the HRTF.
function this = smooth_linphase(this,varargin)
% function this = smooth_linphase(varargin)
......
function [ cThis ] = reduce_spatial( this, newCoordinates, varargin )
%
% This function is used to reduce the spatial sampling from the current
% directions. This is done with a findnearest search. For a reduction to
% interpolated values use interp
%
% INPUT:
%
%
% OUTPUT:
%
%
%
% Author: Jan-Gerrit Richter <jri@akustik.rwth-aachen.de>
% Version: 2017-11-23
oldCoords = this.getEar('L').channelCoordinates;
% if the desired sampling has more points, its probably unfeasable with
% findnearest search. Abort
if oldCoords.nPoints < newCoordinates.nPoints
error('There are more points in the wanted sampling than are available. You probably want the interp function');
end
% the new coords should have the same radius as the old ones to reduce
% errors
newCoordinates.r = mean(oldCoords.r);
oldCoords = oldCoords.build_search_database;
newIndex = oldCoords.findnearest(newCoordinates);
% calculate all distances from the wanted points to the found points
pointDistances = getVectorLength(newCoordinates,oldCoords.n(newIndex));
% calculate the distance between two neighboring points of the new sampling
newSamplingDistance = getVectorLength(newCoordinates.n(1),newCoordinates.n(2));
% the maximum of the found points should always be smaller
if max(pointDistances) > newSamplingDistance
error('The found points are further apart than the sampling allows. Something is wrong')
end
cThis = this.direction(newIndex);
end
function length = getVectorLength(pointsA, pointsB)
pointsA.r = pointsB.r;
vector = pointsA - pointsB;
length = sqrt(vector.x.^2 + vector.y.^2 + vector.z.^2);
end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment