资源简介

基于MATLAB的麦克风阵列的定位算法,具有很好的效果

资源截图

代码片段和文件信息



#define _USE_MATH_DEFINES

#include “matrix.h“
#include “mex.h“
#include “math.h“

#define ROUND(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))

#ifndef M_PI 
    #define M_PI 3.14159265358979323846 
#endif

double sinc(double x)
{
if (x == 0)
return(1.);
else
return(sin(x)/x);
}

double sim_microphone(double x double y double z double* angle char mtype)
{
    if (mtype==‘b‘ || mtype==‘c‘ || mtype==‘s‘ || mtype==‘h‘)
    {
        double strength vartheta varphi alpha;

        // Polar Pattern         alpha
        // ---------------------------
        // Bidirectional         0
        // Hypercardioid         0.25    
        // Cardioid              0.5
        // Subcardioid           0.75
        // Omnidirectional       1

        switch(mtype)
        {
        case ‘b‘:
            alpha = 0;
            break;
        case ‘h‘:
            alpha = 0.25;
            break;
        case ‘c‘:
            alpha = 0.5;
            break;
        case ‘s‘:
            alpha = 0.75;
            break;
        };
                
        vartheta = acos(z/sqrt(pow(x2)+pow(y2)+pow(z2)));
        varphi = atan2(yx);

        strength = sin(M_PI/2-angle[1]) * sin(vartheta) * cos(angle[0]-varphi) + cos(M_PI/2-angle[1]) * cos(vartheta);
        strength = alpha + (1-alpha) * strength;
                
        return strength;
    }
    else
    {
        return 1;
    }
}

void mexFunction(int nlhs mxArray *plhs[] int nrhs const mxArray *prhs[])
{
if (nrhs == 0)
{
mexPrintf(“--------------------------------------------------------------------\n“
“| Room Impulse Response Generator                                  |\n“
“|                                                                  |\n“
“| Computes the response of an acoustic source to one or more       |\n“
            “| microphones in a reverberant room using the image method [12].  |\n“
“|                                                                  |\n“
“| Author    : dr.ir. Emanuel Habets (ehabets@dereverberation.org)  |\n“
“|                                                                  |\n“
“| Version   : 2.0.20100920                                         |\n“
“|                                                                  |\n“
“| Copyright (C) 2003-2010 E.A.P. Habets The Netherlands.          |\n“
“|                                                                  |\n“
“| [1] J.B. Allen and D.A. Berkley                                 |\n“
“|     Image method for efficiently simulating small-room acoustics|\n“
“|     Journal Acoustic Society of America                         |\n“
“|     65(4) April 1979 p 943.                                    |\n“
“|                                                                  |\n“
“| [2] P.M. Peterson                                               |\n“
“|     Simulat

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      12963  2012-04-06 20:27  角度估计程序\rir_generator.cpp

     文件      24576  2012-04-06 20:27  角度估计程序\rir_generator.mexw32

     文件       2255  2012-07-11 16:37  角度估计程序\srplocalization.m

     文件     155042  2012-04-06 21:00  角度估计程序\S_01_01.wav

     文件       2924  2012-04-06 20:27  角度估计程序\tdelocalization.m

     文件        101  2012-04-06 20:27  角度估计程序\tds.m

     目录          0  2012-07-11 16:41  角度估计程序

----------- ---------  ---------- -----  ----

               197861                    7


评论

共有 条评论