From 5dc9385d045b9d30c9a9e6830d00b18f208b6843 Mon Sep 17 00:00:00 2001
From: ZaellixA <axilleaz@protonmail.com>
Date: Mon, 27 Jan 2025 19:19:12 +0000
Subject: [PATCH] Added different DMA desings for 2D and 3D diffuse sound
 fields

---
 .../MATLAB/Functions/firstOrderDma.m          | 47 +++++++++++++++----
 1 file changed, 39 insertions(+), 8 deletions(-)

diff --git a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m
index 7d03383..30748f6 100644
--- a/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m	
+++ b/Signal Processing/Array Processing/MATLAB/Functions/firstOrderDma.m	
@@ -27,15 +27,23 @@
 %                                            - Omni, Omnidirectional,
 %                                              Monopole
 %                                            - Dipole, Figure-of-Eight
-%                                            - Cardioid
-%                                            - Hypercardioid
-%                                            - Supercardioid
+%                                            - Cardioid, Cardio
+%                                            - Hypercardioid, Hyper,
+%                                              Hypercardioid2D, Hyper2D,
+%                                              Hypercardioid3D, Hyper3D
+%                                            - Supercardioid, Super,
+%                                              Supercardioid2D, Super2D,
+%                                              Supercardioid3D, Super3D
 %                                            It can also be a numeric value
 %                                            representing the angle for
 %                                            which the response is
 %                                            specified (input parameter
-%                                            "beta") in degrees.
-%                                            [Default: Dipole]
+%                                            "beta") in degrees. For more
+%                                            information on the differences
+%                                            between the 2D and 3D versions
+%                                            of the Hyper- and
+%                                            Super-cardioids see the notes
+%                                            below. [Default: Dipole]
 % 
 % beta [numeric] (Optional): The (normalised to unity) response at the
 %                            angle specified with teh parameter "pPattern".
@@ -63,6 +71,18 @@
 % --------------------------------------------------
 % Notes
 % 
+% - 2D and 3D versions: The directional patterns of the Hypercardioid and
+%                       Supercardioid are based on the optimisation of the
+%                       Directivity Index/Factor (DI/DF) and the
+%                       Front-to-Back Ratio (FBR). However, the results
+%                       depend on the type of the considered noise field.
+%                       Thus, the desings that optimise these metrics are
+%                       different for the spherically (3D) and
+%                       the cylindrically (2D) diffuse fields. The
+%                       available values without a dimension (either 2D or
+%                       3D) correspond to the spherically diffuse sound
+%                       field (3D case).
+% 
 % --------------------------------------------------
 function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
     % ====================================================
@@ -100,6 +120,11 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
     if nargin > 2 && ~isempty(pPattern)
         if isstring(pPattern) || ischar(pPattern)
             validateattributes(pPattern, {'char', 'string'}, {'scalartext', 'nonempty'}, mfilename, 'Polar pattern', 3);
+            validatestring(pPattern, ["Omni", "Omnidirectional", "Monopole", ...
+                                      "Dipole", "Figure-of-Eight", ...
+                                      "Cardioid", "Cardio", ...
+                                      "Hypercardioid", "Hyper", "Hypercardoid2d", "Hyper2d", "Hypercardoid3d", "Hyper3d", ...
+                                      "Supercardioid", "Super", "Supercardoid2d", "Super2d", "Supercardoid3d", "Super3d"])
         elseif isnumeric(pPattern)
             validateattributes(pPattern, {'numeric'}, {'scalar', 'real', 'nonnan', 'finite', 'nonempty'}, mfilename, 'Angle of null', 3);
         end
@@ -129,13 +154,19 @@ function [h, output] = firstOrderDma(freq, d, pPattern, beta, input)
             case {'dipole', 'figure-of-eight'}
                 pPattern = pi/2;
                 beta = 0;
-            case 'cardioid'
+            case {'cardioid', 'cardio'}
                 pPattern = -pi;
                 beta = 0;
-            case 'hypercardioid'
+            case {'hypercardioid', 'hyper', 'hypercardioid3d', 'hyper3d'}
+                pPattern = acos(-1/3);
+                beta = 0;
+            case {'hypercardioid2d', 'hyper2d'}
                 pPattern = (2 * pi/3);
                 beta = 0;
-            case 'supercardioid'
+            case {'supercardioid', 'super', 'supercardioid3d', 'super3d'}
+                pPattern = deg2rad(125);
+                beta = 0;
+            case {'supercardioid2d', 'super2d'}
                 pPattern = (3 * pi/4);
                 beta = 0;
             otherwise
-- 
GitLab