Allolib  1.0
C++ Components For Interactive Multimedia
al_Spatializer.hpp
1 #ifndef AL_SPATIALIZER_H
2 #define AL_SPATIALIZER_H
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-2015. The Regents of the University of California.
9  All 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 met:
13 
14  Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16 
17  Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 
21  Neither the name of the University of California nor the names of its
22  contributors may be used to endorse or promote products derived from
23  this software without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  POSSIBILITY OF SUCH DAMAGE.
36 
37  File description:
38  Spatializer base class
39  File author(s):
40  Lance Putnam, 2010, putnam.lance@gmail.com
41  Graham Wakefield, 2010, grrrwaaa@gmail.com
42  Ryan McGee, 2012, ryanmichaelmcgee@gmail.com
43 */
44 
45 #include <iostream>
46 
47 #include "al/io/al_AudioIOData.hpp"
48 #include "al/sound/al_Speaker.hpp"
49 #include "al/spatial/al_Pose.hpp"
50 
51 namespace al {
52 
56 class Spatializer {
57 public:
59  Spatializer(const Speakers &sl);
60 
61  virtual ~Spatializer() {}
62 
66  virtual void compile() {}
67 
70  virtual void prepare(AudioIOData &io) {}
71 
73  virtual void renderBuffer(AudioIOData &io, const Pose &listeningPose,
74  const float *samples,
75  const unsigned int &numFrames) = 0;
76 
78  virtual void renderSample(AudioIOData &io, const Pose &listeningPose,
79  const float &sample,
80  const unsigned int &frameIndex) = 0;
81 
84  virtual void finalize(AudioIOData &io) {}
85 
87  virtual void print(std::ostream &stream = std::cout) {}
88 
90  int numSpeakers() const { return int(mSpeakers.size()); }
91 
93  virtual void numFrames(unsigned int v) { mNumFrames = v; }
94 
95 protected:
96  Speakers mSpeakers;
97 
98  std::vector<float> mBuffer; // temporary frame buffer
99  unsigned int mNumFrames{0};
100 };
101 
102 } // namespace al
103 
104 #endif
A local coordinate frame.
Definition: al_Pose.hpp:63
virtual void print(std::ostream &stream=std::cout)
Print out information about spatializer.
virtual void renderSample(AudioIOData &io, const Pose &listeningPose, const float &sample, const unsigned int &frameIndex)=0
Render audio sample in position.
virtual void compile()
virtual void numFrames(unsigned int v)
Set number of frames.
virtual void prepare(AudioIOData &io)
virtual void renderBuffer(AudioIOData &io, const Pose &listeningPose, const float *samples, const unsigned int &numFrames)=0
Render audio buffer in position.
int numSpeakers() const
Get number of speakers.
virtual void finalize(AudioIOData &io)
Spatializer(const Speakers &sl)
Definition: al_App.hpp:23
std::vector< Speaker > Speakers
A set of speakers.
Definition: al_Speaker.hpp:101