Commit 743096db authored by Dipl.-Ing. Jonas Stienen's avatar Dipl.-Ing. Jonas Stienen

Improving generic unity / dirac daff data functions and adding more examples how to use them

parent aeeabe20
......@@ -16,9 +16,14 @@ metadata = daffv17_add_metadata( metadata, 'Generation script', 'String', 'Opend
addpath( 'datafuncs' )
%%
daffv17_write('filename', 'ExampleUnityOmni.ms.daff', ...
unity_dft_config.channels = 1;
unity_dft_config.freqs = [20 25 31.5 40 50 63 80 100 125 160 ...
200 250 315 400 500 630 800 1000 1250 1600 ...
2000 2500 3150 4000 5000 6300 8000 10000 12500 16000 20000];
daffv17_write('filename', 'ExampleUnityOmni_ThirdOctave.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfUnityMS, ...
'userdata', unity_dft_config, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
......@@ -27,7 +32,7 @@ daffv17_write('filename', 'ExampleUnityOmni.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleUnityUpperHemisphere.ms.daff', ...
daffv17_write('filename', 'ExampleUnityUpperHemisphere.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfUnityMS, ...
'channels', channels, ...
......@@ -39,7 +44,7 @@ daffv17_write('filename', 'ExampleUnityUpperHemisphere.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleUnityLowerHemisphere.ms.daff', ...
daffv17_write('filename', 'ExampleUnityLowerHemisphere.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfUnityMS, ...
'channels', channels, ...
......@@ -51,7 +56,7 @@ daffv17_write('filename', 'ExampleUnityLowerHemisphere.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleUnityFrontalHemisphere.ms.daff', ...
daffv17_write('filename', 'ExampleUnityFrontalHemisphere.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfUnityMS, ...
'channels', channels, ...
......@@ -63,7 +68,7 @@ daffv17_write('filename', 'ExampleUnityFrontalHemisphere.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleUnityRearHemisphere.ms.daff', ...
daffv17_write('filename', 'ExampleUnityRearHemisphere.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfUnityMS, ...
'channels', channels, ...
......@@ -75,9 +80,13 @@ daffv17_write('filename', 'ExampleUnityRearHemisphere.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleShortDiracOmni.ir.daff', ...
dirac_ir_config.numsamples = 4;
dirac_ir_config.channels = channels;
dirac_ir_config.samplerate = 48000;
daffv17_write('filename', 'ExampleShortDiracOmni_48kHz.v17.ir.daff', ...
'content', 'ir', ...
'datafunc', @dfDiracIR, ...
'userdata', dirac_ir_config, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
......@@ -87,10 +96,14 @@ daffv17_write('filename', 'ExampleShortDiracOmni.ir.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleShortDiracOmni.ir.daff', ...
dirac_ir_config.numsamples = 128;
dirac_ir_config.channels = 2;
dirac_ir_config.samplerate = 44100;
daffv17_write('filename', 'ExampleMultiChannelDiracOmni_128_44kHz.v17.ir.daff', ...
'content', 'ir', ...
'datafunc', @dfDiracIR, ...
'channels', channels, ...
'userdata', dirac_ir_config, ...
'channels', dirac_ir_config.channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
'orient', default_orient, ...
......@@ -99,7 +112,7 @@ daffv17_write('filename', 'ExampleShortDiracOmni.ir.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleFigureOfEightFront.ms.daff', ...
daffv17_write('filename', 'ExampleFigureOfEightFront.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfFigureOfEightMS, ...
'channels', channels, ...
......@@ -111,7 +124,7 @@ daffv17_write('filename', 'ExampleFigureOfEightFront.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleFigureOfEightFront.mps.daff', ...
daffv17_write('filename', 'ExampleFigureOfEightFront.v17.mps.daff', ...
'content', 'mps', ...
'datafunc', @dfFigureOfEightMPS, ...
'channels', channels, ...
......@@ -123,7 +136,7 @@ daffv17_write('filename', 'ExampleFigureOfEightFront.mps.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleFigureOfEightSide.ms.daff', ...
daffv17_write('filename', 'ExampleFigureOfEightSide.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfFigureOfEightMS, ...
'channels', channels, ...
......@@ -135,7 +148,7 @@ daffv17_write('filename', 'ExampleFigureOfEightSide.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleLowPass3dBOmni.ms.daff', ...
daffv17_write('filename', 'ExampleLowPass3dBOmni.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfLowPass3dBMS, ...
'channels', channels, ...
......@@ -146,7 +159,7 @@ daffv17_write('filename', 'ExampleLowPass3dBOmni.ms.daff', ...
disp( ' ' )
%%
daffv17_write('filename', 'ExampleLowPass6dBOmni.ms.daff', ...
daffv17_write('filename', 'ExampleLowPass6dBOmni.v17.ms.daff', ...
'content', 'ms', ...
'datafunc', @dfLowPass6dBMS, ...
'channels', channels, ...
......@@ -155,3 +168,65 @@ daffv17_write('filename', 'ExampleLowPass6dBOmni.ms.daff', ...
'orient', default_orient, ...
'metadata', metadata);
disp( ' ' )
%%
daffv17_write('filename', 'ExampleUnityOmni.v17.dft.daff', ...
'content', 'dft', ...
'datafunc', @dfUnityDFT, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
'orient', default_orient, ...
'metadata', metadata);
disp( ' ' )
%%
unity_dft_config.channels = 1;
unity_dft_config.length = 128+1;
unity_dft_config.is_symmetric = false;
unity_dft_config.samplerate = 44100;
unity_dft_config.complex_value = 1;
daffv17_write('filename', 'ExampleUnityOmni_128_44kHz.v17.dft.daff', ...
'content', 'dft', ...
'datafunc', @dfUnityDFT, ...
'userdata', unity_dft_config, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
'orient', default_orient, ...
'metadata', metadata);
disp( ' ' )
%%
unity_dft_config.channels = 1;
unity_dft_config.length = 128+1;
unity_dft_config.is_symmetric = false;
unity_dft_config.samplerate = 44100;
unity_dft_config.complex_value = sqrt( 2 ) * ( 1 + 1j );
daffv17_write('filename', 'ExampleUnityOmni_128_44kHz_45deg.v17.dft.daff', ...
'content', 'dft', ...
'datafunc', @dfUnityDFT, ...
'userdata', unity_dft_config, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
'orient', default_orient, ...
'metadata', metadata);
disp( ' ' )
%%
unity_dft_config.channels = 1;
unity_dft_config.length = 128+1;
unity_dft_config.is_symmetric = false;
unity_dft_config.samplerate = 44100;
unity_dft_config.complex_value = -1 + 1i * 0;
daffv17_write('filename', 'ExampleUnityOmni_128_44kHz_phase_inverted.v17.dft.daff', ...
'content', 'dft', ...
'datafunc', @dfUnityDFT, ...
'userdata', unity_dft_config, ...
'channels', channels, ...
'alphares', alpha_res, ...
'betares', beta_res, ...
'orient', default_orient, ...
'metadata', metadata);
disp( ' ' )
function [ data, samplerate, metadata ] = dfDiracIR( ~, ~, ~ )
function [ data, samplerate, metadata ] = dfDiracIR( ~, ~, dirac_ir_config )
channels = 1;
filter_length = 4;
samplerate = 48000.0;
if ~isempty( dirac_ir_config )
channels = dirac_ir_config.channels;
filter_length = dirac_ir_config.numsamples;
samplerate = dirac_ir_config.samplerate;
else
% use default values
channels = 1;
filter_length = 128;
samplerate = 44100;
end
metadata = [];
......
function [ data, sampleRate, isSymetric, metadata ] = dfUnityDFT( ~, ~, ~ )
function [ data, samplerate, is_symetric, metadata ] = dfUnityDFT( ~, ~, unity_dft_config )
% Omnidirectional discrete Fourier transform
channels = 1;
bins = 128;
if ~isempty( fieldnames( unity_dft_config ) )
channels = unity_dft_config.channels;
bins = unity_dft_config.length;
is_symetric = unity_dft_config.is_symmetric;
samplerate = unity_dft_config.samplerate;
complex_value = unity_dft_config.complex_value;
else
channels = 1;
bins = 128;
is_symetric = false;
samplerate = 44100;
complex_value = 1 + 1i * 0;
end
data = zeros( channels, bins );
metadata = [];
isSymetric = false;
sampleRate = 44100;
data = zeros( channels, bins );
for c = 1:channels
for n = 1:bins
data( c, n ) = 1.0 + 1i*0.0;
data( c, n ) = complex_value;
end
end
end
function [ freqs, mags, metadata ] = dfUnityMS( ~, ~, ~ )
function [ freqs, mags, metadata ] = dfUnityMS( ~, ~, unity_ms_config )
% Omnidirectional magnitude spectrum
% Third-octave resolution
freqs = [20 25 31.5 40 50 63 80 100 125 160 ...
200 250 315 400 500 630 800 1000 1250 1600 ...
2000 2500 3150 4000 5000 6300 8000 10000 12500 16000 20000];
if ~isempty( fieldnames( unity_ms_config ) )
freqs = unity_ms_config.freqs;
channels = unity_ms_config.channels;
else
% Third-octave resolution
freqs = [20 25 31.5 40 50 63 80 100 125 160 ...
200 250 315 400 500 630 800 1000 1250 1600 ...
2000 2500 3150 4000 5000 6300 8000 10000 12500 16000 20000];
channels = 1;
end
channels = 1;
mags = zeros(channels, length(freqs));
mags = zeros( channels, numel( freqs ) );
metadata = [];
for c=1:channels
......
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