11 #ifndef SAL_MICROPHONEARRAY_H
12 #define SAL_MICROPHONEARRAY_H
36 const std::vector<Microphone*>& microphones) :
49 mcl::Point old_mic_position =
microphones_[i]->position();
50 mcl::Point new_mic_position(old_mic_position.x()+position_delta.x(),
51 old_mic_position.y()+position_delta.y(),
52 old_mic_position.z()+position_delta.z());
75 if (num_microphones == 0 || num_microphones == 1) {
return true; }
129 const Int num_samples,
130 const mcl::Point& point,
132 Buffer& output_buffer) noexcept {
135 MonoBuffer referencing_buffer(output_buffer, mic_i);
138 microphones_[mic_i]->AddPlaneWave(input_data, num_samples, point,
139 wave_id, referencing_buffer);
144 const Int num_samples,
145 const mcl::Point& point,
147 Buffer& output_buffer) noexcept {
170 const T& mic_prototype,
173 MicrophoneFactory(mic_prototype, num_microphones)) {}
180 std::vector<Microphone*>
182 std::vector<Microphone*> output(num_microphones);
184 output[i] =
new T(mic_prototype);
202 const T& mic_prototype,
204 const std::vector<Angle>& angles) :
205 UniformArray<T>(position, orientation, mic_prototype, angles.size()),
206 radius_(radius), angles_(angles) {
212 std::vector<mcl::Point> positions = GetPositions(position, radius_, angles_);
215 Angle mic_angle = (this->
handedness_ == mcl::Handedness::kRightHanded) ? angles_[i] : -angles_[i];
216 mcl::Point relative_position = mcl::QuatRotate(
orientation,
217 mcl::Subtract(positions[i],
220 this->
microphones_[i]->SetPosition(mcl::Sum(relative_position, position));
222 mcl::Quaternion q = mcl::QuatMultiply(
orientation, mcl::AxAng2Quat(0.0, 0.0, 1.0, mic_angle));
229 std::vector<Angle> angles_;
231 static std::vector<mcl::Point> GetPositions(
const mcl::Point&
position,
233 const std::vector<Angle>& angles) {
234 std::vector<mcl::Point> positions(angles.size());
235 for (
Int i=0; i<(
Int)angles.size(); ++i) {
236 positions[i] = mcl::Point(radius*cos(angles[i])+position.x(),
237 radius*sin(angles[i])+position.y(),
257 const T& mic_prototype,
259 const Angle base_angle,
260 const Angle center_angle) :
262 mic_prototype, radius,
263 StereoAngles(base_angle, center_angle)) {}
266 static std::vector<Angle> StereoAngles(
const Angle base_angle,
267 const Angle center_angle) {
268 std::vector<Angle> angles(2);
269 angles[0] = center_angle-base_angle/2.0;
270 angles[1] = center_angle+base_angle/2.0;