@@ -53,51 +53,54 @@ Before showing the different geometries, we start with some common settings. Fir
53
53
and set the array size/diameter to 3m.
54
54
55
55
``` Matlab
56
- conf = SFS_config ;
56
+ conf = SFS_config_example ;
57
57
conf.secondary_sources.size = 3;
58
58
```
59
59
60
60
#### linear array
61
61
62
62
``` Matlab
63
+ conf = SFS_config_example;
63
64
conf.secondary_sources.geometry = 'line'; % or 'linear'
64
65
conf.secondary_sources.number = 21;
65
66
x0 = secondary_source_positions(conf);
66
67
figure;
67
68
figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit);
68
- draw_loudspeakers(x0);
69
+ draw_loudspeakers(x0,[1 1 0],conf );
69
70
axis([-2 2 -2 1]);
70
- print_png('img/secondary_sources_linear.png');
71
+ % print_png('img/secondary_sources_linear.png');
71
72
```
72
73
73
74
![ Image] ( doc/img/secondary_sources_linear.png )
74
75
75
76
#### circular array
76
77
77
78
``` Matlab
79
+ conf = SFS_config_example;
78
80
conf.secondary_sources.geometry = 'circle'; % or 'circular'
79
81
conf.secondary_sources.number = 56;
80
82
x0 = secondary_source_positions(conf);
81
83
figure;
82
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
83
- draw_loudspeakers(x0);
84
+ figsize(540,404,'px' );
85
+ draw_loudspeakers(x0,[1 1 0],conf );
84
86
axis([-2 2 -2 2]);
85
- print_png('img/secondary_sources_circle.png');
87
+ % print_png('img/secondary_sources_circle.png');
86
88
```
87
89
88
90
![ Image] ( doc/img/secondary_sources_circle.png )
89
91
90
92
#### box shaped array
91
93
92
94
``` Matlab
95
+ conf = SFS_config_example;
93
96
conf.secondary_sources.geometry = 'box';
94
97
conf.secondary_sources.number = 84;
95
98
x0 = secondary_source_positions(conf);
96
99
figure;
97
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
98
- draw_loudspeakers(x0);
100
+ figsize(540,404,'px' );
101
+ draw_loudspeakers(x0,[0 0 1],conf );
99
102
axis([-2 2 -2 2]);
100
- print_png('img/secondary_sources_box.png');
103
+ % print_png('img/secondary_sources_box.png');
101
104
```
102
105
103
106
![ Image] ( doc/img/secondary_sources_box.png )
@@ -117,14 +120,17 @@ download the whole [data repository](http://github.com/sfstoolbox/data) to the
117
120
<code >data</code > folder.
118
121
119
122
``` Matlab
123
+ conf = SFS_config_example;
124
+ conf.secondary_sources.size = 3;
120
125
conf.secondary_sources.geometry = 'sphere'; % or 'spherical'
126
+ conf.secondary_sources.grid = 'equally_spaced_points';
121
127
conf.secondary_sources.number = 225;
122
128
x0 = secondary_source_positions(conf);
123
129
figure;
124
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
125
- draw_loudspeakers(x0);
130
+ figsize(540,404,'px' );
131
+ draw_loudspeakers(x0,[1 1 0],conf );
126
132
axis([-2 2 -2 2]);
127
- print_png('img/secondary_sources_sphere.png');
133
+ % print_png('img/secondary_sources_sphere.png');
128
134
```
129
135
130
136
![ Image] ( doc/img/secondary_sources_sphere.png )
@@ -143,6 +149,7 @@ the sound field from the given driving signals and secondary sources. For WFS
143
149
the <code >r^2 cos(theta)</code > weights for integration on a sphere.
144
150
145
151
``` Matlab
152
+ conf = SFS_config_example;
146
153
% create a stadium like shape by combining two half circles with two linear
147
154
% arrays
148
155
% first getting a full circle with 56 loudspeakers
@@ -177,10 +184,10 @@ conf.secondary_sources.x0 = [x01; x02; x03; x04];
177
184
% simply return the defined x0 matrix
178
185
x0 = secondary_source_positions(conf);
179
186
figure;
180
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
181
- draw_loudspeakers(x0);
187
+ figsize(540,404,'px' );
188
+ draw_loudspeakers(x0,[1 1 0],conf );
182
189
axis([-2 2 -2.5 2.5]);
183
- print_png('img/secondary_sources_arbitrary.png');
190
+ % print_png('img/secondary_sources_arbitrary.png');
184
191
```
185
192
186
193
![ Image] ( doc/img/secondary_sources_arbitrary.png )
@@ -194,10 +201,10 @@ symbols, for example the following will replot the last array.
194
201
``` Matlab
195
202
conf.plot.realloudspeakers = true;
196
203
figure;
197
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
204
+ figsize(540,404,'px' );
198
205
draw_loudspeakers(x0,conf);
199
206
axis([-2 2 -2.5 2.5]);
200
- print_png('img/secondary_sources_arbitrary_realloudspeakers.png');
207
+ % print_png('img/secondary_sources_arbitrary_realloudspeakers.png');
201
208
```
202
209
203
210
![ Image] ( doc/img/secondary_sources_arbitrary_realloudspeakers.png )
@@ -226,18 +233,18 @@ The following will simulate the field of a virtual plane wave with a frequency
226
233
of 800 Hz going into the direction of (0 -1 0) synthesized with 3D WFS.
227
234
228
235
``` Matlab
229
- conf = SFS_config ;
236
+ conf = SFS_config_example ;
230
237
conf.dimension = '3D';
231
238
conf.secondary_sources.size = 3;
232
239
conf.secondary_sources.number = 225;
233
240
conf.secondary_sources.geometry = 'sphere';
234
241
% [P,x,y,z,x0,win] = sound_field_mono_wfs(X,Y,Z,xs,src,f,conf);
235
242
sound_field_mono_wfs([-2 2],[-2 2],0,[0 -1 0],'pw',800,conf);
236
- print_png('img/sound_field_wfs_3d_xy.png');
243
+ % print_png('img/sound_field_wfs_3d_xy.png');
237
244
sound_field_mono_wfs([-2 2],0,[-2 2],[0 -1 0],'pw',800,conf);
238
- print_png('img/sound_field_wfs_3d_xz.png');
245
+ % print_png('img/sound_field_wfs_3d_xz.png');
239
246
sound_field_mono_wfs(0,[-2 2],[-2 2],[0 -1 0],'pw',800,conf);
240
- print_png('img/sound_field_wfs_3d_yz.png');
247
+ % print_png('img/sound_field_wfs_3d_yz.png');
241
248
```
242
249
243
250
![ Image] ( doc/img/sound_field_wfs_3d_xy.png )
@@ -258,12 +265,12 @@ have to explicitly say if we want also plot the results, by
258
265
<code >conf.plot.useplot = true;</code >.
259
266
260
267
``` Matlab
261
- conf = SFS_config ;
268
+ conf = SFS_config_example ;
262
269
conf.dimension = '2.5D';
263
270
conf.plot.useplot = 1;
264
271
% [P,x,y,z,x0] = sound_field_mono_wfs(X,Y,Z,xs,src,f,conf);
265
272
[P,x,y,z,x0] = sound_field_mono_wfs([-2 2],[-2 2],0,[0 2.5 0],'ps',800,conf);
266
- print_png('img/sound_field_wfs_25d.png');
273
+ % print_png('img/sound_field_wfs_25d.png');
267
274
```
268
275
269
276
![ Image] ( doc/img/sound_field_wfs_25d.png )
@@ -281,7 +288,7 @@ x0_all = secondary_source_positions(conf);
281
288
x0_all(:,7) = zeros(1,size(x0_all,1));
282
289
x0_all(idx,7) = x0(:,7);
283
290
plot_sound_field(P,x,y,z,x0_all,conf);
284
- print_png('img/sound_field_wfs_25d_with_all_sources.png');
291
+ % print_png('img/sound_field_wfs_25d_with_all_sources.png');
285
292
```
286
293
287
294
![ Image] ( doc/img/sound_field_wfs_25d_with_all_sources.png )
@@ -293,11 +300,11 @@ In the following we will simulate the field of a virtual plane wave with a frequ
293
300
of 800 Hz traveling into the direction (0 -1 0), synthesized with 2.5D NFC-HOA.
294
301
295
302
``` Matlab
296
- conf = SFS_config ;
303
+ conf = SFS_config_example ;
297
304
conf.dimension = '2.5D';
298
305
% sound_field_mono_nfchoa(X,Y,Z,xs,src,f,conf);
299
306
sound_field_mono_nfchoa([-2 2],[-2 2],0,[0 -1 0],'pw',800,conf);
300
- print_png('img/sound_field_nfchoa_25d.png');
307
+ % print_png('img/sound_field_nfchoa_25d.png');
301
308
```
302
309
303
310
![ Image] ( doc/img/sound_field_nfchoa_25d.png )
@@ -311,10 +318,11 @@ single secondary sources to the resulting sound field. With these function you
311
318
can for example easily simulate a stereophonic setup.
312
319
313
320
``` Matlab
321
+ conf = SFS_config_example;
314
322
x0 = [-1 2 0 0 -1 0 1;1 2 0 0 -1 0 1];
315
323
% [P,x,y,z] = sound_field_mono(X,Y,Z,x0,src,D,f,conf)
316
- sound_field_mono([-2 2],[-1 3],0,x0,'ps',[1 1],800)
317
- print_png('img/sound_field_stereo.png');
324
+ sound_field_mono([-2 2],[-1 3],0,x0,'ps',[1 1],800,conf )
325
+ % print_png('img/sound_field_stereo.png');
318
326
```
319
327
![ Image] ( doc/img/sound_field_stereo.png )
320
328
@@ -328,12 +336,12 @@ In the following we will create a snapshot in time after 200 samples for a broad
328
336
virtual point source placed at (0 2 0) m for 2.5D NFC-HOA.
329
337
330
338
``` Matlab
331
- conf = SFS_config ;
339
+ conf = SFS_config_example ;
332
340
conf.dimension = '2.5D';
333
341
conf.plot.useplot = true;
334
342
% sound_field_imp_nfchoa(X,Y,Z,xs,src,t,conf)
335
343
[p,x,y,z,x0] = sound_field_imp_nfchoa([-2 2],[-2 2],0,[0 2 0],'ps',200,conf);
336
- print_png('img/sound_field_imp_nfchoa_25d.png');
344
+ % print_png('img/sound_field_imp_nfchoa_25d.png');
337
345
```
338
346
339
347
![ Image] ( doc/img/sound_field_imp_nfchoa_25d.png )
@@ -348,7 +356,7 @@ We change also the color map to the Matlab default one.
348
356
conf.plot.usedb = true;
349
357
conf.plot.colormap = 'jet';
350
358
plot_sound_field(p,x,y,z,x0,conf);
351
- print_png('img/sound_field_imp_nfchoa_25d_dB.png');
359
+ % print_png('img/sound_field_imp_nfchoa_25d_dB.png');
352
360
```
353
361
354
362
![ Image] ( doc/img/sound_field_imp_nfchoa_25d_dB.png )
@@ -382,28 +390,28 @@ two available angles will be applied. Afterwards a noise signal is created and c
382
390
with the impulse response by the <code >auralize_ir()</code > function.
383
391
384
392
``` Matlab
385
- conf = SFS_config ;
386
- irs = read_irs('QU_KEMAR_anechoic_3m.mat');
393
+ conf = SFS_config_example ;
394
+ irs = read_irs('QU_KEMAR_anechoic_3m.mat',conf );
387
395
ir = get_ir(irs,[rad(30) 0 3]);
388
396
nsig = randn(44100,1);
389
- sig = auralize_ir(ir,nsig);
397
+ sig = auralize_ir(ir,nsig,1,conf );
390
398
sound(sig,conf.fs);
391
399
```
392
400
393
401
To simulate the same source as a virtual point source synthesized by WFS and a
394
402
circular array with a diameter of 3 m, you have to do the following.
395
403
396
404
``` Matlab
397
- conf = SFS_config ;
405
+ conf = SFS_config_example ;
398
406
conf.secondary_sources.size = 3;
399
407
conf.secondary_sources.number = 56;
400
408
conf.secondary_sources.geometry = 'circle';
401
409
conf.dimension = '2.5D';
402
- irs = read_irs('QU_KEMAR_anechoic_3m.mat');
410
+ irs = read_irs('QU_KEMAR_anechoic_3m.mat',conf );
403
411
% ir = ir_wfs(X,phi,xs,src,irs,conf);
404
412
ir = ir_wfs([0 0 0],pi/2,[0 3 0],'ps',irs,conf);
405
413
nsig = randn(44100,1);
406
- sig = auralize_ir(ir,nsig);
414
+ sig = auralize_ir(ir,nsig,1,conf );
407
415
```
408
416
409
417
Binaural simulations are also a nice way to investigate the frequency response
@@ -414,25 +422,25 @@ expected aliasing frequency of the system (above these frequency the spectrum
414
422
becomes very noise as you can see in the figure).
415
423
416
424
``` Matlab
417
- conf = SFS_config ;
425
+ conf = SFS_config_example ;
418
426
conf.ir.usehcomp = 0;
419
427
conf.wfs.usehpre = 0;
420
428
irs = dummy_irs;
421
429
[ir1,x0] = ir_wfs([0 0 0],pi/2,[0 2.5 0],'ps',irs,conf);
422
430
conf.wfs.usehpre = 1;
423
- conf.wfs.hprefhigh = aliasing_frequency(x0);
431
+ conf.wfs.hprefhigh = aliasing_frequency(x0,conf );
424
432
ir2 = ir_wfs([0 0 0],pi/2,[0 2.5 0],'ps',irs,conf);
425
- [a1,p,f] = easyfft(ir1(:,1)./max(abs(ir1(:,1))));
426
- a2 = easyfft(ir2(:,1)./max(abs(ir2(:,1))));
433
+ [a1,p,f] = easyfft(ir1(:,1)./max(abs(ir1(:,1))),conf );
434
+ a2 = easyfft(ir2(:,1)./max(abs(ir2(:,1))),conf );
427
435
figure;
428
- figsize(conf.plot.size(1),conf.plot.size(2),conf.plot.size_unit );
436
+ figsize(540,404,'px' );
429
437
semilogx(f,20*log10(a1),'-b',f,20*log10(a2),'-r');
430
438
axis([10 20000 -80 -40]);
431
439
set(gca,'XTick',[10 100 250 1000 5000 20000]);
432
440
legend('w/o pre-filter','w pre-filter');
433
441
xlabel('frequency / Hz');
434
442
ylabel('magnitude / dB');
435
- print_png('img/impulse_response_wfs_25d.png');
443
+ % print_png('img/impulse_response_wfs_25d.png');
436
444
```
437
445
438
446
![ Image] ( doc/img/impulse_response_wfs_25d.png )
@@ -443,7 +451,8 @@ frequency range will be affected.
443
451
444
452
``` Matlab
445
453
freq_response_wfs([0 0 0],[0 2.5 0],'ps',conf);
446
- print_png('img/impulse_response_wfs_25d_mono.png');
454
+ axis([10 20000 -20 20]);
455
+ %print_png('img/impulse_response_wfs_25d_mono.png');
447
456
```
448
457
449
458
![ Image] ( doc/img/impulse_response_wfs_25d_mono.png )
@@ -460,6 +469,7 @@ responses used by the SoundScape Renderer.
460
469
All functions regarding the SSR are stored in <code >SFS_ssr</code >.
461
470
462
471
``` Matlab
472
+ conf = SFS_config_example;
463
473
brs = ssr_brs_wfs(X,phi,xs,src,irs,conf);
464
474
wavwrite(brs,fs,16,'brs_set_for_SSR.wav');
465
475
```
@@ -490,7 +500,7 @@ you cannot do the plotting to png afterwards like in Matlab, but have to specify
490
500
the output file before. Note, that the same will work with Matlab.
491
501
492
502
``` Matlab
493
- conf = SFS_config ;
503
+ conf = SFS_config_example ;
494
504
conf.plot.colormap = 'gray';
495
505
conf.plot.usegnuplot = 1;
496
506
conf.plot.file = 'img/sound_field_nfchoa_25d_gnuplot.png';
0 commit comments