Enki  1.9
Microphone.h
Go to the documentation of this file.
1 /*
2  Enki - a fast 2D robot simulator
3  Copyright (C) 1999-2016 Stephane Magnenat <stephane at magnenat dot net>
4  Copyright (C) 2004-2005 Markus Waibel <markus dot waibel at epfl dot ch>
5  Copyright (c) 2004-2005 Antoine Beyeler <abeyeler at ab-ware dot com>
6  Copyright (C) 2005-2006 Laboratory of Intelligent Systems, EPFL, Lausanne
7  Copyright (C) 2006-2008 Laboratory of Robotics Systems, EPFL, Lausanne
8  See AUTHORS for details
9 
10  This program is free software; the authors of any publication
11  arising from research using this software are asked to add the
12  following reference:
13  Enki - a fast 2D robot simulator
14  http://home.gna.org/enki
15  Stephane Magnenat <stephane at magnenat dot net>,
16  Markus Waibel <markus dot waibel at epfl dot ch>
17  Laboratory of Intelligent Systems, EPFL, Lausanne.
18 
19  You can redistribute this program and/or modify
20  it under the terms of the GNU General Public License as published by
21  the Free Software Foundation; either version 2 of the License, or
22  (at your option) any later version.
23 
24  This program is distributed in the hope that it will be useful,
25  but WITHOUT ANY WARRANTY; without even the implied warranty of
26  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  GNU General Public License for more details.
28 
29  You should have received a copy of the GNU General Public License
30  along with this program; if not, write to the Free Software
31  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
32 */
33 
34 #ifndef __ENKI_MICROPHONE_H
35 #define __ENKI_MICROPHONE_H
36 
37 #include <enki/PhysicalEngine.h>
38 #include <enki/Interaction.h>
39 #include "ActiveSoundSource.h"
40 
41 #include <valarray>
42 
47 namespace Enki
48 {
50  typedef double (*MicrophoneResponseModel)(double, double);
51 
53 
55  {
56  protected:
66  double range;
68  unsigned noOfChannels;
70  double* acquiredSound;
71 
72  public:
77  Microphone(Robot *owner, Vector micRelPos, double range,
78  MicrophoneResponseModel micModel, unsigned channels);
80  ~Microphone(void);
82  void init();
84  virtual void objectStep(double dt, PhysicalObject *po, World *w);
86  void resetSound(void);
88  double* getAcquiredSound(void);
90  void getMaxChannel(double *intensity, int *channel);
93  };
94 
96 
98  {
99  protected:
103  Vector allMicAbsPos[4];
105  double micDist;
109  double range;
111  unsigned noOfChannels;
113  double* acquiredSound[4];
114 
115  public:
120  FourWayMic(Robot *owner, double micDist, double range,
121  MicrophoneResponseModel micModel, unsigned channels);
123  ~FourWayMic(void);
125  void init();
127  virtual void objectStep(double dt, PhysicalObject *po, World *w);
129  void resetSound(void);
131  double* getAcquiredSound(unsigned micNo);
133  void getMaxChannel(unsigned micNo, double *intensity, int *channel);
135  Vector getMicAbsPos(unsigned micNo);
136  };
137 }
138 
139 #endif
A vector in a 2D space.
Definition: Geometry.h:68
double * getAcquiredSound(void)
Return frequencies of input sound.
Definition: Microphone.cpp:116
void resetSound(void)
Reset sound buffer to 0 after one time-step in experiment.
Definition: Microphone.cpp:121
Vector micRelPos
Relative position of mic on object.
Definition: Microphone.h:62
A generic sound sensor/microphone.
Definition: Microphone.h:54
Vector micAbsPos
Absolute position in the world, updated on init()
Definition: Microphone.h:60
Header of sound emitter interaction.
A situated object in the world with mass, geometry properties, physical properties, ...
Definition: PhysicalEngine.h:131
A generic sound sensor/microphone.
Definition: Microphone.h:97
PhysicalObject * owner
Robot/object with the microphone.
Definition: Microphone.h:58
unsigned noOfChannels
No of frequency channels distinguished in input.
Definition: Microphone.h:68
Enki is the namespace of the Enki simulator. All Enki functions and classes excepted the math one are...
Definition: BluetoothBase.cpp:44
~Microphone(void)
Destructor.
Definition: Microphone.cpp:63
unsigned noOfChannels
No of frequency channels distinguished in input.
Definition: Microphone.h:111
The interfaces for the interactions.
void init()
Reset distance values, called every w->step()
Definition: Microphone.cpp:68
PhysicalObject * owner
Robot/object with the microphone.
Definition: Microphone.h:101
double * acquiredSound
microphone input signal (array of size noOfChannels)
Definition: Microphone.h:70
void getMaxChannel(double *intensity, int *channel)
Find frequency with maximum intensity.
Definition: Microphone.cpp:126
virtual void objectStep(double dt, PhysicalObject *po, World *w)
Check for local interactions with other physical objects.
Definition: Microphone.cpp:75
The world is the container of all objects and robots.
Definition: PhysicalEngine.h:411
MicrophoneResponseModel micModel
Microphone frequency response model.
Definition: Microphone.h:64
double range
Actual detection range.
Definition: Microphone.h:66
double range
Actual detection range.
Definition: Microphone.h:109
Microphone(Robot *owner, Vector micRelPos, double range, MicrophoneResponseModel micModel, unsigned channels)
Constructor e.g.
Definition: Microphone.cpp:46
Interacts with another object or wall only up to a certain distance.
Definition: Interaction.h:53
double micDist
Distance of the mics from centre of object.
Definition: Microphone.h:105
double(* MicrophoneResponseModel)(double, double)
A function for manipulating acquired sound, normally to model saturation, distance decreasing or freq...
Definition: Microphone.h:50
The core of Enki.
MicrophoneResponseModel micModel
Microphone frequency response model.
Definition: Microphone.h:107
A robot is a PhysicalObject that has additional interactions and a controller.
Definition: PhysicalEngine.h:379
Vector getMicAbsPos()
Get absolute position of microphone.
Definition: Microphone.cpp:140