Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

FreqBeamDipole.cc

Go to the documentation of this file.
00001 /*
00002 
00003     Frequency-domain beamforming for dipole array
00004     Copyright (C) 2000-2001 Jussi Laako
00005 
00006     This program is free software; you can redistribute it and/or modify
00007     it under the terms of the GNU General Public License as published by
00008     the Free Software Foundation; either version 2 of the License, or
00009     (at your option) any later version.
00010 
00011     This program is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU General Public License for more details.
00015 
00016     You should have received a copy of the GNU General Public License
00017     along with this program; if not, write to the Free Software
00018     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 */
00021 
00022 
00023 #include <math.h>
00024 #include <float.h>
00025 
00026 #include <dsp/DSPVector.hh>
00027 
00028 #include "FreqBeamDipole.hh"
00029 
00030 
00031 void clFreqBeamDipole::SetDebug (bool bDebug)
00032 {
00033     long lSensorCntr;
00034 
00035     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00036     {
00037         if (bDebug) Sensors[lSensorCntr].EnableDebug();
00038         else Sensors[lSensorCntr].DisableDebug();
00039     }
00040 }
00041 
00042 
00043 bool clFreqBeamDipole::Initialize (GDT fSpacing, long lWinSize, 
00044     GDT fSampleRate)
00045 {
00046     long lSensorCntr;
00047 
00048     fSensorSpacing = fSpacing;
00049     if (!Sensors[0].Initialize(0, fSpacing, lWinSize) ||
00050         !Sensors[1].Initialize(fSpacing, 0, lWinSize))
00051         return false;
00052     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00053     {
00054         Sensors[lSensorCntr].SetSampleRate(fSampleRate);
00055     }
00056     return true;
00057 }
00058 
00059 
00060 void clFreqBeamDipole::SetSoundSpeed (GDT fSoundSpeed)
00061 {
00062     long lSensorCntr;
00063 
00064     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00065     {
00066         Sensors[lSensorCntr].SetSoundSpeed(fSoundSpeed);
00067         Sensors[lSensorCntr].SetArrayFrequency(
00068             fSoundSpeed / 2 / fSensorSpacing);
00069     }
00070 }
00071 
00072 
00073 void clFreqBeamDipole::SetDirection (GDT fDirection, bool bLowPass)
00074 {
00075     long lSensorCntr;
00076 
00077     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00078     {
00079         if (fDirection < 0 && lSensorCntr == 1)
00080             Sensors[lSensorCntr].SetDirection(fDirection, bLowPass);
00081         else if (fDirection >= 0 && lSensorCntr == 0)
00082             Sensors[lSensorCntr].SetDirection(fDirection, bLowPass);
00083         else
00084             Sensors[lSensorCntr].SetDirection(fDirection, true);
00085     }
00086 }
00087 
00088 
00089 void clFreqBeamDipole::Put (const GDT *fpSrc, long lSrcCount, 
00090     long lSensorOffs, long lChannels)
00091 {
00092     long lSensorCntr;
00093     clDSPVector<GDT> dspvSensorData;
00094     clDSPVector<GDT> dspvSrc(fpSrc, lSrcCount);
00095 
00096     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00097     {
00098         dspvSensorData.Extract(dspvSrc, lSensorOffs + lSensorCntr, lChannels);
00099         Sensors[lSensorCntr].Put(dspvSensorData.Ptr(), dspvSensorData.Size());
00100         dspvSensorData.Clear();
00101     }
00102 }
00103 
00104 
00105 bool clFreqBeamDipole::Get (GDT *fpDest, long lDestCount)
00106 {
00107     long lSensorCntr;
00108     clDSPVector<GDT> dspvSensorData(lDestCount);
00109     clDSPVector<GDT> dspvOutData(lDestCount);
00110 
00111     dspvOutData.Zero();
00112     for (lSensorCntr = 0; lSensorCntr < 2; lSensorCntr++)
00113     {
00114         if (!Sensors[lSensorCntr].Get(dspvSensorData.Ptr(), 
00115             dspvSensorData.Size())) return false;
00116         dspvOutData += dspvSensorData;
00117     }
00118     dspvOutData *= (GDT) 0.5;
00119     return dspvOutData.Get(fpDest, lDestCount);
00120 }

Generated on Sun Oct 26 19:11:20 2003 for HASAS by doxygen 1.3.3