Allolib  1.0
C++ Components For Interactive Multimedia
al_Dbap.hpp
1 #ifndef INCLUDE_AL_PANNING_DBAP
2 #define INCLUDE_AL_PANNING_DBAP
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology,
8  UCSB. Copyright (C) 2012. The Regents of the University of California. All
9  rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are
13  met:
14 
15  Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17 
18  Redistributions in binary form must reproduce the above
19  copyright notice, this list of conditions and the following disclaimer in the
20  documentation and/or other materials provided with the
21  distribution.
22 
23  Neither the name of the University of California nor the names
24  of its contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
28  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
30  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
31  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
32  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
33  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
34  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
35  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
36  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
37  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 
39 
40  File description:
41  Distance-based amplitude panner (DBAP)
42 
43  File author(s):
44  Ryan McGee, 2012, ryanmichaelmcgee@gmail.com
45 */
46 
47 #include "al/math/al_Vec.hpp"
48 #include "al/sound/al_Spatializer.hpp"
49 #include "al/sound/al_Speaker.hpp"
50 #include "al/spatial/al_DistAtten.hpp"
51 #include "al/spatial/al_Pose.hpp"
52 
53 namespace al {
54 
55 #define DBAP_MAX_NUM_SPEAKERS 192
56 
60 class Dbap : public Spatializer {
61  // do not hide base class functions
62  // using Spatializer::perform;
63 
64  public:
67  Dbap(const Speakers& sl, float focus = 1.f);
68 
69  virtual void renderSample(AudioIOData& io, const Pose& listeningPose,
70  const float& sample,
71  const unsigned int& frameIndex) override;
72  virtual void renderBuffer(AudioIOData& io, const Pose& listeningPose,
73  const float* samples,
74  const unsigned int& numFrames) override;
75 
77 
81  void setFocus(float focus) { mFocus = focus; }
82 
83  void print(std::ostream& stream) override;
84 
85  private:
86  // Listener * mListener;
87  Vec3f mSpeakerVecs[DBAP_MAX_NUM_SPEAKERS];
88  unsigned int mDeviceChannels[DBAP_MAX_NUM_SPEAKERS];
89  size_t mNumSpeakers;
90  float mFocus;
91 };
92 
93 } // namespace al
94 
95 #endif
void setFocus(float focus)
focus is an exponent determining the amplitude focus to nearby speakers.
Definition: al_Dbap.hpp:81
Dbap(const Speakers &sl, float focus=1.f)
virtual void renderBuffer(AudioIOData &io, const Pose &listeningPose, const float *samples, const unsigned int &numFrames) override
Render audio buffer in position.
virtual void renderSample(AudioIOData &io, const Pose &listeningPose, const float &sample, const unsigned int &frameIndex) override
Render audio sample in position.
void print(std::ostream &stream) override
Print out information about spatializer.
A local coordinate frame.
Definition: al_Pose.hpp:63
virtual void numFrames(unsigned int v)
Set number of frames.
Definition: al_App.hpp:23
std::vector< Speaker > Speakers
A set of speakers.
Definition: al_Speaker.hpp:101