Commit 9e4cb72b authored by Lukas Aspöck's avatar Lukas Aspöck
Browse files

- revised method to create binaural simulation sphere (experimental, please...

- revised method to create binaural simulation sphere (experimental, please test and use with caution)
- added method to create raven loudspeaker ini file (to be revised)
parent cd20e06d
function [ data, samplerate, metadata ] = dfRavenBinauralVA( alpha, beta, rpf )
view = itaCoordinates( 1 );
view.phi = alpha;
view.theta_deg = 180 - beta;
view.r = 1.0;
up = view;
up.theta = view.theta - pi/2;
rpf.setReceiverViewVectors( ita_matlab2openGL( view.cart ) );
rpf.setReceiverUpVectors( ita_matlab2openGL( up.cart ) );
viewVec = itaCoordinates( 1 );
viewVec.cart = [ sind(beta)*cosd(alpha) sind(beta)*sind(alpha) (-1)*cosd(beta)];
upVec = viewVec;
upVec.elevation= 90-viewVec.elevation;
upVec.azimuth = 180+viewVec.azimuth;
ravenRecViewVector = viewVec.cart([1 3 2]).*[1 1 -1];
ravenRecUpVector = upVec.cart([1 3 2]).*[1 1 -1];
rpf.setReceiverViewVectors(ravenRecViewVector);
rpf.setReceiverUpVectors(ravenRecUpVector);
% disp([ 'Alpha: ' sprintf('%0.2f ',alpha) ' | Beta: ' sprintf('%0.2f ',beta) ' | View: ' sprintf('%0.2f ',ravenRecViewVector) ' | Up: ' sprintf('%0.2f ',ravenRecUpVector) ])
% data = zeros(2,256);
% samplerate = 44100;
% metadata = [];
rpf.run();
brir = rpf.getBinauralImpulseResponseImageSourcesItaAudio; % only early reflections are requested, use rpf.getBinauralImpulseResponseItaAudio if you want to get the full impulse response (and adjust the filter length in your rpf accordingly)
n_residual = mod( brir.nSamples, 4 );
data = [ brir.timeData', zeros( brir.nChannels, n_residual ) ];
samplerate = brir.samplingRate;
metadata = [];
end
function ita_raven_createLoudspeakerSetupFile(coordinates, center)
% Function to write source positions of the reproduction room into
% Speaker.ini for VBAP reproduction
%
% ! This version does not support lsp-directivities, as they are
% not supported by the current VBAP version (07-Jan-2014)!
% Input is in Raven Coordinates
% Output is a Speaker.ini
%
% Authors: Sönke Pelzer, Jonas Sautter, Michael Kohnen
% Email: mko@akustik.rwth-aachen.de
%
% date: 2014/06/17
%
% <ITA-Toolbox>
% This file is part of the application Raven for the ITA-Toolbox. All rights reserved.
% You can find the license for this m-file in the application folder.
% </ITA-Toolbox>
MATRIX_MATLAB2RAVEN = [0 0 -1; -1 0 0; 0 1 0]; % = MATRIX_MATLAB2SPAX
radiusSpeakers=1; %Scaling factor(!) for the distance
%of the loudspeakers to the center point
coordinates_mat=coordinates;
% Convert coordinates from Raven to Matlab in two steps:
% 1. Convert from Raven2Matlab
%coordinates.cart = RavenProject.pSU2RVN(coordinates.cart);
% 2. Convert from Matlab2Spax
coordinates.cart = coordinates.cart * MATRIX_MATLAB2RAVEN;
% set center position
if nargin<2
center=[0 0 0];
end
% open file, empty it and write
%fid = fopen('../RavenInput/Speakers.ini', 'w');
fid = fopen('Speakers.ini', 'w');
% write general settings
fprintf(fid, '\n[General]\nCenter = %d,%d,%d', center);
fprintf(fid, '\nRadiusSpeakers = %d', radiusSpeakers);
fprintf(fid, '\nMode = SIRERA');
% write lsp set-up
fprintf(fid, '\n[SIRERA]\nNumberSpeakers = ');
array = coordinates.cart;
fprintf(fid, '%i\nRouting = 0\nSpeakers = ', coordinates.nPoints);
fprintf(fid, '%f , %f , %f, ', transp(array));
tri = DelaunayTri(coordinates_mat.cart); % Calculation of the triangluar sections for VBAP
tri = tri.convexHull();
fprintf(fid, '\nNumberSections = %i\nSections = ', length(tri));
fprintf(fid, '%i , %i , %i, ', transp(tri));
%close file
fclose(fid);
end
Supports Markdown
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