sfstoolbox / sfs-matlab

SFS Toolbox for Matlab/Octave
https://sfs-matlab.readthedocs.io
MIT License
96 stars 39 forks source link

Implementation of Active Room Compensation methods, modelling reverberations using a simplified Image Source Metho #194

Open jmwilliams1 opened 5 years ago

jmwilliams1 commented 5 years ago

Hi all,

I was wondering if anyone had any guidance regarding how I would implement a control method (WDAF / MCWS / etc) to minimise the effects of unwanted room reverberations.

I have modelled the room reverberations using a simplified Image Source Method, as shown in my code. I believe that the basic approach of the control method should be to alter the driving signals to the array of loudspeakers, however as I am relatively new to this field I am struggling to make much progression in my thesis.

If anyone has also dealt with the implementation of WDAF/ MCWS in applications not involving SFS_toolbox I would also be very interested in hearing their approach.

Thanks for any help

Jack Williams

`%%%~~~~~~~~~~~~~~ %%% ISM CODE. %Room reverberations modelled as their own sources. Based off ISM. %Image positions are calculated, with a driving signal the same as its %respective secondary source. %Listening area is central ring of speakers

% In order to see effect of room absorption manually change value of 'w_abs' (before main loop) % Value of 1 all sound absorbed (anechoic). % Value of ~0.8: shows modest room reverberations, visually affecting % quality of of sound field in listening area.

%%% Jack Williams 2019 %%% SFS-Toolbox: H.Wierstorf et. al. %%% Notes: WORK IN PROGRESS - 'W_abs' is in no means an accurate representation of how walls reflect sound and is to be altered in the future

%%%~~~~~~~~~~~~~~~~

clear clc conf = SFS_config; %load default configuration settings from SFS_config.m file

%Simulation Resolution i.e. - 500 means 500 x 500 grid of pressure values

conf.resolution = 500;

% input parameters for: sound_field_mono_nfchoa(X,Y,Z,xs,src,f,conf)

%X, Y, Z, = axes INCLUDING image sources %xs = position of point source %src = source type- pw = plane wave, ps = point source %f = monochromatic frequency %R = room dimensions R = [3 , 4]; X = [0, R(1)]; Y = [0 ,R(2)]; Z = 0; xs = [1.5 ,4 , 0 ]; src ='ps'; f = 500;

%%% Calculating Positions of Primary Sources within unshifted listening %%% room

centreX = X(1,2) / 2; centreY = Y(1,2) / 2; conf.secondary_sources.number = 20; conf.secondary_sources.size = 2; conf.secondary_sources.center = [centreX , centreY , 0 ]; conf.secondary_sources.geometry = 'circle'; x_primary = secondary_source_positions(conf);

%%% driving signals calculated for initial speaker set up x0 = x_primary; D_primary = driving_function_mono_nfchoa(x0,xs,src,f,conf);

%%% listening position to consider reflections from = centre of speaker set up Xl = [centreX , centreY, 0 ];

%%% number of speakers to find images for inmax = conf.secondary_sources.number;

%%% creating matrix of ones for position and driving signals of images x_image = ones((inmax4),7); D_images = ones((inmax4 ), 1);

%%% Initialising ISM Loop %%% jn = image number, with 4 images modelled per secondary source jn = 0;

%%% Weight of image sources //// Not finalised/// wabs = 0.8 %~~~~~~~~~~~~~~ %%% jn = image source number %%% in = primary source number %%% >For each i primary, positions im(1,2,3,4)are calculated for their %%% corresponding image source. %%% >For each i primary source, driving signals D_images are set for their %%% corresponding image sources. %~~~~~~~~~~~~~~

for in = 1:inmax

 %%% columns 4-6 not considered yet, all directions are -1 
 %%% column 7 / weight needs to be considered through difference in pos
 %%% SEE IMAGE_SOURCE_LOCATIONS code for calculations 

im_1 = [(2 *R(1) -x_primary(in,1 )) , x_primary(in,2) , 0 ,-x_primary(in,4) , x_primary(in,5) , 0 ,(1 - w_abs)]; jn = jn+1; x_image(jn,:) = im_1; D_images(jn) = D_primary(in);

im_2 = [-x_primary(in,1) , x_primary(in,2) , 0, x_primary(in,4) , x_primary(in,5) , 0, (1 - w_abs)]; jn = jn + 1; x_image(jn,:) = im_2; D_images(jn) = D_primary(in);

im_3 = [x_primary(in,1) , (2 *R(2) - x_primary(in,2)), 0, x_primary(in,4) , -x_primary(in,5) , 0 ,(1 - w_abs)]; jn = jn + 1; x_image(jn,:) = im_3; D_images(jn) = D_primary(in);

im_4 = [x_primary(in,1) , -x_primary(in,2), 0,x_primary(in,4) , -x_primary(in,5), 0 ,(1 - w_abs)]; jn = jn + 1; x_image(jn,:) = im_4; D_images(jn) = D_primary(in);

end

%%% finding max / min [X,Y] values of image sources max_image = max(x_image(:, 1:2)); min_image = min(x_image(:, 1:2));

%%% combining image sources and primary sources x0 = [x_image ; x_primary];

%%% shifting entire x0 x0(:,1) = x0(:,1) - min_image(1); x0(:,2) = x0(:,2) - min_image(2);

%%% assigning new limits of simulation area X = [0, ( max_image(1) - min_image(1))]; Y = [0, ( max_image(2) - min_image(2))]; Z = 0;

%%% Assigning driving signals for image sources D = [D_images ; D_primary];

% Calculating sound Field [P,x,y,z] = sound_field_mono(X,Y,Z,x0,src,D,f,conf)

%%% Plotting sound field conf.plot.normalisation = 'center'; conf.plot.usenormalisation = true; plot_sound_field(P,x,y,z,x0,conf);

`

fietew commented 5 years ago

For convenience, please put the relevant code into a code cell like this

a = zeros(12,4);
fietew commented 5 years ago

@spors : Any code regarding WDAF with the SFS toolbox available?