File: prepare_hrirs_cipic.m

package info (click to toggle)
soundscaperenderer 0.6.0%2Bdfsg2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 17,148 kB
  • sloc: cpp: 36,430; sh: 4,522; makefile: 847; ansic: 762; javascript: 593; python: 57
file content (51 lines) | stat: -rw-r--r-- 1,747 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
% This script is part of the SoundScape Renderer (SSR). It exemplarily
% shows how to prepare a set of head-related impulse responses (HRIRs) in
% a format readable by the SSR.
%
% The HRIRs used here are obtained from The CIPIC HRTF Database
% (http://interface.cipic.ucdavis.edu/CIL_html/CIL_HRTF_database.htm)
% Note that the above mentioned material is Copyright (c) 2001 The
% Regents of the University of California. All Rights Reserved.
%
% Download the file
% http://interface.cipic.ucdavis.edu/data/special_kemar_hrir.tar and
% uncompress it in the folder where this Matlab script resides. Finally,
% run the script.
%
% Author of this script: Jens Ahrens, 21.01.2008
% This script is Copyright (c) 2008 Deutsche Telekom Laboratories

clear all;

% load data set from file 'large_pinna_final.mat'
load large_pinna_final.mat;

% this is necessary for interpolation
left  = [left,  left(:,end)];
right = [right, right(:,end)];

% time domain interpolation (note that time domain interpolation is not
% most favourable in this context!)
hrirs_left  = interp2([0:5:360], [1:size(left,1)]', left(:,:), ...
                      [0:1:359], [1:size(left,1)]','spline');

hrirs_right = interp2([0:5:360], [1:size(right,1)]', right(:,:), ...
                      [0:1:359], [1:size(right,1)]','spline');

% prepare data for storage
hrirs = zeros(size(hrirs_right,1), 720);

for n = 1:2:720
    % Something's wrong here. The distribution of left and right
    % channels should be the other way round!?!
    hrirs(:, n+1) = hrirs_left(:,(n+1)/2);
    hrirs(:, n)   = hrirs_right(:,(n+1)/2);
end

% normalize
hrirs = hrirs./max(abs(hrirs(:))) .* .99;

% write data to file
wavwrite(hrirs, 44100, 16, 'hrirs_cipic_large_pinna.wav');

disp('Done.');