Commit 398ada13 authored by Michael Kohnen's avatar Michael Kohnen

Merge branch 'ita_3da_dev'

new functions for 3d audio including ctc generation and channel separation
parents f84d8b75 9677b867
......@@ -23,6 +23,8 @@ function result = filterCTC(binauralInput,CTCfilter,domain)
verboseMode = ita_preferences('verboseMode'); %#ok<NASGU>
thisFuncStr = [upper(mfilename) ':']; %#ok<NASGU>
warning('This function will move to ita_ctc_loudspeaker_signals in future releases.'); %MKO
%% Initialization
if nargin < 2
error('CTC:InputArguments','This function requires two input arguments.')
......
......@@ -8,6 +8,7 @@ function lspSignals = filterCTC_LS234(binauralInput, ctcFilter, crossoverFreq)
% Authors: Florian Pausch, Lukas Aspck -- Email: {fpa, las}@akustik.rwth-aachen.de
% 2014
warning('this function is obsolete and will vanish in future realeases. Use ita_ctc_loudspeaker_signals.'); %MKO
ctcFilter.samplingRate = binauralInput.ch(1).samplingRate;
ctcDelay=ctcFilter(1,1).nSamples/2;
......
......@@ -10,6 +10,7 @@ function lspSignals = filterCTC_LS2or4(binauralInput, ctcFilter, crossoverFreq)
% Authors: Florian Pausch, Lukas Aspck -- Email: {fpa, las}@akustik.rwth-aachen.de
% 2014
warning('this function is obsolete and will vanish in future realeases. Use ita_ctc_loudspeaker_signals.'); %MKO
ctcDelay=ctcFilter(1,1).nSamples/2;
......
......@@ -35,7 +35,7 @@ function [CTC,Horig] = ita_CTC_filter(varargin)
% </ITA-Toolbox>
%% Initialization
warning('No longer supported version that is reported to be bugged, consider using ita_ctc_filter_regularized.')
if nargin < 2
error('CTC:InputArguments','Man! We need at least two loudspeakers for CTC! The input variable must be itaAudio objects.');
end
......
function [ CS_L CS_R ] = ita_ctc_channelSeparation(HRTF_real, CTCFilter, varargin)
%ITA_CTC_CHANNELSEPARATION Returns and plots channelseparation for ctc
%systems
% HRTF_real represent the real HRTFs that will occure in the CTC system,
% either as multi-instance itaAudio or coded in channels
% HRTF.ch(1) = HRTF_LS1_Left;
% HRTF.ch(2) = HRTF_LS1_Right;
% HRTF.ch(3) = HRTF_LS2_Left;
% HRTF.ch(4) = HRTF_LS2_Right;
% HRTF.ch(5) = HRTF_LS3_Left;
%
% CTC has to be multi-instance itaAudio:
% [LS1_left_CTCFilter LS1_right_CTCFilter]
% [LS2_left_CTCFilter LS2_right_CTCFilter]
% [LS3_left_CTCFilter LS3_right_CTCFilter]
% ...
%
opts.naturalCS = true;
opts.doubleSpectrum = true;
opts.singleSpectrum = true;
opts.plot = true;
opts=ita_parse_arguments(opts, varargin);
hrtf=ita_merge(HRTF_real(:));
L=itaAudio;
helper=ita_convolve(hrtf.ch(1),CTCFilter(1));
numSamples=helper.nSamples;
%% Left channel input
L.time=zeros(numSamples,hrtf.nChannels/2);
R=L;
for k=1:size(CTCFilter,1)
L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,1));
R=R+ita_convolve(hrtf.ch(2*k),CTCFilter(k,1));
end
CS_L = ita_merge(L,R);
%% Right channel input
L.time=zeros(numSamples,hrtf.nChannels/2);
R=L;
for k=1:size(CTCFilter,1)
L=L+ita_convolve(hrtf.ch(2*k-1),CTCFilter(k,2));
R=R+ita_convolve(hrtf.ch(2*k),CTCFilter(k,2));
end
CS_R = ita_merge(L,R);
%% Bruno Diss p 83 (5-11)
CS_L_singleSpectrum = ita_divide_spk(CS_L.ch(1),CS_L.ch(2));
CS_R_singleSpectrum = ita_divide_spk(CS_R.ch(2),CS_R.ch(1));
CS_L_value
%% Natural channel separation
if opts.naturalCS
for k=1:2:hrtf.nChannels
if hrtf.ch(k).rms>hrtf.ch(k+1).rms
naturalCS(ceil(k/2))=ita_divide_spk(hrtf.ch(k),hrtf.ch(k+1));
else
naturalCS(ceil(k/2))=ita_divide_spk(hrtf.ch(k+1),hrtf.ch(k));
end
end
end
%% Plot
if opts.plot
if opts.singleSpectrum
CS_L.pf; CS_R.pf;
end
if opts.doubleSpectrum
CS_L_singleSpectrum.pf;
CS_R_singleSpectrum.pf;
end
end
\ No newline at end of file
......@@ -24,7 +24,7 @@ function [ CTC ] = ita_3da_ctcFilter_regularized( varargin )
opts.beta = 0.001; % regularization parameter
opts.thresholdStartIR = -1; % threshold for ita_start_IR() to cut out the start delay, -1 will disable the feature
opts.filterLength = -1; % resulting filter lengt if set to -1: maximum of 4096 and nSamples*2
opts.winLim = [.7 85]; % limits for windowing (suppress artifacts at the end of HRIR caused by time shifting)
opts.winLim = [.7 85]; % limits for windowing (suppress artifacts at the end of HRIR caused by time shifting), needed for ita_start_ir
opts.postProcessing = true; % Indicates if a time shift and windowing operation is performed on the calculated filter. WARNING: May lead to non-causal filters (echo effect)
%% Init
......
function LSSignals = ita_ctc_loudspeaker_signals(CTCFilter, binauralInput)
%ITA_CTC_LOUDSPEAKER_SIGNALS Combines binaural input and ctc filter to
%calculate the loudspeaker signals
%
% CTCFilter a multi-instance of itaAudio [ CTC-1L CTC-1R; CTC-2L CTC-2R; ...]
% binauralInput has to be itaAudio with 2 channels
%
%
% Example: loudspeakerSignals=ita_ctc_loudspeaker_signals(CTCFilters_Calculated, BinauralSignalInput)
%% Initialization
if nargin < 2
error('CTC:InputArguments','This function requires two input arguments.')
end
binauralInput=ita_merge(binauralInput(:));
if ~isa(binauralInput,'itaAudio') || ~isa(CTCFilter,'itaAudio')
error('CTC:InputArguments','The input variable must be itaAudio objects.')
end
% Frequency vectors for the binaural input
if binauralInput.nChannels ~= 2
error('CTC:InputArguments','The binaural signal must contain two channels.')
else
inL = binauralInput.ch(1);
inR = binauralInput.ch(2);
end
% Frequency vectors for the CTC filters.
% e.g.: CTC_LR -> transfer function for the filter from the left signal to
% the right loudspeaker.
if size(CTCFilter,2) ~= 2
error('CTC:InputArguments','The CTC filter must contain two rows.')
end
%% CTC filtering
LSSignals=itaAudio(size(CTCFilter,1),1);
for k=1:size(CTCFilter,1)
LSSignals(k)=ita_convolve(inL,CTCFilter(k,1))+ita_convolve(inR,CTCFilter(k,2));
end
%% Return in time domain as multichannel audio
LSSignals=ita_merge(LSSignals(:))';
end
function [outputArg1,outputArg2] = ita_3da_ctc_smoothHRTF(hrtrf, smoothingType)
%ITA_3DA_CTC_SMOOTHHRTF Smoothes HRTF for
% Detailed explanation goes here
outputArg1 = inputArg1;
outputArg2 = inputArg2;
end
function [ OutputSignals ] = ita_decodeAmbisonics( Bformat, LoudspeakerPos, varargin )
function [ OutputSignals ] = ita_3da_decodeAmbisonics( Bformat, LoudspeakerPos, varargin )
%ITA_DECODEAMBISONICS Summary of this function goes here
% Detailed explanation goes here
......
function [ audioOut ] = ita_encodeAmbisonics( audioIn, order, sourcePos )
function [ audioOut ] = ita_3da_encodeAmbisonics( audioIn, order, sourcePos )
%ITA_ENCODEAMBISONICS Encodes a itaAudio with channel coordinates or a
% itaCoordinate with source positions into ambisonics channels
%
......
function pos = VR_loudspeaker_position(varargin)
function pos = ita_3da_LSSetup_VRLab(varargin)
% Give back the position, in meters, of the 8 loudspeakers in the VR lab.
% See options for more details
......
function weights = panVBAP(pos_LS,pos_VS)
function weights = ita_3da_panVBAP(pos_LS,pos_VS)
%panVBAP - Calculate weights for VBAP
%
% This function receives the position of the loudspeakers and the position
......
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